Compare commits

...

10 Commits

45
.gitignore vendored

@ -1,36 +1,30 @@
# Object files
*.o
*.o.*
*.ko
*.obj
*.elf
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects
*.so
*.so.*
# Binary files
wsdd
wsdd_debug
# SDK files
SDK/
gsoap-2.8/
generated/
# cmake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
/[Dd]ebug*/
/[Rr]elease*/
/[Bb]uild*/
/MinSizeRel*/
/RelWithDebInfo*/
# Temp files
@ -40,6 +34,5 @@ generated/
*.depend
# Files that we don't want to ignore
!.gitignore

@ -0,0 +1,198 @@
cmake_minimum_required(VERSION 3.15)
message(STATUS "Generator is set to: ${CMAKE_GENERATOR}")
#set(CMAKE_VERBOSE_MAKEFILE ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "No CMAKE_BUILD_TYPE specified, force set to: ${CMAKE_BUILD_TYPE}")
endif()
set(DAEMON_NAME wsdd)
set(DAEMON_MAJOR_VERSION 3)
set(DAEMON_MINOR_VERSION 0)
set(DAEMON_PATCH_VERSION patch)
# variants: patch - set PATCH_VERSION == number of commits(patches) between head and last tag
# variants: xxx - set PATCH_VERSION == xxx (your variant)
set(DAEMON_PID_FILE_NAME ${DAEMON_NAME}.pid)
set(DAEMON_LOG_FILE_NAME ${DAEMON_NAME}.log)
set(DAEMON_NO_CHDIR 1)
set(DAEMON_NO_CLOSE_STDIO $<STREQUAL:$<LOWER_CASE:${CMAKE_BUILD_TYPE}>,debug>) # 1 (NO_CLOSE if debug)
project(${DAEMON_NAME} LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g")
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG")
set(CMAKE_C_FLAGS "-O2")
add_compile_options(
-Wall
-Wextra
)
add_compile_definitions(
DAEMON_NAME="${DAEMON_NAME}"
DAEMON_PID_FILE_NAME="${DAEMON_PID_FILE_NAME}"
DAEMON_LOG_FILE_NAME="${DAEMON_LOG_FILE_NAME}"
DAEMON_NO_CHDIR=${DAEMON_NO_CHDIR}
DAEMON_NO_CLOSE_STDIO=${DAEMON_NO_CLOSE_STDIO}
)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(USE_SYSTEM_GSOAP)
#set(GSOAP_DIR "${CMAKE_BINARY_DIR}/gsoap-2.8/gsoap")
find_package(gSOAP REQUIRED)
else()
set(GSOAP_VERSION 2.8.66)
set(GSOAP_INSTALL_DIR "${CMAKE_SOURCE_DIR}")
set(GSOAP_ARCHIVE_DIR "${CMAKE_SOURCE_DIR}/SDK")
set(GSOAP_PATCHES soapcpp2_lex.l.patch)
set(GSOAP_CONFIGURE --disable-c-locale --disable-ssl)
include(build_gsoap)
endif()
set(COMMON_DIR "${CMAKE_SOURCE_DIR}/src")
set(WSDL_DIR "${CMAKE_SOURCE_DIR}/wsdl")
set(GENERATED_DIR "${CMAKE_BINARY_DIR}/generated")
set(SOAP_SOURCES
${GSOAP_PLUGIN_DIR}/wsaapi.c
${GSOAP_PLUGIN_DIR}/wsddapi.c
${GENERATED_DIR}/soapClient.c
${GENERATED_DIR}/soapC.c
)
if(NOT USE_SYSTEM_GSOAP AND NOT USE_GSOAP_STATIC_LIB)
set(SOAP_SOURCES ${SOAP_SOURCES} ${GSOAP_DIR}/stdsoap2.c)
endif()
set(SOURCES
${COMMON_DIR}/${DAEMON_NAME}.c
${COMMON_DIR}/daemon.c
${COMMON_DIR}/net_utils.c
${COMMON_DIR}/file_utils.c
${COMMON_DIR}/wsdd_utils.c
${COMMON_DIR}/client_events.c
${SOAP_SOURCES}
)
set(SOAP_HEADERS
${GSOAP_INCLUDE_DIR}/stdsoap2.h
${GSOAP_PLUGIN_DIR}/wsaapi.h
${GSOAP_PLUGIN_DIR}/wsddapi.h
${GENERATED_DIR}/soapH.h
${GENERATED_DIR}/soapStub.h
${GENERATED_DIR}/wsdd.h
)
set(HEADERS
${COMMON_DIR}/smacros.h
${COMMON_DIR}/daemon.h
${COMMON_DIR}/net_utils.h
${COMMON_DIR}/file_utils.h
${COMMON_DIR}/wsdd_param.h
${GENERATED_DIR}/version.h
${SOAP_HEADERS}
)
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PUBLIC
${COMMON_DIR}
${GENERATED_DIR}
${GSOAP_INCLUDE_DIR}
${GSOAP_PLUGIN_DIR}
${GSOAP_IMPORT_DIR}
)
#Create a cmake target that generate gsoap files
add_custom_command(
OUTPUT ${GENERATED_DIR}/wsdd.h
COMMAND "${CMAKE_COMMAND}" -E make_directory ${GENERATED_DIR}
COMMAND ${GSOAP_WSDL2H} -cg -t ${GSOAP_WS_DIR}/typemap.dat
-o ${GENERATED_DIR}/wsdd.h ${WSDL_DIR}/remotediscovery.wsdl
COMMENT "Creating gSOAP binding file"
)
add_custom_command(
OUTPUT ${GENERATED_DIR}/soapC.c
COMMAND ${GSOAP_SOAPCPP2} -C -L -x -c -2 -d ${GENERATED_DIR}
-I${GSOAP_INCLUDE_DIR}:${GSOAP_IMPORT_DIR} ${GENERATED_DIR}/wsdd.h
DEPENDS ${GENERATED_DIR}/wsdd.h
COMMENT "Creating gSOAP stubs and glue code"
)
add_custom_target(gsoap_generation
DEPENDS ${GENERATED_DIR}/soapC.c
)
add_custom_target(generate_version ALL)
add_custom_command(
TARGET generate_version
COMMAND ${CMAKE_COMMAND}
-DWORK_DIR="${CMAKE_SOURCE_DIR}"
-DIN_FILE="${CMAKE_SOURCE_DIR}/cmake/version.h.in"
-DOUT_FILE="${GENERATED_DIR}/version.h"
-DDAEMON_MAJOR_VERSION=${DAEMON_MAJOR_VERSION}
-DDAEMON_MINOR_VERSION=${DAEMON_MINOR_VERSION}
-DDAEMON_PATCH_VERSION=${DAEMON_PATCH_VERSION}
-P "${CMAKE_SOURCE_DIR}/cmake/version.cmake"
DEPENDS ${SOURCES}
)
add_dependencies(${PROJECT_NAME} generate_version)
set_source_files_properties(
${GENERATED_DIR}/soapClient.c
${GENERATED_DIR}/soapC.c
${GENERATED_DIR}/soapH.h
${GENERATED_DIR}/soapStub.h
${GENERATED_DIR}/wsdd.h
${GENERATED_DIR}/version.h
PROPERTIES GENERATED TRUE
)
if(USE_SYSTEM_GSOAP OR USE_GSOAP_STATIC_LIB)
target_link_libraries(${PROJECT_NAME} ${GSOAP_C_LIBRARY})
endif()

@ -1,301 +0,0 @@
DAEMON_NAME = wsdd
DAEMON_MAJOR_VERSION = 3
DAEMON_MINOR_VERSION = 0
DAEMON_PATCH_VERSION = patch
#variants: hash - set PATCH_VERSION == commit hash (12 digits)
#variants: *hash - set PATCH_VERSION == * + commit hash (12 digits),
# * will be set if files in repo are changed
#variants: patch - set PATCH_VERSION == number of commits(patches) between head and last tag
#variants: xxx - set PATCH_VERSION == xxx (your variant)
DAEMON_PID_FILE_NAME = $(DAEMON_NAME).pid
DAEMON_LOG_FILE_NAME = $(DAEMON_NAME).log
DAEMON_NO_CHDIR = 1
DAEMON_NO_CLOSE_STDIO = 0
COMMIT_HASH = $(shell git rev-parse --short=12 HEAD 2>/dev/null)
ifeq ($(strip $(shell git status --short --untracked-files=no 2>/dev/null)),)
COMMIT_ISDIRTY = 0
else
COMMIT_ISDIRTY = 1
endif
# process PATCH_VERSION
ifeq ($(strip $(DAEMON_PATCH_VERSION)), *hash)
ifeq ($(strip $(COMMIT_ISDIRTY)), 0)
DAEMON_PATCH_VERSION = $(COMMIT_HASH)
else
DAEMON_PATCH_VERSION = *$(COMMIT_HASH)
endif
endif
ifeq ($(strip $(DAEMON_PATCH_VERSION)), hash)
DAEMON_PATCH_VERSION = $(COMMIT_HASH)
endif
ifeq ($(strip $(DAEMON_PATCH_VERSION)), patch)
LAST_TAG = $(shell git describe --tags --first-parent --abbrev=0 2>/dev/null)
DAEMON_PATCH_VERSION = $(shell git rev-list HEAD...$(LAST_TAG) --count 2>/dev/null)
endif
ifeq ($(strip $(DAEMON_PATCH_VERSION)),)
DAEMON_PATCH_VERSION = 0
endif
GSOAP_VERSION = 2.8.66
GSOAP_INSTALL_DIR = ./gsoap-2.8
GSOAP_DIR = $(GSOAP_INSTALL_DIR)/gsoap
GSOAP_PLUGIN_DIR = $(GSOAP_DIR)/plugin
GSOAP_IMPORT_DIR = $(GSOAP_DIR)/import
SOAPCPP2 = $(GSOAP_DIR)/src/soapcpp2
WSDL2H = $(GSOAP_DIR)/wsdl/wsdl2h
GSOAP_CONFIGURE = --disable-c-locale --disable-ssl
COMMON_DIR = ./src
GENERATED_DIR = ./generated
CFLAGS = -DDAEMON_NAME='"$(DAEMON_NAME)"'
CFLAGS += -DDAEMON_MAJOR_VERSION=$(DAEMON_MAJOR_VERSION)
CFLAGS += -DDAEMON_MINOR_VERSION=$(DAEMON_MINOR_VERSION)
CFLAGS += -DDAEMON_PATCH_VERSION=$(DAEMON_PATCH_VERSION)
CFLAGS += -DDAEMON_PID_FILE_NAME='"$(DAEMON_PID_FILE_NAME)"'
CFLAGS += -DDAEMON_LOG_FILE_NAME='"$(DAEMON_LOG_FILE_NAME)"'
CFLAGS += -DDAEMON_NO_CHDIR=$(DAEMON_NO_CHDIR)
CFLAGS += -DDAEMON_NO_CLOSE_STDIO=$(DAEMON_NO_CLOSE_STDIO)
CFLAGS += -DCOMMIT_ISDIRTY=$(COMMIT_ISDIRTY)
CFLAGS += -DCOMMIT_HASH='"$(COMMIT_HASH)"'
CFLAGS += -I$(COMMON_DIR)
CFLAGS += -I$(GENERATED_DIR)
CFLAGS += -I$(GSOAP_DIR) -I$(GSOAP_PLUGIN_DIR) -I$(GSOAP_IMPORT_DIR)
CFLAGS += -O2 -Wall -pipe
CC ?= gcc
SOAP_SRC = $(GSOAP_DIR)/stdsoap2.c \
$(GSOAP_PLUGIN_DIR)/wsaapi.c \
$(GSOAP_PLUGIN_DIR)/wsddapi.c \
$(GENERATED_DIR)/soapClient.c
# Add your source files to the list.
# Supported *.c *.cpp *.S files.
# For other file types write a template rule for build, see below.
SOURCES = $(COMMON_DIR)/$(DAEMON_NAME).c \
$(COMMON_DIR)/daemon.c \
$(COMMON_DIR)/net_utils.c \
$(COMMON_DIR)/file_utils.c \
$(COMMON_DIR)/wsdd_utils.c \
$(COMMON_DIR)/client_events.c \
$(GENERATED_DIR)/soapC.c \
$(SOAP_SRC)
OBJECTS := $(patsubst %.c, %.o, $(SOURCES) )
OBJECTS := $(patsubst %.cpp,%.o, $(OBJECTS) )
OBJECTS := $(patsubst %.S, %.o, $(OBJECTS) )
DEBUG_SUFFIX = debug
DEBUG_OBJECTS := $(patsubst %.o, %_$(DEBUG_SUFFIX).o, $(OBJECTS) )
.PHONY: all
all: debug release
.PHONY: release
release: CFLAGS := -s $(CFLAGS)
release: $(DAEMON_NAME)
.PHONY: debug
debug: DAEMON_NO_CLOSE_STDIO = 1
debug: CFLAGS := -DDEBUG -g $(CFLAGS)
debug: $(DAEMON_NAME)_$(DEBUG_SUFFIX)
# release
$(DAEMON_NAME): .depend $(OBJECTS)
$(call build_bin, $(OBJECTS))
# debug
$(DAEMON_NAME)_$(DEBUG_SUFFIX): .depend $(DEBUG_OBJECTS)
$(call build_bin, $(DEBUG_OBJECTS))
# Build release objects
%.o: %.c
$(build_object)
%.o: %.cpp
$(build_object)
%.o: %.S
$(build_object)
# Build debug objects
%_$(DEBUG_SUFFIX).o: %.c
$(build_object)
%_$(DEBUG_SUFFIX).o: %.cpp
$(build_object)
%_$(DEBUG_SUFFIX).o: %.S
$(build_object)
.PHONY: clean
clean:
-@rm -f $(DAEMON_NAME)
-@rm -f $(DAEMON_NAME)_$(DEBUG_SUFFIX)
-@rm -f $(OBJECTS)
-@rm -f $(DEBUG_OBJECTS)
-@rm -f .depend
-@rm -f -d -R $(GENERATED_DIR)
-@rm -f *.*~
.PHONY: distclean
distclean: clean
-@rm -f -d -R SDK
-@rm -f -d -R $(GSOAP_INSTALL_DIR)
-@rm -f RECV.log SENT.log TEST.log
.depend: $(GENERATED_DIR)/soapC.c
-@rm -f .depend
@echo "Generating dependencies..."
@for src in $(SOURCES) ; do \
echo " [depend] $$src" ; \
$(CC) $(CFLAGS) -MT ".depend $${src%.*}.o $${src%.*}_$(DEBUG_SUFFIX).o" -MM $$src >> .depend ; \
done
ifeq "$(findstring $(MAKECMDGOALS),clean distclean)" ""
include $(wildcard .depend)
endif
# ---- gSOAP ----
$(GENERATED_DIR)/wsdd.h:
@$(build_gsoap)
@mkdir -p $(GENERATED_DIR)
$(WSDL2H) -cg -t $(GSOAP_DIR)/WS/typemap.dat -o $@ wsdl/remotediscovery.wsdl
$(GENERATED_DIR)/soapC.c: $(GENERATED_DIR)/wsdd.h
$(SOAPCPP2) -C -L -x -c -2 -d $(GENERATED_DIR) -I$(GSOAP_DIR):$(GSOAP_IMPORT_DIR) $<
# This targets is needed for parallel work of make
$(OBJECTS) $(DEBUG_OBJECTS) $(SOAP_SRC): $(GENERATED_DIR)/soapC.c
# Common commands
BUILD_ECHO = echo "\n [build] $@:"
define build_object
@$(BUILD_ECHO)
$(CC) -c $< -o $@ $(CFLAGS)
endef
define build_bin
@$(BUILD_ECHO)
$(CC) $1 -o $@ $(CFLAGS)
@echo "\n---- Compiled $@ ver $(DAEMON_MAJOR_VERSION).$(DAEMON_MINOR_VERSION).$(DAEMON_PATCH_VERSION) ----\n"
endef
define build_gsoap
# get archive
if [ ! -f SDK/gsoap.zip ]; then \
mkdir -p SDK; \
wget -O ./SDK/gsoap.zip.tmp "https://github.com/SrcBackup/gsoap/releases/download/v2.8.x/gsoap_$(GSOAP_VERSION).zip" || \
wget -O ./SDK/gsoap.zip.tmp "https://sourceforge.net/projects/gsoap2/files/gsoap_$(GSOAP_VERSION).zip/download" && \
mv ./SDK/gsoap.zip.tmp ./SDK/gsoap.zip; \
fi
# unzip
if [ ! -f $(GSOAP_INSTALL_DIR)/README.txt ]; then \
unzip ./SDK/gsoap.zip; \
fi
#add patch
if [ ! -f $(GSOAP_INSTALL_DIR)/gsoap/src/soapcpp2_lex.l.patched ]; then \
patch $(GSOAP_INSTALL_DIR)/gsoap/src/soapcpp2_lex.l -i ./patch/soapcpp2_lex.l.patch -f; \
touch $(GSOAP_INSTALL_DIR)/gsoap/src/soapcpp2_lex.l.patched; \
fi
# build
if [ ! -f $(SOAPCPP2) ] || [ ! -f $(WSDL2H) ]; then \
cd $(GSOAP_INSTALL_DIR); \
./configure $(GSOAP_CONFIGURE) && \
make -j1; \
cd ..;\
fi
endef
.PHONY: help
help:
@echo "make [command]"
@echo "command is:"
@echo " all - build daemon in release and debug mode"
@echo " debug - build in debug mode (#define DEBUG 1)"
@echo " release - build in release mode (strip)"
@echo " clean - remove all generated files"
@echo " distclean - clean + remove all SDK files"
@echo " help - this help"

@ -3,7 +3,7 @@
## Description
wsdd is Linux daemon for ONVIF WS-Discovery service (server side).
**wsdd** is Linux daemon for ONVIF WS-Discovery service (server side).
ONVIF official website: [https://www.onvif.org](https://www.onvif.org)
and their [github presence](https://github.com/onvif/).
@ -13,6 +13,7 @@ The web services data binding is generated using [gSOAP](https://www.genivia.com
For more details about it see the [gSOAP WS-Discovery plugin official manual.](https://www.genivia.com/doc/wsdd/html/wsdd_0.html)
## Build
#### Dependencies
@ -21,28 +22,63 @@ Most Linux systems for building this project require the following packages to b
If you need support for encryption and WS-Security then you also need: `openssl zlib libcrypto`
For example, on ubuntu 20.04, you needed to install:
For example, on ubuntu 22.04, you needed to install:
```console
sudo apt install flex bison byacc make m4
sudo apt install flex bison byacc make cmake m4
#for support encryption and WS-Security
sudo apt install openssl libssl-dev zlib1g-dev libcrypto++6
sudo apt install openssl libssl-dev zlib1g-dev libcrypto++8
```
To start build you have to choose your compiler (or toolchain) in the [Makefile](./Makefile) (see variable `$CC`).
For build use make for [Makefile](./Makefile):
For build use cmake for [CMakeLists.txt](./CMakeLists.txt):
You have 4 build variants:
1. By default, the build takes place in the old style (when there was a `Makefile`)
We build our own version of `gSOAP` and use it (see [build_gsoap.cmake](./cmake/build_gsoap.cmake)).
At the same time, we compile the necessary `gSOAP` functions with the project.
```console
make target
cd repo_dir
cmake -B build .
cmake --build build
```
target is:
- `all` - build daemon in release and debug mode
- `debug` - build in debug mode (#define DEBUG 1)
- `release` - build in release mode (strip)
- `clean` - remove all generated files
- `distclean` - clean + remove all SDK files
- `help` - show list support targets
2. Analogue of the 1st, but we use the static library `gSOAP` (we link it)
```console
cd repo_dir
cmake -B build . -DUSE_GSOAP_STATIC_LIB=1
cmake --build build
```
3. We use the system `gSOAP`, for this we use the search module([FindgSOAP.cmake](./cmake/FindgSOAP.cmake)),
this module should find the `gSOAP` in the system that we will use.
```console
cd repo_dir
cmake -B build . -DUSE_SYSTEM_GSOAP=1
cmake --build build
```
For example, in Ubuntu 22.04, to install `gSOAP`, you need to install the following packages:
```console
sudo apt install gsoap libgsoap-dev
```
4. Analogue of the 3rd, but we tell the [FindgSOAP.cmake](./cmake/FindgSOAP.cmake) search module to look for static libraries instead of shared ones.
This will allow you not to depend on the `gSOAP` system libraries.
```console
cd repo_dir
cmake -B build . -DUSE_SYSTEM_GSOAP=1 -DUSE_GSOAP_STATIC_LIB=1
cmake --build build
```
@ -70,7 +106,6 @@ If You use systemd see:
## Testing
For testing daemon you need client application.
@ -91,5 +126,7 @@ For testing daemon you need client application.
[GPLv2](./LICENSE).
## Copyright
Copyright (C) 2016 Koynov Stas - skojnov@yandex.ru

@ -0,0 +1,210 @@
# SPDX-License-Identifier: MIT
#
# Copyright (C) Koynov Stas - skojnov@yandex.ru
#
#
# This module try find the system gsoap
#
# This code sets the following variables:
#
# GSOAP_VERSION = gSOAP version
#
# GSOAP_INCLUDE_DIR = Full path to the main gSOAP header stdsoap2.h
# GSOAP_CUSTOM_DIR = Full path to gSOAP custom serializers for various data types
# GSOAP_IMPORT_DIR = Full path to gSOAP import-ed header files for soapcpp2 compiler
# GSOAP_PLUGIN_DIR = Full path to gSOAP plug-ins for advanced features
# GSOAP_WS_DIR = Full path to gSOAP WS-typemap.dat and WS-* protocol schemas for plug-in development
#
# GSOAP_C_LIBRARY = Full path to libgsoap.a
# GSOAP_CK_C_LIBRARY = Full path to libgsoapck.a
# GSOAP_SSL_C_LIBRARY = Full path to libgsoapssl.a
# GSOAP_CXX_LIBRARY = Full path to libgsoap++.a
# GSOAP_CK_CXX_LIBRARY = Full path to libgsoapck++.a
# GSOAP_SSL_CXX_LIBRARY = Full path to libgsoapssl++.a
#
# GSOAP_WSDL2H = Full path to wsdl2h binary tool
# GSOAP_SOAPCPP2 = Full path to soapcpp2 binary tool
#
# GSOAP_FOUND = set to true if gsoap was found successfully
message(STATUS "Searching gSOAP")
find_path(GSOAP_INCLUDE_DIR
NAMES stdsoap2.h
HINTS ${GSOAP_DIR} ${GSOAP_DIR}/include ${GSOAP_DIR}/include/*
DOC "The main gSOAP header"
)
find_path(GSOAP_CUSTOM_DIR
NAMES chrono_duration.cpp
HINTS ${GSOAP_DIR}/custom /usr/share/gsoap/custom
DOC "gSOAP custom serializers for various data types"
)
find_path(GSOAP_IMPORT_DIR
NAMES wsa.h
HINTS ${GSOAP_DIR}/import /usr/share/gsoap/import
DOC "gSOAP import-ed header files for soapcpp2 compiler"
)
find_path(GSOAP_PLUGIN_DIR
NAMES wsaapi.h
HINTS ${GSOAP_DIR}/plugin /usr/share/gsoap/plugin
DOC "gSOAP plug-ins for advanced features"
)
find_path(GSOAP_WS_DIR
NAMES typemap.dat
HINTS ${GSOAP_DIR}/WS /usr/share/gsoap/WS
DOC "gSOAP WS-typemap.dat and WS-* protocol schemas for plug-in development"
)
# user want use only static library
if(DEFINED USE_GSOAP_STATIC_LIB)
set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()
# C Library
find_library(GSOAP_C_LIBRARY
NAMES gsoap
HINTS ${GSOAP_DIR} ${GSOAP_DIR}/lib ${GSOAP_DIR}/lib64
${GSOAP_DIR}/lib32
)
find_library(GSOAP_CK_C_LIBRARY
NAMES gsoapck
HINTS ${GSOAP_DIR} ${GSOAP_DIR}/lib ${GSOAP_DIR}/lib64
${GSOAP_DIR}/lib32
)
find_library(GSOAP_SSL_C_LIBRARY
NAMES gsoapssl
HINTS ${GSOAP_DIR} ${GSOAP_DIR}/lib ${GSOAP_DIR}/lib64
${GSOAP_DIR}/lib32
)
# C++ Library
find_library(GSOAP_CXX_LIBRARY
NAMES gsoap++
HINTS ${GSOAP_DIR} ${GSOAP_DIR}/lib ${GSOAP_DIR}/lib64
${GSOAP_DIR}/lib32
)
find_library(GSOAP_CK_CXX_LIBRARY
NAMES gsoapck++
HINTS ${GSOAP_DIR} ${GSOAP_DIR}/lib ${GSOAP_DIR}/lib64
${GSOAP_DIR}/lib32
)
find_library(GSOAP_SSL_CXX_LIBRARY
NAMES gsoapssl++
HINTS ${GSOAP_DIR} ${GSOAP_DIR}/lib ${GSOAP_DIR}/lib64
${GSOAP_DIR}/lib32
)
# restore old value for CMAKE_FIND_LIBRARY_SUFFIXES
if(DEFINED USE_GSOAP_STATIC_LIB)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_OLD})
unset(CMAKE_FIND_LIBRARY_SUFFIXES_OLD)
endif()
# gSOAP tools
find_program(GSOAP_WSDL2H
NAMES wsdl2h
HINTS ${GSOAP_DIR}/wsdl ${GSOAP_DIR}/bin
)
find_program(GSOAP_SOAPCPP2
NAMES soapcpp2
HINTS ${GSOAP_DIR}/src ${GSOAP_DIR}/bin
)
# Try get gSOAP version
execute_process(COMMAND ${GSOAP_SOAPCPP2} "-V"
OUTPUT_VARIABLE GSOAP_STRING_VERSION
ERROR_VARIABLE GSOAP_STRING_VERSION
)
string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" GSOAP_VERSION ${GSOAP_STRING_VERSION})
unset(GSOAP_STRING_VERSION)
# Show find results
message(STATUS "GSOAP_VERSION = ${GSOAP_VERSION}")
if(DEFINED GSOAP_DIR)
message(STATUS "GSOAP_DIR = ${GSOAP_DIR}")
endif()
message(STATUS "GSOAP_INCLUDE_DIR = ${GSOAP_INCLUDE_DIR}")
message(STATUS "GSOAP_CUSTOM_DIR = ${GSOAP_CUSTOM_DIR}")
message(STATUS "GSOAP_IMPORT_DIR = ${GSOAP_IMPORT_DIR}")
message(STATUS "GSOAP_PLUGIN_DIR = ${GSOAP_PLUGIN_DIR}")
message(STATUS "GSOAP_WS_DIR = ${GSOAP_WS_DIR}")
message(STATUS "GSOAP_C_LIBRARY = ${GSOAP_C_LIBRARY}")
message(STATUS "GSOAP_CK_C_LIBRARY = ${GSOAP_CK_C_LIBRARY}")
message(STATUS "GSOAP_SSL_C_LIBRARY = ${GSOAP_SSL_C_LIBRARY}")
message(STATUS "GSOAP_CXX_LIBRARY = ${GSOAP_CXX_LIBRARY}")
message(STATUS "GSOAP_CK_CXX_LIBRARY = ${GSOAP_CK_CXX_LIBRARY}")
message(STATUS "GSOAP_SSL_CXX_LIBRARY = ${GSOAP_SSL_CXX_LIBRARY}")
message(STATUS "GSOAP_SOAPCPP2 = ${GSOAP_SOAPCPP2}")
message(STATUS "GSOAP_WSDL2H = ${GSOAP_WSDL2H}")
# -----------------------------------------------------
# handle the QUIETLY and REQUIRED arguments and set GSOAP_FOUND to TRUE if
# all listed variables are TRUE
# -----------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(gSOAP DEFAULT_MSG
GSOAP_C_LIBRARY
GSOAP_SSL_C_LIBRARY
GSOAP_CXX_LIBRARY
GSOAP_SSL_CXX_LIBRARY
GSOAP_INCLUDE_DIR
GSOAP_CUSTOM_DIR
GSOAP_IMPORT_DIR
GSOAP_PLUGIN_DIR
GSOAP_SOAPCPP2
GSOAP_WSDL2H
)
mark_as_advanced(
GSOAP_C_LIBRARY
GSOAP_CK_C_LIBRARY
GSOAP_SSL_C_LIBRARY
GSOAP_CXX_LIBRARY
GSOAP_CK_CXX_LIBRARY
GSOAP_SSL_CXX_LIBRARY
GSOAP_INCLUDE_DIR
GSOAP_CUSTOM_DIR
GSOAP_IMPORT_DIR
GSOAP_PLUGIN_DIR
GSOAP_SOAPCPP2
GSOAP_WSDL2H
)

@ -0,0 +1,109 @@
cmake_minimum_required(VERSION 3.15)
function(get_commit_isdirty)
execute_process(COMMAND
"${GIT_EXECUTABLE}" status --short --untracked-files=no
WORKING_DIRECTORY "${WORK_DIR}"
OUTPUT_VARIABLE COMMIT_ISDIRTY_OUT
RESULT_VARIABLE exit_code
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(exit_code EQUAL 0 AND "${COMMIT_ISDIRTY_OUT}" STREQUAL "")
set(COMMIT_ISDIRTY 0 PARENT_SCOPE)
else()
set(COMMIT_ISDIRTY 1 PARENT_SCOPE)
endif()
endfunction()
function(get_commit_hash)
execute_process(COMMAND
"${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
WORKING_DIRECTORY "${WORK_DIR}"
OUTPUT_VARIABLE COMMIT_HASH_VAR
RESULT_VARIABLE exit_code
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(exit_code EQUAL 0)
set(COMMIT_HASH ${COMMIT_HASH_VAR} PARENT_SCOPE)
else()
set(COMMIT_HASH unknown PARENT_SCOPE)
endif()
endfunction()
function(get_patch_version)
if(${DAEMON_PATCH_VERSION} STREQUAL patch)
execute_process(COMMAND
"${GIT_EXECUTABLE}" describe --tags --first-parent --abbrev=0
WORKING_DIRECTORY "${WORK_DIR}"
OUTPUT_VARIABLE LAST_TAG
RESULT_VARIABLE exit_code
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(exit_code EQUAL 0)
set(GET_PATCH_VERSION_CMD ${GIT_EXECUTABLE} rev-list HEAD...${LAST_TAG} --count)
else()
set(GET_PATCH_VERSION_CMD ${GIT_EXECUTABLE} rev-list HEAD --count)
endif()
execute_process(COMMAND
${GET_PATCH_VERSION_CMD}
WORKING_DIRECTORY "${WORK_DIR}"
OUTPUT_VARIABLE NUMBER_PATCH
RESULT_VARIABLE exit_code
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(exit_code EQUAL 0)
set(DAEMON_PATCH_VERSION ${NUMBER_PATCH} PARENT_SCOPE)
else()
set(DAEMON_PATCH_VERSION 0 PARENT_SCOPE)
endif()
endif()
endfunction()
find_package(Git QUIET)
if(Git_FOUND)
get_commit_isdirty()
get_commit_hash()
get_patch_version()
else()
message(WARNING "Git not found, it is impossible to get the hash and patch version (they will be set to zero)")
if(${DAEMON_PATCH_VERSION} STREQUAL patch)
set(DAEMON_PATCH_VERSION 0)
endif()
set(COMMIT_ISDIRTY 1)
set(COMMIT_HASH unknown)
endif()
configure_file(${IN_FILE} ${OUT_FILE} @ONLY)

@ -0,0 +1,15 @@
#ifndef VERSION_HEADER
#define VERSION_HEADER
#define DAEMON_MAJOR_VERSION @DAEMON_MAJOR_VERSION@
#define DAEMON_MINOR_VERSION @DAEMON_MINOR_VERSION@
#define DAEMON_PATCH_VERSION @DAEMON_PATCH_VERSION@
#define COMMIT_HASH "@COMMIT_HASH@"
#define COMMIT_ISDIRTY @COMMIT_ISDIRTY@
#endif //VERSION_HEADER

@ -44,7 +44,7 @@
#include <stddef.h> //for NULL
#include <version.h>

@ -32,7 +32,6 @@
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@ -49,7 +48,6 @@
#include "net_utils.h"
#include "smacros.h"
// gsoap headers
#include "wsdd.nsmap"
#include "wsddapi.h"

Loading…
Cancel
Save