summaryrefslogtreecommitdiffstats
path: root/cmake/FindUacpp.cmake
blob: 32a95c8c1203b667e04709f979dadd716fd8b091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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")