forked from bazza2jw/open62541Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
63 lines (47 loc) · 1.85 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
cmake_minimum_required(VERSION 3.5)
## project name
project(open62541cpp)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
## library name
set(OPEN62541_CPP open62541cpp)
## build settings - try and match the c library version
set(VERSION_MAJOR 1)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)
set(PACKAGE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
## Set the UA log level.
# IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
# add_definitions(-DUA_LOGLEVEL=100)
# ELSE()
# add_definitions(-DUA_LOGLEVEL=500)
# ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
## --- Build options ---
set(BUILD_EXAMPLES FALSE CACHE BOOL "Build example programs")
## --- C++17 build flags ---
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(INCLUDE_INSTALL_DIR include)
set(LIB_INSTALL_DIR lib)
set(UA_CPP_SANITIZE ON)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND UA_CPP_SANITIZE AND
"x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")
# Add default sanitizer settings when using clang and Debug build.
# This allows e.g. CLion to find memory locations for SegFaults
message(STATUS "Sanitizer enabled")
set(SANITIZER_FLAGS "-g -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=leak -fsanitize=undefined")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize-coverage=trace-pc-guard")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
endif()
## include directories
include_directories(include)
add_subdirectory(src)
add_subdirectory(include)
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()