forked from umati/Dashboard-OPCUA-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
118 lines (96 loc) · 5.03 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.9)
message("### opcua_dashboardclient: loading project")
project(Dashboard_OpcUaClient)
enable_testing()
set(CMAKE_CXX_STANDARD 14)
message("########################### CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
message("########################### CREATE_COVERAGE=${CREATE_COVERAGE}")
if (CREATE_COVERAGE)
message("########################### COVERAGE enabled")
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-lgcov --coverage -fprofile-arcs -ftest-coverage")
SET(CMAKE_CXX_FLAGS "${GCC_COVERAGE_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "${GCC_COVERAGE_COMPILE_FLAGS} ${CMAKE_C_FLAGS}")
endif ()
message("########################### MEMORY_SANITZER=${MEMORY_SANITZER}")
if (MEMORY_SANITZER)
message("########################### MEMORY_SANITZER enabled")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -fno-omit-frame-pointer -fsanitize=leak")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -g -fno-omit-frame-pointer -fsanitize=leak")
endif ()
message("### opcua_dashboardclient: adding cmake files to find used libraries from /cmake directory")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
message("### opcua_dashboardclient: Set common directories for all executables in this project")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
message("### opcua_dashboardclient: Adding the target")
add_custom_target(Dashboard_OpcUaClient)
add_definitions(-DELPP_THREAD_SAFE -DELPP_USE_STD_THREADING -DELPP_NO_DEFAULT_LOG_FILE)
find_package(easyloggingpp REQUIRED)
find_package(open62541 REQUIRED)
find_package(Open62541Cpp REQUIRED)
find_package(Threads REQUIRED)
include_directories(${CPP_MOSQUITTO_INCLUDE})
message("### opcua_dashboardclient: Adding subdirectories")
add_subdirectory(Util)
add_subdirectory(ModelOpcUa)
add_subdirectory(DashboardClient)
add_subdirectory(OpcUaClient)
add_subdirectory(MachineObserver)
message("### opcua_dashboardclient: Adding test directory")
#add_subdirectory(Tests)
message("### opcua_dashboardclient: Adding the executable c++ file")
find_package(Threads)
add_executable(DashboardOpcUaClient Main.cpp DashboardOpcUaClient.cpp)
message("### opcua_dashboardclient: Setting Dashboard Publisher")
target_link_libraries(DashboardOpcUaClient PUBLIC OpcUaClientLib)
target_link_libraries(DashboardOpcUaClient PUBLIC MachineObserver)
set(DASHBOARD_PUBLISHER "MQTT_PAHO" CACHE STRING "Publisher Backend")
set_property(CACHE DASHBOARD_PUBLISHER PROPERTY STRINGS MQTT_MOSQUITTO MQTT_PAHO REDIS)
if (DASHBOARD_PUBLISHER STREQUAL "MQTT_MOSQUITTO")
message("### opcua_dashboardclient: Adding Publisher mosquitto")
add_subdirectory(MqttPublisher)
target_compile_definitions(DashboardOpcUaClient PUBLIC PUBLISHER_MQTT_MOSQUITTO=1)
target_link_libraries(DashboardOpcUaClient PUBLIC MqttPublisher)
endif ()
message("### OpenSSL Library Found:" ${PAHO_WITH_SSL})
if (PAHO_WITH_SSL)
set(OPENSSL_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
find_package(OpenSSL REQUIRED)
message("### OpenSSL Library Found: " ${OPENSSL_FOUND})
message("### OpenSSL Library Path: " ${OPENSSL_SSL_LIBRARY})
message("### OpenSSL Crypto Library Path: " ${OPENSSL_CRYPTO_LIBRARY})
message("### OpelSSL Include Dir: " ${OPENSSL_INCLUDE_DIR})
endif()
if (DASHBOARD_PUBLISHER STREQUAL "MQTT_PAHO")
# Promote target PahoMqttC::PahoMqttC for dll copy
message("### opcua_dashboardclient: Adding Publisher paho")
find_package(PahoMqttCpp REQUIRED)
add_subdirectory(MqttPublisher_Paho)
target_compile_definitions(DashboardOpcUaClient PUBLIC PUBLISHER_MQTT_PAHO=1)
target_link_libraries(DashboardOpcUaClient PUBLIC MqttPublisher_Paho)
target_compile_definitions(DashboardOpcUaClient PUBLIC NOMINMAX)
endif ()
message("### opcua_dashboardclient: Adding custom command to copy the example config")
add_custom_command(TARGET DashboardOpcUaClient POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
configuration.json.example
$<TARGET_FILE_DIR:DashboardOpcUaClient>
COMMENT "Copy Example Configuration"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
message("### opcua_dashboardclient: Installing DashboardOpcUaClient targets")
install(TARGETS DashboardOpcUaClient EXPORT DashboardOpcUaClient RUNTIME DESTINATION bin)
set(CERTGEN_INSTALL_FILES
Tools/certGen/createCertificate.py
Tools/certGen/openssl.cnf.jinja2
Tools/certGen/pki.json
Tools/certGen/README.md
Tools/certGen/requirements.txt
Tools/certGen/settings.template.json
)
install(FILES ${CERTGEN_INSTALL_FILES} DESTINATION bin/Tools/certGen)
target_link_libraries(DashboardOpcUaClient PUBLIC Threads::Threads Open62541Cpp::Open62541Cpp)
message("### opcua_dashboardclient: Exporting DashboardOpcUaClient")
install(EXPORT DashboardOpcUaClient DESTINATION lib/DashboardOpcUaClient/cmake NAMESPACE DashboardOpcUaClient:: EXPORT_LINK_INTERFACE_LIBRARIES)