CMakeLists.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. cmake_minimum_required(VERSION 2.8.11)
  2. project(open62541 C)
  3. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake")
  4. # set(CMAKE_VERBOSE_MAKEFILE ON)
  5. ######################
  6. # Check Dependencies #
  7. ######################
  8. find_package(PythonInterp REQUIRED)
  9. find_package(Git)
  10. if(GIT_FOUND)
  11. execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=7 --dirty --always --tags
  12. RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COM_ID WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
  13. if(NOT ${res_var} EQUAL 0)
  14. set(GIT_COMMIT_ID "unknown--git-commit-id-unknown")
  15. message(STATUS "Git failed (not a repo, or no tags). Build will not contain git revision info." )
  16. else()
  17. string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COM_ID} )
  18. endif()
  19. else()
  20. set(GIT_COMMIT_ID "unknown--no-git-found")
  21. message(STATUS "Git not found. Build will not contain git revision info." )
  22. endif()
  23. message(STATUS "Git version: " ${GIT_COMMIT_ID})
  24. ############
  25. # Settings #
  26. ############
  27. # Set default build type.
  28. if(NOT CMAKE_BUILD_TYPE)
  29. message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'Debug'")
  30. set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
  31. endif()
  32. # Options
  33. set(UA_LOGLEVEL 300 CACHE STRING "Level at which logs shall be reported")
  34. option(UA_ENABLE_METHODCALLS "Enable the Method service set" ON)
  35. option(UA_ENABLE_NODEMANAGEMENT "Enable dynamic addition and removal of nodes at runtime" ON)
  36. option(UA_ENABLE_SUBSCRIPTIONS "Enable subscriptions support." ON)
  37. option(UA_ENABLE_MULTITHREADING "Enable multithreading" OFF)
  38. option(UA_ENABLE_AMALGAMATION "Concatenate the library to a single file open62541.h/.c" OFF)
  39. option(UA_ENABLE_COVERAGE "Enable gcov coverage" OFF)
  40. option(BUILD_SHARED_LIBS "Enable building of shared libraries (dll/so)" OFF)
  41. if(UA_ENABLE_COVERAGE)
  42. set(CMAKE_BUILD_TYPE DEBUG)
  43. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
  44. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
  45. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
  46. endif()
  47. # Advanced options
  48. option(UA_ENABLE_TYPENAMES "Add the type and member names to the UA_DataType structure" OFF)
  49. mark_as_advanced(UA_ENABLE_TYPENAMES)
  50. option(UA_ENABLE_EMBEDDED_LIBC "Use a custom implementation of some libc functions that might be missing on embedded targets (e.g. string handling)." OFF)
  51. mark_as_advanced(UA_ENABLE_EMBEDDED_LIBC)
  52. option(UA_ENABLE_GENERATE_NAMESPACE0 "Generate and load UA XML Namespace 0 definition (experimental)" OFF)
  53. mark_as_advanced(UA_ENABLE_GENERATE_NAMESPACE0)
  54. option(UA_ENABLE_EXTERNAL_NAMESPACES "Enable namespace handling by an external component (experimental)" OFF)
  55. mark_as_advanced(UA_ENABLE_EXTERNAL_NAMESPACES)
  56. option(UA_ENABLE_NONSTANDARD_STATELESS "Enable stateless extension" OFF)
  57. mark_as_advanced(UA_ENABLE_NONSTANDARD_STATELESS)
  58. option(UA_ENABLE_NONSTANDARD_UDP "Enable udp extension" OFF)
  59. mark_as_advanced(UA_ENABLE_NONSTANDARD_UDP)
  60. if(UA_ENABLE_NONSTANDARD_UDP)
  61. set(UA_ENABLE_NONSTANDARD_STATELESS ON)
  62. endif()
  63. # Build Targets
  64. option(UA_BUILD_EXAMPLES "Build example servers and clients" OFF)
  65. option(UA_BUILD_UNIT_TESTS "Build the unit tests" OFF)
  66. option(UA_BUILD_DOCUMENTATION "Generate doxygen/sphinx documentation" OFF)
  67. option(UA_BUILD_EXAMPLES_NODESET_COMPILER "Generate an OPC UA information model from a nodeset XML (experimental)" OFF)
  68. # Advanced Build Targets
  69. option(UA_BUILD_SELFSIGNED_CERTIFICATE "Generate self-signed certificate" OFF)
  70. # Building shared libs (dll, so). This option is written into ua_config.h.
  71. set(UA_DYNAMIC_LINKING OFF)
  72. if(BUILD_SHARED_LIBS)
  73. set(UA_DYNAMIC_LINKING ON)
  74. endif()
  75. #####################
  76. # Compiler Settings #
  77. #####################
  78. list(APPEND open62541_LIBRARIES "") # Collect libraries
  79. if(CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")
  80. # Compiler
  81. add_definitions(-std=c99 -pipe -Wall -Wextra -Werror -Wformat -Wno-unused-parameter
  82. -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare
  83. -Wmultichar -Wstrict-overflow -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes
  84. -Winit-self -Wuninitialized -Wformat-security -Wformat-nonliteral)
  85. if(NOT WIN32 AND NOT CYGWIN)
  86. add_definitions(-Wshadow -Wconversion -fvisibility=hidden -fPIC)
  87. endif()
  88. # Linker
  89. set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
  90. # Debug
  91. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  92. # add_definitions(-fsanitize=address)
  93. # list(APPEND open62541_LIBRARIES asan)
  94. # add_definitions(-fsanitize=undefined)
  95. # list(APPEND open62541_LIBRARIES ubsan)
  96. endif()
  97. # Strip release builds
  98. if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" OR CMAKE_BUILD_TYPE STREQUAL "Release")
  99. add_definitions(-ffunction-sections -fdata-sections -fno-stack-protector -fno-unwind-tables
  100. -fno-asynchronous-unwind-tables -fno-math-errno -fmerge-all-constants -fno-ident)
  101. set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s")
  102. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s")
  103. if(APPLE)
  104. set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-dead_strip")
  105. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
  106. else()
  107. set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--gc-sections")
  108. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
  109. endif()
  110. if(NOT WIN32 AND NOT CYGWIN AND NOT APPLE)
  111. # these settings reduce the binary size by ~2kb
  112. set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none")
  113. endif()
  114. endif()
  115. endif()
  116. if(APPLE)
  117. set(CMAKE_MACOSX_RPATH 1)
  118. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DARWIN_C_SOURCE=1")
  119. endif()
  120. if(MSVC)
  121. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /WX") # Compiler warnings, error on warning
  122. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
  123. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
  124. endif()
  125. #########################
  126. # Generate Main Library #
  127. #########################
  128. file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
  129. configure_file("include/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
  130. include_directories(${PROJECT_BINARY_DIR}/src_generated)
  131. set(exported_headers ${PROJECT_BINARY_DIR}/src_generated/ua_config.h
  132. ${PROJECT_SOURCE_DIR}/include/ua_constants.h
  133. ${PROJECT_SOURCE_DIR}/include/ua_types.h
  134. ${PROJECT_BINARY_DIR}/src_generated/ua_nodeids.h
  135. ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h
  136. ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated_handling.h
  137. ${PROJECT_SOURCE_DIR}/include/ua_connection.h
  138. ${PROJECT_SOURCE_DIR}/include/ua_job.h
  139. ${PROJECT_SOURCE_DIR}/include/ua_log.h
  140. ${PROJECT_SOURCE_DIR}/include/ua_server.h
  141. ${PROJECT_SOURCE_DIR}/include/ua_server_external_ns.h
  142. ${PROJECT_SOURCE_DIR}/include/ua_client.h
  143. ${PROJECT_SOURCE_DIR}/include/ua_client_highlevel.h
  144. ${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.h
  145. ${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.h
  146. ${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.h)
  147. set(internal_headers ${PROJECT_SOURCE_DIR}/deps/queue.h
  148. ${PROJECT_SOURCE_DIR}/deps/pcg_basic.h
  149. ${PROJECT_SOURCE_DIR}/deps/libc_time.h
  150. ${PROJECT_SOURCE_DIR}/src/ua_util.h
  151. ${PROJECT_SOURCE_DIR}/src/ua_types_encoding_binary.h
  152. ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated_encoding_binary.h
  153. ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.h
  154. ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated_handling.h
  155. ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated_encoding_binary.h
  156. ${PROJECT_SOURCE_DIR}/src/ua_connection_internal.h
  157. ${PROJECT_SOURCE_DIR}/src/ua_securechannel.h
  158. ${PROJECT_SOURCE_DIR}/src/server/ua_nodes.h
  159. ${PROJECT_SOURCE_DIR}/src/ua_session.h
  160. ${PROJECT_SOURCE_DIR}/src/server/ua_subscription.h
  161. ${PROJECT_SOURCE_DIR}/src/server/ua_nodestore.h
  162. ${PROJECT_SOURCE_DIR}/src/server/ua_session_manager.h
  163. ${PROJECT_SOURCE_DIR}/src/server/ua_securechannel_manager.h
  164. ${PROJECT_SOURCE_DIR}/src/server/ua_server_internal.h
  165. ${PROJECT_SOURCE_DIR}/src/server/ua_services.h
  166. ${PROJECT_SOURCE_DIR}/src/client/ua_client_internal.h)
  167. set(lib_sources ${PROJECT_SOURCE_DIR}/src/ua_types.c
  168. ${PROJECT_SOURCE_DIR}/src/ua_types_encoding_binary.c
  169. ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
  170. ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
  171. ${PROJECT_SOURCE_DIR}/src/ua_connection.c
  172. ${PROJECT_SOURCE_DIR}/src/ua_securechannel.c
  173. ${PROJECT_SOURCE_DIR}/src/ua_session.c
  174. ${PROJECT_SOURCE_DIR}/src/server/ua_server.c
  175. ${PROJECT_SOURCE_DIR}/src/server/ua_server_binary.c
  176. ${PROJECT_SOURCE_DIR}/src/server/ua_nodes.c
  177. ${PROJECT_SOURCE_DIR}/src/server/ua_server_worker.c
  178. ${PROJECT_SOURCE_DIR}/src/server/ua_securechannel_manager.c
  179. ${PROJECT_SOURCE_DIR}/src/server/ua_session_manager.c
  180. ${PROJECT_SOURCE_DIR}/src/server/ua_services_discovery.c
  181. ${PROJECT_SOURCE_DIR}/src/server/ua_services_securechannel.c
  182. ${PROJECT_SOURCE_DIR}/src/server/ua_services_session.c
  183. ${PROJECT_SOURCE_DIR}/src/server/ua_services_attribute.c
  184. ${PROJECT_SOURCE_DIR}/src/server/ua_services_nodemanagement.c
  185. ${PROJECT_SOURCE_DIR}/src/server/ua_services_view.c
  186. ${PROJECT_SOURCE_DIR}/src/client/ua_client.c
  187. ${PROJECT_SOURCE_DIR}/src/client/ua_client_highlevel.c
  188. # nodestores
  189. ${PROJECT_SOURCE_DIR}/src/server/ua_nodestore.c
  190. ${PROJECT_SOURCE_DIR}/src/server/ua_nodestore_concurrent.c
  191. # method call
  192. ${PROJECT_SOURCE_DIR}/src/server/ua_services_call.c
  193. # subscriptions
  194. ${PROJECT_SOURCE_DIR}/src/server/ua_subscription.c
  195. ${PROJECT_SOURCE_DIR}/src/server/ua_services_subscription.c
  196. ${PROJECT_SOURCE_DIR}/src/client/ua_client_highlevel_subscriptions.c
  197. # plugins and dependencies
  198. ${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.c
  199. ${PROJECT_SOURCE_DIR}/plugins/ua_clock.c
  200. ${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.c
  201. ${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.c
  202. ${PROJECT_SOURCE_DIR}/deps/libc_time.c
  203. ${PROJECT_SOURCE_DIR}/deps/pcg_basic.c)
  204. ##TODO: make client stuff optional
  205. if(UA_ENABLE_EMBEDDED_LIBC)
  206. list(APPEND lib_sources ${PROJECT_SOURCE_DIR}/deps/libc_string.c)
  207. endif()
  208. if(UA_ENABLE_GENERATE_NAMESPACE0)
  209. set(GENERATE_NAMESPACE0_FILE "Opc.Ua.NodeSet2.xml" CACHE STRING "Namespace definition XML file")
  210. set_property(CACHE GENERATE_NAMESPACE0_FILE PROPERTY STRINGS Opc.Ua.NodeSet2.xml Opc.Ua.NodeSet2.Minimal.xml)
  211. list(APPEND internal_headers ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.h)
  212. list(APPEND lib_sources ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.c)
  213. endif()
  214. #########################
  215. # Generate source files #
  216. #########################
  217. # standard data types
  218. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
  219. ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h
  220. ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated_handling.h
  221. ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated_encoding_binary.h
  222. PRE_BUILD
  223. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  224. --typedescriptions ${PROJECT_SOURCE_DIR}/tools/schema/NodeIds.csv
  225. --selected_types=${PROJECT_SOURCE_DIR}/tools/schema/datatypes_minimal.txt
  226. ${PROJECT_SOURCE_DIR}/tools/schema/Opc.Ua.Types.bsd ${PROJECT_BINARY_DIR}/src_generated/ua_types
  227. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_datatypes.py
  228. ${PROJECT_SOURCE_DIR}/tools/schema/datatypes_minimal.txt
  229. ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/Opc.Ua.Types.bsd
  230. ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/NodeIds.csv)
  231. # transport data types
  232. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
  233. ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.h
  234. ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated_handling.h
  235. ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated_encoding_binary.h
  236. PRE_BUILD
  237. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  238. --namespace=1 --selected_types=${PROJECT_SOURCE_DIR}/tools/schema/datatypes_transport.txt
  239. ${PROJECT_SOURCE_DIR}/tools/schema/Opc.Ua.Types.bsd
  240. ${PROJECT_SOURCE_DIR}/tools/schema/Custom.Opc.Ua.Transport.bsd
  241. ${PROJECT_BINARY_DIR}/src_generated/ua_transport
  242. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_datatypes.py
  243. ${PROJECT_SOURCE_DIR}/tools/schema/datatypes_transport.txt
  244. ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/Custom.Opc.Ua.Transport.bsd)
  245. # nodeids
  246. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_nodeids.h
  247. PRE_BUILD
  248. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_nodeids.py
  249. ${PROJECT_SOURCE_DIR}/tools/schema/NodeIds.csv ${PROJECT_BINARY_DIR}/src_generated/ua_nodeids
  250. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_nodeids.py
  251. ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/NodeIds.csv)
  252. # generated namespace 0
  253. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.c
  254. ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.h
  255. PRE_BUILD
  256. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
  257. -i ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_AssumeExternal.txt
  258. -s description -b ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_Blacklist.txt
  259. ${PROJECT_SOURCE_DIR}/tools/schema/namespace0/${GENERATE_NAMESPACE0_FILE}
  260. ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated
  261. DEPENDS ${PROJECT_SOURCE_DIR}/tools/schema/namespace0/${GENERATE_NAMESPACE0_FILE}
  262. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
  263. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/open62541_MacroHelper.py
  264. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_builtin_types.py
  265. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_constants.py
  266. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_namespace.py
  267. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_node_types.py)
  268. # single-file release
  269. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.h
  270. PRE_BUILD
  271. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
  272. ${GIT_COMMIT_ID} ${CMAKE_CURRENT_BINARY_DIR}/open62541.h ${exported_headers}
  273. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
  274. ${exported_headers}
  275. ${internal_headers})
  276. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
  277. PRE_BUILD
  278. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
  279. ${GIT_COMMIT_ID} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c ${internal_headers}
  280. ${PROJECT_SOURCE_DIR}/src/server/ua_nodestore_hash.inc ${lib_sources}
  281. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py ${internal_headers}
  282. ${PROJECT_SOURCE_DIR}/src/server/ua_nodestore_hash.inc ${lib_sources})
  283. # example information model from nodeset xml
  284. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/nodeset.h ${PROJECT_BINARY_DIR}/src_generated/nodeset.c
  285. PRE_BUILD
  286. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
  287. -i ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_Blacklist_FullNS0.txt
  288. ${PROJECT_SOURCE_DIR}/tools/schema/namespace0/Opc.Ua.NodeSet2.xml
  289. ${PROJECT_SOURCE_DIR}/examples/server_nodeset.xml
  290. ${PROJECT_BINARY_DIR}/src_generated/nodeset
  291. DEPENDS ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
  292. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/open62541_MacroHelper.py
  293. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_builtin_types.py
  294. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_constants.py
  295. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_namespace.py
  296. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_node_types.py
  297. ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_Blacklist_FullNS0.txt
  298. ${PROJECT_SOURCE_DIR}/examples/server_nodeset.xml)
  299. #####################
  300. # Build the Library #
  301. #####################
  302. if(UA_ENABLE_AMALGAMATION)
  303. add_library(open62541-object OBJECT ${PROJECT_BINARY_DIR}/open62541.c ${PROJECT_BINARY_DIR}/open62541.h)
  304. target_include_directories(open62541-object PRIVATE ${PROJECT_BINARY_DIR})
  305. else()
  306. add_library(open62541-object OBJECT ${lib_sources} ${internal_headers} ${exported_headers})
  307. target_include_directories(open62541-object PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src
  308. ${PROJECT_SOURCE_DIR}/plugins ${PROJECT_SOURCE_DIR}/deps)
  309. endif()
  310. add_library(open62541 $<TARGET_OBJECTS:open62541-object>)
  311. target_link_libraries(open62541 ${open62541_LIBRARIES})
  312. target_compile_definitions(open62541-object PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
  313. target_compile_definitions(open62541 PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
  314. if(WIN32)
  315. target_link_libraries(open62541 ws2_32)
  316. endif()
  317. ##########################
  318. # Build Selected Targets #
  319. ##########################
  320. if(UA_BUILD_EXAMPLES)
  321. add_subdirectory(examples)
  322. endif()
  323. if(UA_BUILD_UNIT_TESTS)
  324. target_compile_definitions(open62541-object PRIVATE UA_BUILD_UNIT_TESTS) # Export some internal functions
  325. enable_testing()
  326. add_subdirectory(tests)
  327. endif()
  328. if(UA_BUILD_DOCUMENTATION)
  329. add_subdirectory(doc)
  330. endif()
  331. if(UA_BUILD_EXAMPLES_NODESET_COMPILER)
  332. add_custom_target(generate_informationmodel ALL
  333. DEPENDS ${PROJECT_BINARY_DIR}/src_generated/nodeset.h ${PROJECT_BINARY_DIR}/src_generated/nodeset.c)
  334. endif()