diff --git a/ports/freeopcua/CONTROL b/ports/freeopcua/CONTROL new file mode 100644 index 000000000..ad224b863 --- /dev/null +++ b/ports/freeopcua/CONTROL @@ -0,0 +1,4 @@ +Source: freeopcua +Version: 20190125 +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 diff --git a/ports/freeopcua/cmakelists_fixes.patch b/ports/freeopcua/cmakelists_fixes.patch new file mode 100644 index 000000000..6c9798766 --- /dev/null +++ b/ports/freeopcua/cmakelists_fixes.patch @@ -0,0 +1,204 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index de03564..2637355 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,6 +6,8 @@ if( NOT CMAKE_BUILD_TYPE ) + 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) + 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 +40,12 @@ 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) ++ 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) + + 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,9 +154,6 @@ 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(TARGETS opcuaprotocol EXPORT FreeOpcUa +@@ -227,10 +193,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,11 +228,7 @@ 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(TARGETS opcuacore EXPORT FreeOpcUa + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +@@ -306,7 +264,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}" ) + endif () + + add_test(NAME opcuacore COMMAND test_opcuacore) +@@ -327,9 +285,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} +@@ -371,9 +326,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,10 +375,7 @@ 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(TARGETS opcuaserver EXPORT FreeOpcUa + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +@@ -481,7 +430,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}") + endif () + + add_test(NAME opcuaserverapp COMMAND test_opcuaserver) +@@ -510,9 +459,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 +479,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 +498,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,7 +512,7 @@ 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") diff --git a/ports/freeopcua/improve_compatibility_with_recent_boost.patch b/ports/freeopcua/improve_compatibility_with_recent_boost.patch new file mode 100644 index 000000000..14e78a68e --- /dev/null +++ b/ports/freeopcua/improve_compatibility_with_recent_boost.patch @@ -0,0 +1,54 @@ +diff --git a/include/opc/ua/services/services.h b/include/opc/ua/services/services.h +index f138831..4732a59 100644 +--- a/include/opc/ua/services/services.h ++++ b/include/opc/ua/services/services.h +@@ -26,20 +26,7 @@ + #include + + #include +- +- +-namespace boost +-{ +-namespace asio +-{ +-#if BOOST_VERSION < 106600 +- class io_service; +-#else +- class io_context; +- typedef io_context io_service; +-#endif +-} +-} ++#include + + namespace OpcUa + { +diff --git a/src/server/internal_subscription.cpp b/src/server/internal_subscription.cpp +index edf4715..69ef74a 100644 +--- a/src/server/internal_subscription.cpp ++++ b/src/server/internal_subscription.cpp +@@ -14,7 +14,7 @@ InternalSubscription::InternalSubscription(SubscriptionServiceInternal & service + , CurrentSession(SessionAuthenticationToken) + , Callback(callback) + , io(service.GetIOService()) +- , Timer(io, boost::posix_time::milliseconds(data.RevisedPublishingInterval)) ++ , Timer(io, boost::posix_time::milliseconds((int)data.RevisedPublishingInterval)) + , LifeTimeCount(data.RevisedLifetimeCount) + , Logger(logger) + { +@@ -105,7 +105,7 @@ void InternalSubscription::PublishResults(const boost::system::error_code & erro + } + + TimerStopped = false; +- Timer.expires_at(Timer.expires_at() + boost::posix_time::milliseconds(Data.RevisedPublishingInterval)); ++ Timer.expires_at(Timer.expires_at() + boost::posix_time::milliseconds((int)Data.RevisedPublishingInterval)); + std::shared_ptr self = shared_from_this(); + Timer.async_wait([self](const boost::system::error_code & error) { self->PublishResults(error); }); + } +@@ -615,5 +615,3 @@ std::vector InternalSubscription::GetEventFields(const EventFilter & fi + + } + } +- +- diff --git a/ports/freeopcua/include_asio_first.patch b/ports/freeopcua/include_asio_first.patch new file mode 100644 index 000000000..d540a38ab --- /dev/null +++ b/ports/freeopcua/include_asio_first.patch @@ -0,0 +1,138 @@ +diff --git a/src/core/subscription.cpp b/src/core/subscription.cpp +index b690d3a..fdac2f3 100644 +--- a/src/core/subscription.cpp ++++ b/src/core/subscription.cpp +@@ -17,11 +17,10 @@ + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ******************************************************************************/ + +- +-#include ++#include + #include ++#include + +-#include + #include + + namespace OpcUa +diff --git a/src/server/asio_addon.cpp b/src/server/asio_addon.cpp +index 795a6b2..532ac3c 100644 +--- a/src/server/asio_addon.cpp ++++ b/src/server/asio_addon.cpp +@@ -17,9 +17,9 @@ + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ******************************************************************************/ + ++#include + #include + +-#include + #include + #include + +diff --git a/src/server/internal_subscription.h b/src/server/internal_subscription.h +index d42aa65..dd193a9 100644 +--- a/src/server/internal_subscription.h ++++ b/src/server/internal_subscription.h +@@ -1,6 +1,7 @@ + + #pragma once + ++#include + //#include "address_space_internal.h" + #include "subscription_service_internal.h" + +@@ -11,7 +12,6 @@ + #include + #include + +-#include + #include + #include + #include +@@ -115,5 +115,3 @@ private: + + } + } +- +- +diff --git a/src/server/opc_tcp_async.cpp b/src/server/opc_tcp_async.cpp +index dc700c2..f3a66b8 100644 +--- a/src/server/opc_tcp_async.cpp ++++ b/src/server/opc_tcp_async.cpp +@@ -17,6 +17,7 @@ + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ******************************************************************************/ + ++#include + #include "opc_tcp_processor.h" + + #include +@@ -29,7 +30,6 @@ + #include + + #include +-#include + #include + #include + #include +diff --git a/src/server/subscription_service_internal.h b/src/server/subscription_service_internal.h +index 6b16e1d..f7e5dfe 100644 +--- a/src/server/subscription_service_internal.h ++++ b/src/server/subscription_service_internal.h +@@ -9,6 +9,7 @@ + + #pragma once + ++#include + #include "address_space_addon.h" + #include "internal_subscription.h" + +@@ -20,7 +21,6 @@ + #include + #include + +-#include + #include + #include + #include +@@ -76,4 +76,3 @@ private: + } + + } +- +diff --git a/src/server/tcp_server.cpp b/src/server/tcp_server.cpp +index b4f2000..2430820 100644 +--- a/src/server/tcp_server.cpp ++++ b/src/server/tcp_server.cpp +@@ -8,9 +8,6 @@ + /// http://www.gnu.org/licenses/lgpl.html) + /// + +-#ifdef _WIN32 +-#include +-#endif + + #include "tcp_server.h" + +@@ -34,8 +31,18 @@ + #include + #include + +- + #ifdef _WIN32 ++#include ++#include ++#if !defined SHUT_RD && defined SD_RECEIVE ++#define SHUT_RD SD_RECEIVE ++#endif ++#if !defined SHUT_WR && defined SD_SEND ++#define SHUT_WR SD_SEND ++#endif ++#if !defined SHUT_RDWR && defined SD_BOTH ++#define SHUT_RDWR SD_BOTH ++#endif + #else + #include + #include diff --git a/ports/freeopcua/portfile.cmake b/ports/freeopcua/portfile.cmake new file mode 100644 index 000000000..e329f12e6 --- /dev/null +++ b/ports/freeopcua/portfile.cmake @@ -0,0 +1,35 @@ +include(vcpkg_common_functions) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO FreeOpcUa/freeopcua + REF 2f2c886eb2da46b9dc8944c8f79ac31a9f116a81 + SHA512 f19c1489eb116224ac3192e646c08cf3967c9a07064a09c4cbdef89d93e98c7541bb3edd030be22f6daf3f831ff92a324bc3734a8fe34cdd9d5a5ff7cb7f2f19 + HEAD_REF master + PATCHES + cmakelists_fixes.patch + improve_compatibility_with_recent_boost.patch + use_another_implementation_of_has_begin_end.patch + uri_facade_win.patch + serverObj.patch + include_asio_first.patch +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + -DBUILD_PYTHON=OFF + -DBUILD_TESTING=OFF + -DSSL_SUPPORT_MBEDTLS=OFF +) + +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) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) + +#Handle copyright +file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/freeopcua RENAME copyright) diff --git a/ports/freeopcua/serverObj.patch b/ports/freeopcua/serverObj.patch new file mode 100644 index 000000000..6680e587b --- /dev/null +++ b/ports/freeopcua/serverObj.patch @@ -0,0 +1,14 @@ +diff --git a/src/server/server_object.cpp b/src/server/server_object.cpp +index f35b168..b6c816a 100644 +--- a/src/server/server_object.cpp ++++ b/src/server/server_object.cpp +@@ -25,9 +25,6 @@ + #include + #include + +-#ifdef WIN32 +-#undef GetObject +-#endif + + namespace + { diff --git a/ports/freeopcua/uri_facade_win.patch b/ports/freeopcua/uri_facade_win.patch new file mode 100644 index 000000000..e6cc601dc --- /dev/null +++ b/ports/freeopcua/uri_facade_win.patch @@ -0,0 +1,28 @@ +diff --git a/src/core/common/uri_facade_win.cpp b/src/core/common/uri_facade_win.cpp +index 1a807fb..c579e2d 100644 +--- a/src/core/common/uri_facade_win.cpp ++++ b/src/core/common/uri_facade_win.cpp +@@ -19,7 +19,7 @@ + namespace Common + { + +-void Uri::Initialize(const char * uriString, std::size_t size) ++void Uri::Initialize(const std::string& uriString) + { + URL_COMPONENTS url = {0}; + url.dwStructSize = sizeof(url); +@@ -31,7 +31,7 @@ void Uri::Initialize(const char * uriString, std::size_t size) + + // TODO msdn says do not use this function in services and in server patforms. :( + // TODO http://msdn.microsoft.com/en-us/library/windows/desktop/aa384376(v=vs.85).aspx +- if (!InternetCrackUrl(uriString, size, options, &url)) ++ if (!InternetCrackUrl(uriString.c_str(), uriString.size(), options, &url)) + { + THROW_ERROR1(CannotParseUri, uriString); + } +@@ -50,5 +50,3 @@ void Uri::Initialize(const char * uriString, std::size_t size) + } + + } // namespace Common +- +- diff --git a/ports/freeopcua/use_another_implementation_of_has_begin_end.patch b/ports/freeopcua/use_another_implementation_of_has_begin_end.patch new file mode 100644 index 000000000..34fa77f7c --- /dev/null +++ b/ports/freeopcua/use_another_implementation_of_has_begin_end.patch @@ -0,0 +1,39 @@ +diff --git a/include/opc/ua/protocol/variant.h b/include/opc/ua/protocol/variant.h +index 9dc5b15..317cb17 100644 +--- a/include/opc/ua/protocol/variant.h ++++ b/include/opc/ua/protocol/variant.h +@@ -76,22 +76,25 @@ public: + template + struct has_begin_end + { +- template static char (&f(typename std::enable_if < +- std::is_same(&C::begin)), +- typename C::const_iterator(C::*)() const>::value, void >::type *))[1]; ++ struct Dummy { typedef void const_iterator; }; ++ typedef typename std::conditional::value, T, Dummy>::type TType; ++ typedef typename TType::const_iterator iter; + +- template static char (&f(...))[2]; ++ struct Fallback { iter begin() const; iter end() const; }; ++ struct Derived : TType, Fallback { }; + +- template static char (&g(typename std::enable_if < +- std::is_same(&C::end)), +- typename C::const_iterator(C::*)() const>::value, void >::type *))[1]; ++ template struct ChT; + ++ template static char (&f(ChT*))[1]; ++ template static char (&f(...))[2]; ++ template static char (&g(ChT*))[1]; + template static char (&g(...))[2]; + +- static bool const beg_value = sizeof(f(0)) == 1; +- static bool const end_value = sizeof(g(0)) == 1; ++ static bool const beg_value = sizeof(f(0)) == 2; ++ static bool const end_value = sizeof(g(0)) == 2; + }; + ++ + template + struct is_container_not_string : std::integral_constant < bool, has_const_iterator::value && has_begin_end::beg_value && has_begin_end::end_value > + { };