[freeopcua] better dealing with dynamic builds (#5763)

* [freeopcua] better dealing with dynamic builds
This commit is contained in:
Stefano Sinigardi 2019-03-22 07:17:13 +01:00 committed by Phil Christensen
parent 6e8725ba64
commit de4add711d
3 changed files with 62 additions and 29 deletions

View File

@ -1,4 +1,4 @@
Source: freeopcua
Version: 20190125
Version: 20190125-1
Description: OPC-UA server and client library written in C++ and with a lot of code auto-generated from xml specification using python.
Build-Depends: boost-asio,boost-system,boost-program-options,boost-filesystem,boost-thread,boost-format,boost-foreach,boost-property-tree,boost-date-time

View File

@ -1,17 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index de03564..2637355 100644
index de03564..df3fcf6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,8 @@ if( NOT CMAKE_BUILD_TYPE )
endif()
@@ -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 +18,6 @@ option(BUILD_PYTHON "Build Python bindings" 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)
@ -40,7 +45,7 @@ index de03564..2637355 100644
# 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 +40,12 @@ function(generate_pkgconfig BASENAME)
@@ -60,23 +35,9 @@ function(generate_pkgconfig BASENAME)
endif()
endfunction(generate_pkgconfig)
if(MSVC)
@ -63,14 +68,11 @@ index de03564..2637355 100644
- #set(CMAKE_SHARED_LINKER_FLAGS "--no-undefined" )
+ add_definitions(-D_SCL_SECURE_NO_WARNINGS)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ add_definitions(-D_WIN32)
+ add_definitions(-D_WINDOWS)
+ add_definitions(-D_WIN32_WINNT=0x0600)
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
if(WIN32)
@@ -105,7 +74,7 @@ else(WIN32)
@@ -105,7 +66,7 @@ else(WIN32)
endif(WIN32)
@ -79,7 +81,7 @@ index de03564..2637355 100644
include_directories( ${Boost_INCLUDE_DIRS} )
link_directories( ${Boost_LIBRARY_DIRS} )
message(STATUS "Boost INCLUDE DIR IS: " ${Boost_INCLUDE_DIRS})
@@ -185,9 +154,6 @@ add_library(opcuaprotocol
@@ -185,14 +146,12 @@ add_library(opcuaprotocol
src/protocol/subscriptions.cpp
)
@ -89,7 +91,14 @@ index de03564..2637355 100644
target_link_libraries(opcuaprotocol ${ADDITIONAL_LINK_LIBRARIES})
target_include_directories(opcuaprotocol PUBLIC $<INSTALL_INTERFACE:include>)
install(TARGETS opcuaprotocol EXPORT FreeOpcUa
@@ -227,10 +193,6 @@ if (BUILD_TESTING)
+ 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
)
@ -100,7 +109,7 @@ index de03564..2637355 100644
add_test(NAME opcuaprotocol COMMAND test_opcuaprotocol)
endif()
@@ -266,11 +228,7 @@ SET(opcuacore_SOURCES
@@ -266,15 +221,12 @@ SET(opcuacore_SOURCES
add_library(opcuacore ${opcuacore_SOURCES})
@ -112,17 +121,23 @@ index de03564..2637355 100644
+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}
@@ -306,7 +264,7 @@ if (BUILD_TESTING)
- 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 ${D}DYNAMIC_ADDON_PATH="${DYNAMIC_ADDON_PATH}" ${D}TEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}" )
+ 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 +285,6 @@ if (BUILD_CLIENT)
@@ -327,9 +279,6 @@ if (BUILD_CLIENT)
src/client/client.cpp
)
@ -132,7 +147,18 @@ index de03564..2637355 100644
target_link_libraries(opcuaclient
opcuacore
${ADDITIONAL_LINK_LIBRARIES}
@@ -371,9 +326,6 @@ if (BUILD_CLIENT)
@@ -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
)
@ -142,7 +168,7 @@ index de03564..2637355 100644
endif(BUILD_CLIENT)
@@ -423,10 +375,7 @@ if(BUILD_SERVER)
@@ -423,14 +370,12 @@ if(BUILD_SERVER)
src/server/subscription_service_internal.cpp
)
@ -153,17 +179,23 @@ index de03564..2637355 100644
+ 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}
@@ -481,7 +430,7 @@ if(BUILD_SERVER)
- 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 ${D}TEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}")
+ target_compile_options(test_opcuaserver PUBLIC -DTEST_CORE_CONFIG_PATH="${TEST_CORE_CONFIG_PATH}")
endif ()
add_test(NAME opcuaserverapp COMMAND test_opcuaserver)
@@ -510,9 +459,6 @@ if(BUILD_SERVER)
@@ -510,9 +455,6 @@ if(BUILD_SERVER)
opcuaserver
${Boost_PROGRAM_OPTIONS_LIBRARY}
)
@ -173,7 +205,7 @@ index de03564..2637355 100644
endif(BUILD_SERVER)
@@ -533,9 +479,6 @@ if (BUILD_CLIENT)
@@ -533,9 +475,6 @@ if (BUILD_CLIENT)
${SSL_SUPPORT_LINK_LIBRARIES}
)
@ -183,7 +215,7 @@ index de03564..2637355 100644
endif (BUILD_CLIENT)
@@ -555,9 +498,6 @@ if(BUILD_SERVER)
@@ -555,9 +494,6 @@ if(BUILD_SERVER)
opcuaserver
)
@ -193,12 +225,14 @@ index de03564..2637355 100644
if(MSVC)
set_target_properties(example_server PROPERTIES LINK_FLAGS /STACK:3000000)
endif(MSVC)
@@ -572,7 +512,7 @@ if (BUILD_PYTHON)
@@ -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)
+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")
+SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "freeopcua")
INCLUDE(CPack)

View File

@ -22,12 +22,11 @@ vcpkg_configure_cmake(
-DBUILD_PYTHON=OFF
-DBUILD_TESTING=OFF
-DSSL_SUPPORT_MBEDTLS=OFF
-DCMAKE_DEBUG_POSTFIX=d
)
vcpkg_install_cmake()
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/share/freeopcua/FreeOpcUaConfig-debug.cmake ${CURRENT_PACKAGES_DIR}/share/freeopcua/FreeOpcUaConfig-debug.cmake)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/share/freeopcua/FreeOpcUaConfig.cmake ${CURRENT_PACKAGES_DIR}/share/freeopcua/FreeOpcUaConfig.cmake)
vcpkg_fixup_cmake_targets()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)