mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-26 06:51:18 +08:00
de4add711d
* [freeopcua] better dealing with dynamic builds
239 lines
8.8 KiB
Diff
239 lines
8.8 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index de03564..df3fcf6 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -1,11 +1,8 @@
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
-#It seems Cmake does not set default bild type so we force it
|
|
-if( NOT CMAKE_BUILD_TYPE )
|
|
- set( CMAKE_BUILD_TYPE Debug CACHE STRING "Debug" FORCE )
|
|
-endif()
|
|
-
|
|
project(freeopcua)
|
|
+set(CMAKE_CXX_STANDARD 11)
|
|
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
option(BUILD_CLIENT "Build Client" ON)
|
|
option(BUILD_SERVER "Build Server" ON)
|
|
@@ -16,28 +13,6 @@ option(BUILD_PYTHON "Build Python bindings" ON)
|
|
option(BUILD_TESTING "Build and run tests" OFF)
|
|
OPTION(BUILD_SHARED_LIBS "Build shared libraries." ON)
|
|
|
|
-IF (NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
|
- SET(CMAKE_INSTALL_LIBDIR lib)
|
|
-ENDIF ()
|
|
-
|
|
-SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
|
|
- ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
|
- CACHE PATH
|
|
- ""
|
|
- )
|
|
-
|
|
-SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
|
- ${PROJECT_BINARY_DIR}/bin
|
|
- CACHE PATH
|
|
- ""
|
|
- )
|
|
-
|
|
-SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
|
|
- ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
|
- CACHE PATH
|
|
- ""
|
|
- )
|
|
-
|
|
# Helper function to generate a pkg-config file for a single library
|
|
# Takes the filename of the .pc file as a parameter and replaces all
|
|
# placeholders in the .pc.in file with the actual values
|
|
@@ -60,23 +35,9 @@ function(generate_pkgconfig BASENAME)
|
|
endif()
|
|
endfunction(generate_pkgconfig)
|
|
if(MSVC)
|
|
- SET(STATIC_LIBRARY_CXX_FLAGS /MDd CACHE STRING "")
|
|
- SET(EXECUTABLE_CXX_FLAGS /MDd CACHE STRING "")
|
|
- SET(DYNAMIC_LIBRARY_CXX_FLAGS /MDd CACHE STRING "")
|
|
- SET(D /D)
|
|
-
|
|
- add_definitions(/D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32 /D_WINDOWS /FS /D_WIN32_WINNT=0x0600)
|
|
- add_compile_options(/Zi /Od /EHsc /W4)
|
|
-else(MSVC)
|
|
- set(CMAKE_CXX_FLAGS_DEBUG " -Wall -ggdb -o0 ${CMAKE_CXX_FLAGS_DEBUG}")
|
|
-
|
|
- SET(STATIC_LIBRARY_CXX_FLAGS)
|
|
- SET(EXECUTABLE_CXX_FLAGS)
|
|
- SET(DYNAMIC_LIBRARY_CXX_FLAGS)
|
|
- SET(D -D)
|
|
- set(CMAKE_CXX_FLAGS " -std=c++11 -Wall -fPIC ${CMAKE_CXX_FLAGS} ")
|
|
- SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS})
|
|
- #set(CMAKE_SHARED_LINKER_FLAGS "--no-undefined" )
|
|
+ add_definitions(-D_SCL_SECURE_NO_WARNINGS)
|
|
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
|
endif()
|
|
|
|
if(WIN32)
|
|
@@ -105,7 +66,7 @@ else(WIN32)
|
|
|
|
endif(WIN32)
|
|
|
|
-find_package( Boost COMPONENTS system program_options filesystem thread REQUIRED )
|
|
+find_package( Boost COMPONENTS system program_options filesystem thread date_time REQUIRED )
|
|
include_directories( ${Boost_INCLUDE_DIRS} )
|
|
link_directories( ${Boost_LIBRARY_DIRS} )
|
|
message(STATUS "Boost INCLUDE DIR IS: " ${Boost_INCLUDE_DIRS})
|
|
@@ -185,14 +146,12 @@ add_library(opcuaprotocol
|
|
src/protocol/subscriptions.cpp
|
|
)
|
|
|
|
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(opcuaprotocol PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
|
|
-endif ()
|
|
target_link_libraries(opcuaprotocol ${ADDITIONAL_LINK_LIBRARIES})
|
|
target_include_directories(opcuaprotocol PUBLIC $<INSTALL_INTERFACE:include>)
|
|
install(TARGETS opcuaprotocol EXPORT FreeOpcUa
|
|
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
|
|
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
generate_pkgconfig("libopcuaprotocol.pc")
|
|
|
|
@@ -227,10 +186,6 @@ if (BUILD_TESTING)
|
|
gtest_main
|
|
)
|
|
|
|
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(test_opcuaprotocol PUBLIC ${EXECUTABLE_CXX_FLAGS})
|
|
- endif ()
|
|
-
|
|
add_test(NAME opcuaprotocol COMMAND test_opcuaprotocol)
|
|
endif()
|
|
|
|
@@ -266,15 +221,12 @@ SET(opcuacore_SOURCES
|
|
|
|
add_library(opcuacore ${opcuacore_SOURCES})
|
|
|
|
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(opcuacore PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
|
|
-endif ()
|
|
-
|
|
-target_link_libraries(opcuacore ${ADDITIONAL_LINK_LIBRARIES} opcuaprotocol ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
|
|
+target_link_libraries(opcuacore ${ADDITIONAL_LINK_LIBRARIES} opcuaprotocol ${Boost_LIBRARIES})
|
|
target_include_directories(opcuacore PUBLIC $<INSTALL_INTERFACE:include>)
|
|
install(TARGETS opcuacore EXPORT FreeOpcUa
|
|
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
|
|
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
generate_pkgconfig("libopcuacore.pc")
|
|
|
|
@@ -306,7 +258,7 @@ if (BUILD_TESTING)
|
|
)
|
|
|
|
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- 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})
|
|
+ target_compile_options(test_opcuacore PUBLIC -DDYNAMIC_ADDON_PATH="${DYNAMIC_ADDON_PATH}" -DTEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}" )
|
|
endif ()
|
|
|
|
add_test(NAME opcuacore COMMAND test_opcuacore)
|
|
@@ -327,9 +279,6 @@ if (BUILD_CLIENT)
|
|
src/client/client.cpp
|
|
)
|
|
|
|
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(opcuaclient PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
|
|
- endif ()
|
|
target_link_libraries(opcuaclient
|
|
opcuacore
|
|
${ADDITIONAL_LINK_LIBRARIES}
|
|
@@ -338,8 +287,9 @@ if (BUILD_CLIENT)
|
|
|
|
target_include_directories(opcuaclient PUBLIC $<INSTALL_INTERFACE:include>)
|
|
install(TARGETS opcuaclient EXPORT FreeOpcUa
|
|
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
|
|
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
generate_pkgconfig("libopcuaclient.pc")
|
|
|
|
@@ -371,9 +321,6 @@ if (BUILD_CLIENT)
|
|
opcuacore
|
|
)
|
|
|
|
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(opcuaclient PUBLIC ${EXECUTABLE_CXX_FLAGS})
|
|
- endif ()
|
|
endif(BUILD_CLIENT)
|
|
|
|
|
|
@@ -423,14 +370,12 @@ if(BUILD_SERVER)
|
|
src/server/subscription_service_internal.cpp
|
|
)
|
|
|
|
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(opcuaserver PUBLIC ${STATIC_LIBRARY_CXX_FLAGS})
|
|
- endif ()
|
|
- target_link_libraries(opcuaserver ${ADDITIONAL_LINK_LIBRARIES} opcuacore opcuaprotocol ${Boost_SYSTEM_LIBRARY})
|
|
+ target_link_libraries(opcuaserver ${ADDITIONAL_LINK_LIBRARIES} opcuacore opcuaprotocol ${Boost_LIBRARIES})
|
|
target_include_directories(opcuaserver PUBLIC $<INSTALL_INTERFACE:include>)
|
|
install(TARGETS opcuaserver EXPORT FreeOpcUa
|
|
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static)
|
|
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
generate_pkgconfig("libopcuaserver.pc")
|
|
|
|
@@ -481,7 +426,7 @@ if(BUILD_SERVER)
|
|
|
|
target_include_directories(test_opcuaserver PUBLIC .)
|
|
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(test_opcuaserver PUBLIC ${D}TEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}" ${STATIC_LIBRARY_CXX_FLAGS})
|
|
+ target_compile_options(test_opcuaserver PUBLIC -DTEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}")
|
|
endif ()
|
|
|
|
add_test(NAME opcuaserverapp COMMAND test_opcuaserver)
|
|
@@ -510,9 +455,6 @@ if(BUILD_SERVER)
|
|
opcuaserver
|
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
)
|
|
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(opcuaserverapp PUBLIC ${EXECUTABLE_CXX_FLAGS})
|
|
- endif ()
|
|
|
|
endif(BUILD_SERVER)
|
|
|
|
@@ -533,9 +475,6 @@ if (BUILD_CLIENT)
|
|
${SSL_SUPPORT_LINK_LIBRARIES}
|
|
)
|
|
|
|
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(example_client PUBLIC ${EXECUTABLE_CXX_FLAGS})
|
|
- endif ()
|
|
|
|
endif (BUILD_CLIENT)
|
|
|
|
@@ -555,9 +494,6 @@ if(BUILD_SERVER)
|
|
opcuaserver
|
|
)
|
|
|
|
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
- target_compile_options(example_server PUBLIC ${EXECUTABLE_CXX_FLAGS})
|
|
- endif ()
|
|
if(MSVC)
|
|
set_target_properties(example_server PROPERTIES LINK_FLAGS /STACK:3000000)
|
|
endif(MSVC)
|
|
@@ -572,8 +508,8 @@ if (BUILD_PYTHON)
|
|
add_subdirectory(python)
|
|
endif (BUILD_PYTHON)
|
|
|
|
-install(EXPORT FreeOpcUa DESTINATION lib/cmake/FreeOpcUa FILE FreeOpcUaConfig.cmake)
|
|
+install(EXPORT FreeOpcUa DESTINATION share/freeopcua FILE freeopcuaConfig.cmake)
|
|
|
|
SET(CPACK_GENERATOR "DEB")
|
|
-SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "FreeOpcUa")
|
|
+SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "freeopcua")
|
|
INCLUDE(CPack)
|