1 diff --git a/CMakeLists.txt b/CMakeLists.txt
2 index de03564..df3fcf6 100644
6 cmake_minimum_required(VERSION 2.8)
8 -#It seems Cmake does not set default bild type so we force it
9 -if( NOT CMAKE_BUILD_TYPE )
10 - set( CMAKE_BUILD_TYPE Debug CACHE STRING "Debug" FORCE )
14 +set(CMAKE_CXX_STANDARD 11)
15 +set(CMAKE_POSITION_INDEPENDENT_CODE ON)
17 option(BUILD_CLIENT "Build Client" ON)
18 option(BUILD_SERVER "Build Server" ON)
19 @@ -16,28 +13,6 @@ option(BUILD_PYTHON "Build Python bindings" ON)
20 option(BUILD_TESTING "Build and run tests" OFF)
21 OPTION(BUILD_SHARED_LIBS "Build shared libraries." ON)
23 -IF (NOT DEFINED CMAKE_INSTALL_LIBDIR)
24 - SET(CMAKE_INSTALL_LIBDIR lib)
27 -SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
28 - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
33 -SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
34 - ${PROJECT_BINARY_DIR}/bin
39 -SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
40 - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
45 # Helper function to generate a pkg-config file for a single library
46 # Takes the filename of the .pc file as a parameter and replaces all
47 # placeholders in the .pc.in file with the actual values
48 @@ -60,23 +35,9 @@ function(generate_pkgconfig BASENAME)
50 endfunction(generate_pkgconfig)
52 - SET(STATIC_LIBRARY_CXX_FLAGS /MDd CACHE STRING "")
53 - SET(EXECUTABLE_CXX_FLAGS /MDd CACHE STRING "")
54 - SET(DYNAMIC_LIBRARY_CXX_FLAGS /MDd CACHE STRING "")
57 - add_definitions(/D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32 /D_WINDOWS /FS /D_WIN32_WINNT=0x0600)
58 - add_compile_options(/Zi /Od /EHsc /W4)
60 - set(CMAKE_CXX_FLAGS_DEBUG " -Wall -ggdb -o0 ${CMAKE_CXX_FLAGS_DEBUG}")
62 - SET(STATIC_LIBRARY_CXX_FLAGS)
63 - SET(EXECUTABLE_CXX_FLAGS)
64 - SET(DYNAMIC_LIBRARY_CXX_FLAGS)
66 - set(CMAKE_CXX_FLAGS " -std=c++11 -Wall -fPIC ${CMAKE_CXX_FLAGS} ")
67 - SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS})
68 - #set(CMAKE_SHARED_LINKER_FLAGS "--no-undefined" )
69 + add_definitions(-D_SCL_SECURE_NO_WARNINGS)
70 + add_definitions(-D_CRT_SECURE_NO_WARNINGS)
71 + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
75 @@ -105,7 +66,7 @@ else(WIN32)
79 -find_package( Boost COMPONENTS system program_options filesystem thread REQUIRED )
80 +find_package( Boost COMPONENTS system program_options filesystem thread date_time REQUIRED )
81 include_directories( ${Boost_INCLUDE_DIRS} )
82 link_directories( ${Boost_LIBRARY_DIRS} )
83 message(STATUS "Boost INCLUDE DIR IS: " ${Boost_INCLUDE_DIRS})
84 @@ -185,14 +146,12 @@ add_library(opcuaprotocol
85 src/protocol/subscriptions.cpp
88 -if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
89 - target_compile_options(opcuaprotocol PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
91 target_link_libraries(opcuaprotocol ${ADDITIONAL_LINK_LIBRARIES})
92 target_include_directories(opcuaprotocol PUBLIC $<INSTALL_INTERFACE:include>)
93 install(TARGETS opcuaprotocol EXPORT FreeOpcUa
94 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
95 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
96 - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
97 + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
99 generate_pkgconfig("libopcuaprotocol.pc")
101 @@ -227,10 +186,6 @@ if (BUILD_TESTING)
105 - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
106 - target_compile_options(test_opcuaprotocol PUBLIC ${EXECUTABLE_CXX_FLAGS})
109 add_test(NAME opcuaprotocol COMMAND test_opcuaprotocol)
112 @@ -266,15 +221,12 @@ SET(opcuacore_SOURCES
114 add_library(opcuacore ${opcuacore_SOURCES})
116 -if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
117 - target_compile_options(opcuacore PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
120 -target_link_libraries(opcuacore ${ADDITIONAL_LINK_LIBRARIES} opcuaprotocol ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
121 +target_link_libraries(opcuacore ${ADDITIONAL_LINK_LIBRARIES} opcuaprotocol ${Boost_LIBRARIES})
122 target_include_directories(opcuacore PUBLIC $<INSTALL_INTERFACE:include>)
123 install(TARGETS opcuacore EXPORT FreeOpcUa
124 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
125 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
126 - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
127 + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
129 generate_pkgconfig("libopcuacore.pc")
131 @@ -306,7 +258,7 @@ if (BUILD_TESTING)
134 if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
135 - target_compile_options(test_opcuacore PUBLIC ${D}DYNAMIC_ADDON_PATH="${DYNAMIC_ADDON_PATH}" ${D}TEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}" ${EXECUTABLE_CXX_FLAGS})
136 + target_compile_options(test_opcuacore PUBLIC -DDYNAMIC_ADDON_PATH="${DYNAMIC_ADDON_PATH}" -DTEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}" )
139 add_test(NAME opcuacore COMMAND test_opcuacore)
140 @@ -327,9 +279,6 @@ if (BUILD_CLIENT)
141 src/client/client.cpp
144 - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
145 - target_compile_options(opcuaclient PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
147 target_link_libraries(opcuaclient
149 ${ADDITIONAL_LINK_LIBRARIES}
150 @@ -338,8 +287,9 @@ if (BUILD_CLIENT)
152 target_include_directories(opcuaclient PUBLIC $<INSTALL_INTERFACE:include>)
153 install(TARGETS opcuaclient EXPORT FreeOpcUa
154 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
155 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
156 - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
157 + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
159 generate_pkgconfig("libopcuaclient.pc")
161 @@ -371,9 +321,6 @@ if (BUILD_CLIENT)
165 - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
166 - target_compile_options(opcuaclient PUBLIC ${EXECUTABLE_CXX_FLAGS})
171 @@ -423,14 +370,12 @@ if(BUILD_SERVER)
172 src/server/subscription_service_internal.cpp
175 - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
176 - target_compile_options(opcuaserver PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
178 - target_link_libraries(opcuaserver ${ADDITIONAL_LINK_LIBRARIES} opcuacore opcuaprotocol ${Boost_SYSTEM_LIBRARY})
179 + target_link_libraries(opcuaserver ${ADDITIONAL_LINK_LIBRARIES} opcuacore opcuaprotocol ${Boost_LIBRARIES})
180 target_include_directories(opcuaserver PUBLIC $<INSTALL_INTERFACE:include>)
181 install(TARGETS opcuaserver EXPORT FreeOpcUa
182 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
183 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
184 - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
185 + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
187 generate_pkgconfig("libopcuaserver.pc")
189 @@ -481,7 +426,7 @@ if(BUILD_SERVER)
191 target_include_directories(test_opcuaserver PUBLIC .)
192 if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
193 - target_compile_options(test_opcuaserver PUBLIC ${D}TEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}" ${STATIC_LIBRARY_CXX_FLAGS})
194 + target_compile_options(test_opcuaserver PUBLIC -DTEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}")
197 add_test(NAME opcuaserverapp COMMAND test_opcuaserver)
198 @@ -510,9 +455,6 @@ if(BUILD_SERVER)
200 ${Boost_PROGRAM_OPTIONS_LIBRARY}
202 - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
203 - target_compile_options(opcuaserverapp PUBLIC ${EXECUTABLE_CXX_FLAGS})
208 @@ -533,9 +475,6 @@ if (BUILD_CLIENT)
209 ${SSL_SUPPORT_LINK_LIBRARIES}
212 - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
213 - target_compile_options(example_client PUBLIC ${EXECUTABLE_CXX_FLAGS})
218 @@ -555,9 +494,6 @@ if(BUILD_SERVER)
222 - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
223 - target_compile_options(example_server PUBLIC ${EXECUTABLE_CXX_FLAGS})
226 set_target_properties(example_server PROPERTIES LINK_FLAGS /STACK:3000000)
228 @@ -572,8 +508,8 @@ if (BUILD_PYTHON)
229 add_subdirectory(python)
232 -install(EXPORT FreeOpcUa DESTINATION lib/cmake/FreeOpcUa FILE FreeOpcUaConfig.cmake)
233 +install(EXPORT FreeOpcUa DESTINATION share/freeopcua FILE freeopcuaConfig.cmake)
235 SET(CPACK_GENERATOR "DEB")
236 -SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "FreeOpcUa")
237 +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "freeopcua")