|
@@ -43,9 +43,9 @@ if(NOT ${OPEN62541_VER_COMMIT} OR ${OPEN62541_VER_COMMIT} STREQUAL "")
|
|
|
set(OPEN62541_VER_COMMIT "undefined")
|
|
|
endif()
|
|
|
|
|
|
-############
|
|
|
-# Settings #
|
|
|
-############
|
|
|
+#################
|
|
|
+# Build Options #
|
|
|
+#################
|
|
|
|
|
|
# Set default build type.
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
@@ -136,7 +136,28 @@ mark_as_advanced(UA_COMPILE_AS_CXX)
|
|
|
# Compiler Settings #
|
|
|
#####################
|
|
|
|
|
|
-list(APPEND open62541_LIBRARIES "") # Collect libraries
|
|
|
+# Collect libraries
|
|
|
+list(APPEND open62541_LIBRARIES "")
|
|
|
+if(NOT WIN32)
|
|
|
+ if(QNXNTO)
|
|
|
+ list(APPEND open62541_LIBRARIES socket)
|
|
|
+ list(APPEND open62541_LIBRARIES c)
|
|
|
+ list(APPEND open62541_LIBRARIES stdc++)
|
|
|
+ else()
|
|
|
+ list(APPEND open62541_LIBRARIES pthread m)
|
|
|
+ if(NOT APPLE)
|
|
|
+ list(APPEND open62541_LIBRARIES rt)
|
|
|
+ endif()
|
|
|
+ endif()
|
|
|
+else()
|
|
|
+ list(APPEND open62541_LIBRARIES ws2_32)
|
|
|
+ if(UA_ENABLE_DISCOVERY_MULTICAST)
|
|
|
+ list(APPEND open62541_LIBRARIES iphlpapi)
|
|
|
+ endif()
|
|
|
+endif()
|
|
|
+if(UA_ENABLE_MULTITHREADING)
|
|
|
+ list(APPEND open62541_LIBRARIES urcu-cds urcu urcu-common)
|
|
|
+endif(UA_ENABLE_MULTITHREADING)
|
|
|
|
|
|
if(NOT UA_COMPILE_AS_CXX AND (CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang"))
|
|
|
# Compiler
|
|
@@ -203,6 +224,7 @@ if (UA_ENABLE_DISCOVERY_MULTICAST)
|
|
|
endif()
|
|
|
include_directories(${PROJECT_BINARY_DIR}/src_generated
|
|
|
${PROJECT_SOURCE_DIR}/include
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins # TODO: discovery depends on the standard config
|
|
|
${PROJECT_SOURCE_DIR}/deps)
|
|
|
|
|
|
set(exported_headers ${PROJECT_BINARY_DIR}/src_generated/ua_config.h
|
|
@@ -221,8 +243,8 @@ set(exported_headers ${PROJECT_BINARY_DIR}/src_generated/ua_config.h
|
|
|
${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.h
|
|
|
${PROJECT_SOURCE_DIR}/plugins/ua_accesscontrol_default.h
|
|
|
${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.h
|
|
|
- ${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.h
|
|
|
-)
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.h)
|
|
|
+
|
|
|
set(internal_headers ${PROJECT_SOURCE_DIR}/deps/queue.h
|
|
|
${PROJECT_SOURCE_DIR}/deps/pcg_basic.h
|
|
|
${PROJECT_SOURCE_DIR}/deps/libc_time.h
|
|
@@ -243,8 +265,9 @@ set(internal_headers ${PROJECT_SOURCE_DIR}/deps/queue.h
|
|
|
${PROJECT_SOURCE_DIR}/src/server/ua_securechannel_manager.h
|
|
|
${PROJECT_SOURCE_DIR}/src/server/ua_server_internal.h
|
|
|
${PROJECT_SOURCE_DIR}/src/server/ua_services.h
|
|
|
- ${PROJECT_SOURCE_DIR}/src/client/ua_client_internal.h
|
|
|
-)
|
|
|
+ ${PROJECT_SOURCE_DIR}/src/client/ua_client_internal.h)
|
|
|
+
|
|
|
+# TODO: make client optional
|
|
|
set(lib_sources ${PROJECT_SOURCE_DIR}/src/ua_types.c
|
|
|
${PROJECT_SOURCE_DIR}/src/ua_types_encoding_binary.c
|
|
|
${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
|
|
@@ -284,17 +307,15 @@ set(lib_sources ${PROJECT_SOURCE_DIR}/src/ua_types.c
|
|
|
${PROJECT_SOURCE_DIR}/src/client/ua_client_discovery.c
|
|
|
${PROJECT_SOURCE_DIR}/src/client/ua_client_highlevel.c
|
|
|
${PROJECT_SOURCE_DIR}/src/client/ua_client_highlevel_subscriptions.c
|
|
|
- # plugins and dependencies
|
|
|
- ${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.c
|
|
|
- ${PROJECT_SOURCE_DIR}/plugins/ua_accesscontrol_default.c
|
|
|
- ${PROJECT_SOURCE_DIR}/plugins/ua_clock.c
|
|
|
- ${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.c
|
|
|
- ${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.c
|
|
|
+ # dependencies
|
|
|
${PROJECT_SOURCE_DIR}/deps/libc_time.c
|
|
|
- ${PROJECT_SOURCE_DIR}/deps/pcg_basic.c
|
|
|
-)
|
|
|
- ##TODO: make client stuff optional
|
|
|
+ ${PROJECT_SOURCE_DIR}/deps/pcg_basic.c)
|
|
|
|
|
|
+set(default_plugin_sources ${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.c
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins/ua_clock.c
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.c
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins/ua_accesscontrol_default.c
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.c)
|
|
|
if(UA_ENABLE_EMBEDDED_LIBC)
|
|
|
list(APPEND lib_sources ${PROJECT_SOURCE_DIR}/deps/libc_string.c)
|
|
|
endif()
|
|
@@ -394,17 +415,17 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.h
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
|
|
|
${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.h ${exported_headers}
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
|
|
|
- ${exported_headers}
|
|
|
- ${internal_headers})
|
|
|
+ ${exported_headers} ${internal_headers})
|
|
|
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
|
|
|
PRE_BUILD
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
|
|
|
- ${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c ${internal_headers} ${lib_sources}
|
|
|
+ ${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c
|
|
|
+ ${internal_headers} ${lib_sources} ${default_plugin_sources}
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py ${internal_headers} ${lib_sources})
|
|
|
|
|
|
ADD_CUSTOM_TARGET(open62541_amalgamation DEPENDS ${PROJECT_BINARY_DIR}/open62541.h
|
|
|
- ${PROJECT_BINARY_DIR}/open62541.c)
|
|
|
+ ${PROJECT_BINARY_DIR}/open62541.c)
|
|
|
|
|
|
# example information model from nodeset xml
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/nodeset.h ${PROJECT_BINARY_DIR}/src_generated/nodeset.c
|
|
@@ -433,46 +454,52 @@ assign_source_group(${exported_headers})
|
|
|
|
|
|
if(UA_ENABLE_AMALGAMATION)
|
|
|
add_library(open62541-object OBJECT ${PROJECT_BINARY_DIR}/open62541.c ${PROJECT_BINARY_DIR}/open62541.h)
|
|
|
+ target_include_directories(open62541-object PRIVATE ${PROJECT_BINARY_DIR})
|
|
|
|
|
|
# make sure the open62541_amalgamation target builds before so that amalgamation is finished and it is not executed again for open62541-object
|
|
|
# and thus may overwrite the amalgamation result during multiprocessor compilation
|
|
|
add_dependencies(open62541-object open62541_amalgamation)
|
|
|
|
|
|
- target_include_directories(open62541-object PRIVATE ${PROJECT_BINARY_DIR})
|
|
|
+ add_library(open62541 $<TARGET_OBJECTS:open62541-object>)
|
|
|
+
|
|
|
if(UA_COMPILE_AS_CXX)
|
|
|
set_source_files_properties(${PROJECT_BINARY_DIR}/open62541.c PROPERTIES LANGUAGE CXX)
|
|
|
endif()
|
|
|
else()
|
|
|
add_definitions(-DUA_NO_AMALGAMATION)
|
|
|
add_library(open62541-object OBJECT ${lib_sources} ${internal_headers} ${exported_headers})
|
|
|
- target_include_directories(open62541-object PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/plugins)
|
|
|
+ target_include_directories(open62541-object PRIVATE ${PROJECT_SOURCE_DIR}/src)
|
|
|
+
|
|
|
+ add_library(open62541-plugins OBJECT ${default_plugin_sources} ${exported_headers})
|
|
|
+ target_include_directories(open62541-plugins PRIVATE ${PROJECT_SOURCE_DIR}/plugins)
|
|
|
+ target_include_directories(open62541-plugins PRIVATE ${PROJECT_BINARY_DIR}/src_generated)
|
|
|
+ target_compile_definitions(open62541-plugins PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
|
|
|
+
|
|
|
+ add_library(open62541 $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
|
|
|
|
|
|
if(UA_COMPILE_AS_CXX)
|
|
|
set_source_files_properties(${lib_sources} PROPERTIES LANGUAGE CXX)
|
|
|
+ set_source_files_properties(${default_plugin_sources} PROPERTIES LANGUAGE CXX)
|
|
|
endif()
|
|
|
endif()
|
|
|
-add_library(open62541 $<TARGET_OBJECTS:open62541-object>)
|
|
|
-target_link_libraries(open62541 ${open62541_LIBRARIES})
|
|
|
|
|
|
+# Export Symbols
|
|
|
target_compile_definitions(open62541-object PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
|
|
|
target_compile_definitions(open62541 PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
|
|
|
-
|
|
|
if (UA_ENABLE_DISCOVERY_MULTICAST)
|
|
|
target_compile_definitions(open62541-object PRIVATE -DMDNSD_DYNAMIC_LINKING_EXPORT)
|
|
|
target_compile_definitions(open62541 PRIVATE -DMDNSD_DYNAMIC_LINKING_EXPORT)
|
|
|
endif()
|
|
|
|
|
|
+# DLL requires linking to dependencies
|
|
|
+target_link_libraries(open62541 ${open62541_LIBRARIES})
|
|
|
+
|
|
|
+# Always generate the amalgamated header
|
|
|
+add_dependencies(open62541 open62541_amalgamation)
|
|
|
+
|
|
|
# Generate properly versioned shared library links on Linux
|
|
|
SET_TARGET_PROPERTIES(open62541 PROPERTIES SOVERSION 0 VERSION "${OPEN62541_VER_MAJOR}.${OPEN62541_VER_MINOR}.${OPEN62541_VER_PATCH}")
|
|
|
|
|
|
-if(WIN32)
|
|
|
- target_link_libraries(open62541 ws2_32)
|
|
|
- if (UA_ENABLE_DISCOVERY_MULTICAST)
|
|
|
- target_link_libraries(open62541 iphlpapi) # for GetAdaptersAddresses
|
|
|
- list(APPEND open62541_LIBRARIES iphlpapi)
|
|
|
- endif()
|
|
|
-endif()
|
|
|
-
|
|
|
##########################
|
|
|
# Build Selected Targets #
|
|
|
##########################
|
|
@@ -485,7 +512,10 @@ if(UA_BUILD_EXAMPLES)
|
|
|
endif()
|
|
|
|
|
|
if(UA_BUILD_UNIT_TESTS)
|
|
|
- target_compile_definitions(open62541-object PRIVATE UA_BUILD_UNIT_TESTS) # Export some internal functions
|
|
|
+ if(UA_ENABLE_AMALGAMATION)
|
|
|
+ # Cannot compile tests with amalgamation. Amalgamation uses the default plugins, not the testing plugins
|
|
|
+ message(FATAL_ERROR "Unit tests cannot be generated with source amalgamation enabled")
|
|
|
+ endif()
|
|
|
enable_testing()
|
|
|
add_subdirectory(tests)
|
|
|
endif()
|