diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2020-05-06 13:41:46 +0200 |
---|---|---|
committer | Jannis Voelker <jannis.voelker@basyskom.com> | 2020-06-04 09:21:39 +0200 |
commit | 119bbeb00b96ed628d4dff32dfea6fee09d74abf (patch) | |
tree | e877ec40469aeedba7527a4afdd4bfc63c1e1119 /cmake | |
parent | 762126c13026d4ae7cdbd27ad621ef43e155279c (diff) |
Add CMake support for building Qt OPC UA
Change-Id: I1cf9c7f4914a665d7a057950eb6528929034e039
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindMbedtls.cmake | 67 | ||||
-rw-r--r-- | cmake/FindOpen62541.cmake | 50 | ||||
-rw-r--r-- | cmake/FindUacpp.cmake | 170 |
3 files changed, 287 insertions, 0 deletions
diff --git a/cmake/FindMbedtls.cmake b/cmake/FindMbedtls.cmake new file mode 100644 index 0000000..9e29ea1 --- /dev/null +++ b/cmake/FindMbedtls.cmake @@ -0,0 +1,67 @@ +#.rst: +# FindMbedtls +# --------- +# +# Try to locate the mbedTLS library. +# If found, this will define the following variables: +# +# ``Mbedtls_FOUND`` +# True if the mbedtls library is available +# ``Mbedtls_INCLUDE_DIRS`` +# The mbedTLS include directories +# ``Mbedx509_LIBRARIES`` +# The mbedx509 library for linking +# ``Mbedcrypto_LIBRARIES`` +# The mbedcrypto library for linking +# +# If ``Mbedtls_FOUND`` is TRUE, it will also define the following +# imported targets: +# +# ``mbedx509`` +# The mbedx509 library +# ``mbedcrypto`` +# The mbedcrypto library +# ``mbedtls`` +# An interface library combining mbedx509 and mbedcrypto + + +find_path(Mbedtls_INCLUDE_DIRS + NAMES mbedtls/x509_crt.h + HINTS ${MBEDTLS_INCDIR}) + +find_library(Mbedx509_LIBRARIES + NAMES mbedx509 + HINTS ${MBEDTLS_LIBDIR}) + +find_library(Mbedcrypto_LIBRARIES + NAMES mbedcrypto + HINTS ${MBEDTLS_LIBDIR}) + +if (NOT Mbedtls_INCLUDE_DIRS STREQUAL "Mbedtls_INCLUDE_DIRS-NOTFOUND" + AND NOT Mbedx509_LIBRARIES STREQUAL "Mbedx09_LIBRARIES-NOTFOUND" + AND NOT Mbedcrypto_LIBRARIES STREQUAL "Mbedcrypto_LIBRARIES-NOTFOUND") + set(Mbedtls_FOUND ON) +endif() + +if (Mbedtls_FOUND) + add_library(mbedx509 UNKNOWN IMPORTED) + set_target_properties(mbedx509 PROPERTIES + IMPORTED_LOCATION "${Mbedx509_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Mbedtls_INCLUDE_DIRS}") + + add_library(mbedcrypto UNKNOWN IMPORTED) + set_target_properties(mbedcrypto PROPERTIES + IMPORTED_LOCATION "${Mbedcrypto_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Mbedtls_INCLUDE_DIRS}") + + add_library(mbedtls INTERFACE IMPORTED) + set_property(TARGET mbedtls PROPERTY + INTERFACE_LINK_LIBRARIES mbedx509 mbedcrypto) +endif() + +mark_as_advanced(Mbedtls_INCLUDE_DIRS Mbedx509_LIBRARIES Mbedcrypto_LIBRARIES) + +include(FeatureSummary) +set_package_properties(Mbedtls PROPERTIES + URL "https://tls.mbed.org/" + DESCRIPTION "The mbedTLS library") diff --git a/cmake/FindOpen62541.cmake b/cmake/FindOpen62541.cmake new file mode 100644 index 0000000..f6a5bd6 --- /dev/null +++ b/cmake/FindOpen62541.cmake @@ -0,0 +1,50 @@ +#.rst: +# FindOpen62541 +# --------- +# +# Try to locate the open62541 library. +# If found, this will define the following variables: +# +# ``Open62541_FOUND`` +# True if the open62541 library is available +# ``Open62541_INCLUDE_DIRS`` +# The open62541 include directories +# ``Open62541_LIBRARIES`` +# The open62541 libraries for linking +# +# If ``Open62541_FOUND`` is TRUE, it will also define the following +# imported target: +# +# ``open62541`` +# The open62541 library + +find_path(Open62541_INCLUDE_DIRS + NAMES open62541.h + HINTS "${OPEN62541_INCDIR}") + +find_library(Open62541_LIBRARIES + NAMES open62541 + HINTS "${OPEN62541_LIBDIR}") + +if (NOT Open62541_INCLUDE_DIRS STREQUAL "Open62541_INCLUDE_DIRS-NOTFOUND" AND NOT Open62541_LIBRARIES STREQUAL "Open62541_LIBRARIES-NOTFOUND") + set(Open62541_FOUND ON) +endif() + +if (Open62541_FOUND) + add_library(open62541 UNKNOWN IMPORTED) + set_target_properties(open62541 PROPERTIES + IMPORTED_LOCATION "${Open62541_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Open62541_INCLUDE_DIRS}") + + if (win32) + set_property(TARGET open62541 APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ws2_32) + endif() +endif() + +mark_as_advanced(Open62541_INCLUDE_DIRS Open62541_LIBRARIES) + +include(FeatureSummary) +set_package_properties(Open62541 PROPERTIES + URL "https://open62541.org" + DESCRIPTION "Open62541 OPC UA library") diff --git a/cmake/FindUacpp.cmake b/cmake/FindUacpp.cmake new file mode 100644 index 0000000..3b5ec40 --- /dev/null +++ b/cmake/FindUacpp.cmake @@ -0,0 +1,170 @@ +#.rst: +# FindUacpp +# --------- +# +# Try to locate the uacpp library. +# If found, this will define the following variables: +# +# ``Uacpp_FOUND`` +# True if the mbedtls library is available +# ``Uacpp_INCLUDE_DIRS`` +# The mbedTLS include directories +# ``Mbedx509_LIBRARIES`` +# The mbedx509 library for linking +# ``Mbedcrypto_LIBRARIES`` +# The mbedcrypto library for linking +# +# If ``Uacpp_FOUND`` is TRUE, it will also define the following +# imported targets: +# +# ``uacpp`` +# An interface library combining the uacpp libraries + +find_path(Uabasecpp_INCLUDE_DIRS + NAMES uaplatformlayer.h + HINTS "${UACPP_PREFIX}/include" + PATH_SUFFIXES "uabasecpp") + +find_path(Uastack_INCLUDE_DIRS + NAMES opcua_platformdefs.h + HINTS "${UACPP_PREFIX}/include" + PATH_SUFFIXES "uastack") + +find_path(Uaclientcpp_INCLUDE_DIRS + NAMES uaclientsdk.h + HINTS "${UACPP_PREFIX}/include" + PATH_SUFFIXES "uaclientcpp") + +find_path(Uapkicpp_INCLUDE_DIRS + NAMES uapkicertificate.h + HINTS "${UACPP_PREFIX}/include" + PATH_SUFFIXES "uapkicpp") + +find_path(Xmlparsercpp_INCLUDE_DIRS + NAMES opcua_xml_parser.h + HINTS "${UACPP_PREFIX}/include" + PATH_SUFFIXES "xmlparsercpp") + +# Use the release or debug libs depending on the build type +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + find_library(Uaclientcpp_LIBRARIES + NAMES uaclientcppd + HINTS "${UACPP_PREFIX}/lib") + + find_library(Uabasecpp_LIBRARIES + NAMES uabasecppd + HINTS "${UACPP_PREFIX}/lib") + + find_library(Uastack_LIBRARIES + NAMES uastackd + HINTS "${UACPP_PREFIX}/lib") + + find_library(Uapkicpp_LIBRARIES + NAMES uapkicppd + HINTS "${UACPP_PREFIX}/lib") + + find_library(Xmlparsercpp_LIBRARIES + NAMES xmlparsercppd + HINTS "${UACPP_PREFIX}/lib") +else() + find_library(Uaclientcpp_LIBRARIES + NAMES uaclientcpp + HINTS "${UACPP_PREFIX}/lib") + + find_library(Uabasecpp_LIBRARIES + NAMES uabasecpp + HINTS "${UACPP_PREFIX}/lib") + + find_library(Uastack_LIBRARIES + NAMES uastack + HINTS "${UACPP_PREFIX}/lib") + + find_library(Uapkicpp_LIBRARIES + NAMES uapkicpp + HINTS "${UACPP_PREFIX}/lib") + + find_library(Xmlparsercpp_LIBRARIES + NAMES xmlparsercpp + HINTS "${UACPP_PREFIX}/lib") +endif() + +if (NOT Uaclientcpp_INCLUDE_DIRS STREQUAL "Uaclientcpp_INCLUDE_DIRS-NOTFOUND" + AND NOT Uabasecpp_INCLUDE_DIRS STREQUAL "Uabasecpp_INCLUDE_DIRS-NOTFOUND" + AND NOT Uastack_INCLUDE_DIRS STREQUAL "Uastack_INCLUDE_DIRS-NOTFOUND" + AND NOT Uapkicpp_INCLUDE_DIRS STREQUAL "Uapkicpp_INCLUDE_DIRS-NOTFOUND" + AND NOT Xmlparsercpp_INCLUDE_DIRS STREQUAL "Xmlparsercpp_LIBRARIES-NOTFOUND" + AND NOT Uaclientcpp_LIBRARIES STREQUAL "Uaclientcpp_LIBRARIES-NOTFOUND" + AND NOT Uabasecpp_LIBRARIES STREQUAL "Uabasecpp_LIBRARIES-NOTFOUND" + AND NOT Uastack_LIBRARIES STREQUAL "Uastack_LIBRARIES-NOTFOUND" + AND NOT Uapkicpp_LIBRARIES STREQUAL "Uapkicpp_LIBRARIES-NOTFOUND" + AND NOT Xmlparsercpp_LIBRARIES STREQUAL "Xmlparsercpp_LIBRARIES-NOTFOUND") + set(Uacpp_FOUND ON) +endif() + +if (Uacpp_FOUND) + add_library(uaclientcpp UNKNOWN IMPORTED) + set_target_properties(uaclientcpp PROPERTIES + IMPORTED_LOCATION "${Uaclientcpp_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Uaclientcpp_INCLUDE_DIRS}") + + add_library(uabasecpp UNKNOWN IMPORTED) + set_target_properties(uabasecpp PROPERTIES + IMPORTED_LOCATION "${Uabasecpp_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Uabasecpp_INCLUDE_DIRS}") + + add_library(uastack UNKNOWN IMPORTED) + set_target_properties(uastack PROPERTIES + IMPORTED_LOCATION "${Uastack_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Uastack_INCLUDE_DIRS}") + + add_library(uapkicpp UNKNOWN IMPORTED) + set_target_properties(uapkicpp PROPERTIES + IMPORTED_LOCATION "${Uapkicpp_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Uapkicpp_INCLUDE_DIRS}") + + add_library(xmlparsercpp UNKNOWN IMPORTED) + set_target_properties(xmlparsercpp PROPERTIES + IMPORTED_LOCATION "${Xmlparsercpp_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Xmlparsercpp_INCLUDE_DIRS}") + + add_library(uacpp INTERFACE IMPORTED) + set_property(TARGET uacpp PROPERTY + INTERFACE_LINK_LIBRARIES uaclientcpp uabasecpp uastack uapkicpp xmlparsercpp) + + if (win32) + if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + SET(UACPP_ARCHDIR "win64") + else() + SET(UACPP_ARCHDIR "win32") + endif() + + find_library(Libxml2_LIBRARIES + NAMES libxml2 + HINTS "${UACPP_PREFIX}/third-party/${UACPP_ARCHDIR}/vs2015/libxml2/out32dll") + + if (NOT Libxml2_LIBRARIES STREQUAL "Libxml2_LIBRARIES-NOTFOUND") + add_library(libxml2 UNKNOWN IMPORTED) + set_target_properties(libxml2 PROPERTIES + IMPORTED_LOCATION "${Libxml2_LIBRARIES}") + endif() + endif() + + if (win32) + set_property(TARGET uacpp APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Crypt32 Ole32 OleAut32 ws2_32 libeay32 libxml2) + else() + set_property(TARGET uacpp APPEND PROPERTY + INTERFACE_LINK_LIBRARIES crypto ssl xml2) + endif() +endif() + +mark_as_advanced(Uaclientcpp_INCLUDE_DIRS Uaclientcpp_LIBRARIES + Uabasecpp_INCLUDE_DIRS Uabasecpp_LIBRARIES + Uastack_INCLUDE_DIRS Uastack_LIBRARIES + Uapkicpp_INCLUDE_DIRS Uapkicpp_LIBRARIES + Xmlparsercpp_INCLUDE_DIRS Xmlparsercpp_LIBRARIES) + +include(FeatureSummary) +set_package_properties(Uacpp PROPERTIES + URL "https://www.unified-automation.com/products/server-sdk/c-ua-server-sdk.html" + DESCRIPTION "The Unified Automation C++ OPC UA SDK") |