CMakeLists.txt 20 KB

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