|
@@ -1,79 +1,16 @@
|
|
cmake_minimum_required(VERSION 2.6)
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
+# set(CMAKE_VERBOSE_MAKEFILE on )
|
|
|
|
|
|
project(open62541)
|
|
project(open62541)
|
|
-
|
|
|
|
set(open62541_VERSION_MAJOR 0)
|
|
set(open62541_VERSION_MAJOR 0)
|
|
set(open62541_VERSION_MINOR 1)
|
|
set(open62541_VERSION_MINOR 1)
|
|
|
|
|
|
-# set(CMAKE_VERBOSE_MAKEFILE on )
|
|
|
|
-
|
|
|
|
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules")
|
|
|
|
-
|
|
|
|
-# compiler options
|
|
|
|
-if(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
-add_definitions(-std=c99 -pedantic -pipe -fstack-protector -Wall -Wextra
|
|
|
|
- -Wno-unused-parameter -Wno-unused-function -Wno-unused-label
|
|
|
|
- -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar
|
|
|
|
- -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated
|
|
|
|
- -Wformat-security -Werror -ffunction-sections -fdata-sections
|
|
|
|
- -Wl,--gc-sections)
|
|
|
|
- if(WIN32)
|
|
|
|
- add_definitions(-fno-stack-protector)
|
|
|
|
- endif(WIN32)
|
|
|
|
-endif(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
-
|
|
|
|
-# multithreading
|
|
|
|
-set(MULTITHREADING OFF CACHE BOOL "Enable multithreading")
|
|
|
|
-if(MULTITHREADING)
|
|
|
|
- find_package(Threads REQUIRED)
|
|
|
|
-endif(MULTITHREADING)
|
|
|
|
-
|
|
|
|
-# encodings
|
|
|
|
-set(UA_ENCODING_AMOUNT 1) # binary encoding
|
|
|
|
-
|
|
|
|
-set(UA_ENCODING_XML OFF CACHE BOOL "Enable XML-encoding of the UA types")
|
|
|
|
-if(UA_ENCODING_XML)
|
|
|
|
- MATH(EXPR UA_ENCODING_AMOUNT "${UA_ENCODING_AMOUNT}+1")
|
|
|
|
- find_package(EXPAT REQUIRED)
|
|
|
|
- if(EXPAT_FOUND)
|
|
|
|
- include_directories(${EXPAT_INCLUDE_DIRS})
|
|
|
|
- else(EXPAT_FOUND)
|
|
|
|
- message(FATAL_ERROR "Expat library not found.")
|
|
|
|
- endif(EXPAT_FOUND)
|
|
|
|
-endif(UA_ENCODING_XML)
|
|
|
|
-
|
|
|
|
-set(UA_ENCODING_JSON OFF CACHE BOOL "Enable JSON-encoding of the UA types")
|
|
|
|
-if(UA_ENCODING_JSON)
|
|
|
|
- MATH(EXPR UA_ENCODING_AMOUNT "${UA_ENCODING_AMOUNT}+1")
|
|
|
|
-endif(UA_ENCODING_JSON)
|
|
|
|
-
|
|
|
|
-#included types
|
|
|
|
-set(TYPES_ONLY_NEEDED OFF CACHE BOOL "Inlcude only compile-needed types")
|
|
|
|
-
|
|
|
|
-# coverage
|
|
|
|
-option(ENABLE_COVERAGE "Enable gcov coverage" OFF)
|
|
|
|
-if(ENABLE_COVERAGE)
|
|
|
|
- message(STATUS "Enabling gcov support")
|
|
|
|
- set(CMAKE_BUILD_TYPE DEBUG)
|
|
|
|
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
-endif(ENABLE_COVERAGE)
|
|
|
|
-
|
|
|
|
-# directory for generated source files
|
|
|
|
-file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
|
|
|
|
-include_directories("${PROJECT_BINARY_DIR}/src_generated")
|
|
|
|
-
|
|
|
|
-# build the library
|
|
|
|
-configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
|
|
|
|
-
|
|
|
|
|
|
+# main sources of libopen62541
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/server")
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/server")
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/util")
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/util")
|
|
-
|
|
|
|
file(GLOB_RECURSE headers "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
|
|
file(GLOB_RECURSE headers "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
|
|
file(GLOB generated_headers "${PROJECT_BINARY_DIR}/src_generated/*.h")
|
|
file(GLOB generated_headers "${PROJECT_BINARY_DIR}/src_generated/*.h")
|
|
-
|
|
|
|
set(lib_sources src/ua_types.c
|
|
set(lib_sources src/ua_types.c
|
|
src/ua_types_encoding_binary.c
|
|
src/ua_types_encoding_binary.c
|
|
${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
|
|
${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
|
|
@@ -95,44 +32,91 @@ set(lib_sources src/ua_types.c
|
|
src/server/ua_channel_manager.c
|
|
src/server/ua_channel_manager.c
|
|
src/server/ua_session_manager.c
|
|
src/server/ua_session_manager.c
|
|
src/server/ua_transport_connection_manager.c
|
|
src/server/ua_transport_connection_manager.c
|
|
- src/server/ua_server.c
|
|
|
|
|
|
+ src/server/ua_server.c
|
|
src/server/ua_application.c
|
|
src/server/ua_application.c
|
|
src/util/ua_util.c
|
|
src/util/ua_util.c
|
|
src/util/ua_list.c
|
|
src/util/ua_list.c
|
|
src/util/ua_indexedList.c
|
|
src/util/ua_indexedList.c
|
|
src/util/ua_base64.c
|
|
src/util/ua_base64.c
|
|
- ${headers}
|
|
|
|
- ${generated_headers})
|
|
|
|
|
|
+ ${headers}
|
|
|
|
+ ${generated_headers})
|
|
|
|
|
|
-if(MULTITHREADING)
|
|
|
|
- list(APPEND lib_sources src/server/ua_namespace_concurrent.c)
|
|
|
|
-else()
|
|
|
|
- list(APPEND lib_sources src/server/ua_namespace.c)
|
|
|
|
-endif(MULTITHREADING)
|
|
|
|
|
|
+# build settings
|
|
|
|
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules")
|
|
|
|
+set(generate_src_options) # the options for the tools that generate code from xml-schema definitions
|
|
|
|
|
|
-set(generate_src_options)
|
|
|
|
|
|
+## compiler flags
|
|
|
|
+if(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
+add_definitions(-std=c99 -pedantic -pipe -fstack-protector -Wall -Wextra
|
|
|
|
+ -Wno-unused-parameter -Wno-unused-function -Wno-unused-label
|
|
|
|
+ -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar
|
|
|
|
+ -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated
|
|
|
|
+ -Wformat-security -Werror -ffunction-sections -fdata-sections
|
|
|
|
+ -Wl,--gc-sections)
|
|
|
|
+ if(WIN32)
|
|
|
|
+ add_definitions(-fno-stack-protector)
|
|
|
|
+ endif(WIN32)
|
|
|
|
+endif(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
|
|
-#types
|
|
|
|
|
|
+## auto-generate all types or only the relevant subset?
|
|
|
|
+option(TYPES_ONLY_NEEDED "Include only compile-needed types" OFF)
|
|
if(TYPES_ONLY_NEEDED)
|
|
if(TYPES_ONLY_NEEDED)
|
|
list(APPEND generate_src_options "--only-needed")
|
|
list(APPEND generate_src_options "--only-needed")
|
|
endif(TYPES_ONLY_NEEDED)
|
|
endif(TYPES_ONLY_NEEDED)
|
|
|
|
|
|
|
|
+## encodings
|
|
|
|
+set(UA_ENCODING_AMOUNT 1) # binary encoding
|
|
|
|
|
|
-if(UA_ENCODING_XML)
|
|
|
|
|
|
+### xml
|
|
|
|
+option(ENABLE_XML_ENCODING "Enable XML-encoding of the UA types" OFF)
|
|
|
|
+if(ENABLE_XML_ENCODING)
|
|
|
|
+ MATH(EXPR UA_ENCODING_AMOUNT "${UA_ENCODING_AMOUNT}+1")
|
|
|
|
+ find_package(EXPAT REQUIRED)
|
|
|
|
+ if(EXPAT_FOUND)
|
|
|
|
+ include_directories(${EXPAT_INCLUDE_DIRS})
|
|
|
|
+ else(EXPAT_FOUND)
|
|
|
|
+ message(FATAL_ERROR "Expat library not found.")
|
|
|
|
+ endif(EXPAT_FOUND)
|
|
list(APPEND lib_sources src/ua_types_encoding_xml.c
|
|
list(APPEND lib_sources src/ua_types_encoding_xml.c
|
|
src/server/ua_namespace_xml.c
|
|
src/server/ua_namespace_xml.c
|
|
src/ua_xml.c)
|
|
src/ua_xml.c)
|
|
list(APPEND generate_src_options "--with-xml")
|
|
list(APPEND generate_src_options "--with-xml")
|
|
-endif(UA_ENCODING_XML)
|
|
|
|
|
|
+endif(ENABLE_XML_ENCODING)
|
|
|
|
|
|
-if(UA_ENCODING_JSON)
|
|
|
|
|
|
+### json
|
|
|
|
+option(ENABLE_JSON_ENCODING "Enable JSON-encoding of the UA types" OFF)
|
|
|
|
+if(ENABLE_JSON_ENCODING)
|
|
|
|
+ MATH(EXPR UA_ENCODING_AMOUNT "${UA_ENCODING_AMOUNT}+1")
|
|
list(APPEND lib_sources src/ua_types_encoding_json.c)
|
|
list(APPEND lib_sources src/ua_types_encoding_json.c)
|
|
list(APPEND generate_src_options "--with-json")
|
|
list(APPEND generate_src_options "--with-json")
|
|
-endif(UA_ENCODING_JSON)
|
|
|
|
|
|
+endif(ENABLE_JSON_ENCODING)
|
|
|
|
+
|
|
|
|
+configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
|
|
|
|
+
|
|
|
|
+## multithreading
|
|
|
|
+option(ENABLE_MULTITHREADING "Enable multithreading" OFF)
|
|
|
|
+if(ENABLE_MULTITHREADING)
|
|
|
|
+ find_package(Threads REQUIRED)
|
|
|
|
+ list(APPEND lib_sources src/server/ua_namespace_concurrent.c)
|
|
|
|
+else()
|
|
|
|
+ list(APPEND lib_sources src/server/ua_namespace.c)
|
|
|
|
+endif(ENABLE_MULTITHREADING)
|
|
|
|
|
|
add_library(open62541 ${lib_sources})
|
|
add_library(open62541 ${lib_sources})
|
|
|
|
|
|
-# generate data structures
|
|
|
|
|
|
+## coverage
|
|
|
|
+option(ENABLE_COVERAGE "Enable gcov coverage" OFF)
|
|
|
|
+if(ENABLE_COVERAGE)
|
|
|
|
+ message(STATUS "Enabling gcov support")
|
|
|
|
+ set(CMAKE_BUILD_TYPE DEBUG)
|
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
+endif(ENABLE_COVERAGE)
|
|
|
|
+
|
|
|
|
+# build generated code
|
|
|
|
+file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
|
|
|
|
+include_directories("${PROJECT_BINARY_DIR}/src_generated")
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
|
|
${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h
|
|
${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h
|
|
COMMAND python ${PROJECT_SOURCE_DIR}/tools/generate_builtin.py ${generate_src_options} ${PROJECT_SOURCE_DIR}/schema/Opc.Ua.Types.bsd ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated
|
|
COMMAND python ${PROJECT_SOURCE_DIR}/tools/generate_builtin.py ${generate_src_options} ${PROJECT_SOURCE_DIR}/schema/Opc.Ua.Types.bsd ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated
|
|
@@ -145,40 +129,25 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_namespace.py
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_namespace.py
|
|
${CMAKE_CURRENT_SOURCE_DIR}/schema/NodeIds.csv)
|
|
${CMAKE_CURRENT_SOURCE_DIR}/schema/NodeIds.csv)
|
|
|
|
|
|
-# download queue.h if required
|
|
|
|
-if(WIN32)
|
|
|
|
- if(NOT EXISTS "${PROJECT_BINARY_DIR}/src_generated/queue.h")
|
|
|
|
- file(DOWNLOAD "http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/~checkout~/src/sys/sys/queue.h" "${PROJECT_BINARY_DIR}/src_generated/queue.h" STATUS result)
|
|
|
|
- list(GET result 0 download_ok)
|
|
|
|
- if(NOT ${download_ok} MATCHES 0)
|
|
|
|
- file(REMOVE "${PROJECT_BINARY_DIR}/src_generated/queue.h") # remove empty file if created
|
|
|
|
- message(FATAL_ERROR "queue.h could not be downloaded")
|
|
|
|
- endif()
|
|
|
|
- endif()
|
|
|
|
-endif(WIN32)
|
|
|
|
-
|
|
|
|
-# build example implementations
|
|
|
|
|
|
+# build example server
|
|
add_executable(exampleServer examples/opcuaServer.c
|
|
add_executable(exampleServer examples/opcuaServer.c
|
|
examples/networklayer.c)
|
|
examples/networklayer.c)
|
|
target_link_libraries(exampleServer open62541)
|
|
target_link_libraries(exampleServer open62541)
|
|
if(WIN32)
|
|
if(WIN32)
|
|
target_link_libraries(exampleServer ws2_32)
|
|
target_link_libraries(exampleServer ws2_32)
|
|
endif(WIN32)
|
|
endif(WIN32)
|
|
-if(MULTITHREADING)
|
|
|
|
|
|
+if(ENABLE_MULTITHREADING)
|
|
target_link_libraries(exampleServer urcu-cds urcu)
|
|
target_link_libraries(exampleServer urcu-cds urcu)
|
|
-endif(MULTITHREADING)
|
|
|
|
|
|
+endif(ENABLE_MULTITHREADING)
|
|
|
|
|
|
-# build api server specificaion
|
|
|
|
-#add_executable(api-design examples/api-design/server.c)
|
|
|
|
-#target_link_libraries(api-design open62541)
|
|
|
|
-#if(WIN32)
|
|
|
|
-# target_link_libraries(api-design ws2_32)
|
|
|
|
-#endif(WIN32)
|
|
|
|
-#if(MULTITHREADING)
|
|
|
|
-# target_link_libraries(api-design urcu-cds urcu)
|
|
|
|
-#endif(MULTITHREADING)
|
|
|
|
|
|
+# build unit tests
|
|
|
|
+option(ENABLE_UNIT_TESTS "Run unit tests after building" OFF)
|
|
|
|
+if(ENABLE_UNIT_TESTS)
|
|
|
|
+ enable_testing()
|
|
|
|
+ add_subdirectory(tests)
|
|
|
|
+endif(ENABLE_UNIT_TESTS)
|
|
|
|
|
|
-# generate documentation
|
|
|
|
|
|
+# build documentation
|
|
option(GENERATE_DOCUMENTATION "Generate doxygen documentation" OFF)
|
|
option(GENERATE_DOCUMENTATION "Generate doxygen documentation" OFF)
|
|
if(GENERATE_DOCUMENTATION)
|
|
if(GENERATE_DOCUMENTATION)
|
|
find_package(Doxygen)
|
|
find_package(Doxygen)
|
|
@@ -192,9 +161,25 @@ if(GENERATE_DOCUMENTATION)
|
|
COMMENT "Generating API documentation with Doxygen")
|
|
COMMENT "Generating API documentation with Doxygen")
|
|
endif(GENERATE_DOCUMENTATION)
|
|
endif(GENERATE_DOCUMENTATION)
|
|
|
|
|
|
-# run unit tests
|
|
|
|
-option(UNIT_TESTS "Run unit tests after building" OFF)
|
|
|
|
-if(UNIT_TESTS)
|
|
|
|
- enable_testing()
|
|
|
|
- add_subdirectory(tests)
|
|
|
|
-endif(UNIT_TESTS)
|
|
|
|
|
|
+# download queue.h if required
|
|
|
|
+if(WIN32)
|
|
|
|
+ if(NOT EXISTS "${PROJECT_BINARY_DIR}/src_generated/queue.h")
|
|
|
|
+ file(DOWNLOAD "http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/~checkout~/src/sys/sys/queue.h" "${PROJECT_BINARY_DIR}/src_generated/queue.h" STATUS result)
|
|
|
|
+ list(GET result 0 download_ok)
|
|
|
|
+ if(NOT ${download_ok} MATCHES 0)
|
|
|
|
+ file(REMOVE "${PROJECT_BINARY_DIR}/src_generated/queue.h") # remove empty file if created
|
|
|
|
+ message(FATAL_ERROR "queue.h could not be downloaded")
|
|
|
|
+ endif()
|
|
|
|
+ endif()
|
|
|
|
+endif(WIN32)
|
|
|
|
+
|
|
|
|
+# build api server specificaion
|
|
|
|
+#add_executable(api-design examples/api-design/server.c)
|
|
|
|
+#target_link_libraries(api-design open62541)
|
|
|
|
+#if(WIN32)
|
|
|
|
+# target_link_libraries(api-design ws2_32)
|
|
|
|
+#endif(WIN32)
|
|
|
|
+#if(MULTITHREADING)
|
|
|
|
+# target_link_libraries(api-design urcu-cds urcu)
|
|
|
|
+#endif(MULTITHREADING)
|
|
|
|
+
|