-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
90 lines (73 loc) · 2.08 KB
/
CMakeLists.txt
File metadata and controls
90 lines (73 loc) · 2.08 KB
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
# General project setup and options
project(
protean HOMEPAGE_URL https://github.com/proteanic/protean LANGUAGES CXX)
cmake_minimum_required(
VERSION 3.0)
option(
ENABLE_XML_SUPPORT "Enable support for converting to/from XML representation" ON)
option(
ENABLE_TESTS "Enable tests" ON)
option(
BOOST_STATIC_LINK_PATH "Force required Boost libs to be statically linked using this location" "")
set(
CMAKE_CXX_STANDARD 11)
set(
CMAKE_CXX_STANDARD_REQUIRED ON)
string(
REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(
CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
endif()
# Common compiler / linker setup
find_package(
Boost REQUIRED COMPONENTS iostreams)
include_directories(
SYSTEM ${Boost_INCLUDE_DIRS})
add_compile_options(
-fdata-sections -ffunction-sections -Wno-deprecated-declarations -Wno-multichar)
if(NOT ENABLE_XML_SUPPORT)
add_compile_definitions(
PROTEAN_DISABLE_XML)
endif()
# Platform-specific compiler / linker setup (including setting up variables for later use)
if(APPLE)
add_link_options(
-Wl,-dead_strip)
else()
add_link_options(
-Wl,--gc-sections -Wl,--no-undefined)
endif()
# Target libprotean
file(
GLOB_RECURSE LibSourceFiles
CONFIGURE_DEPENDS
"src/*.cpp")
add_library(
protean SHARED ${LibSourceFiles})
set_target_properties(
protean PROPERTIES BUILD_RPATH_USE_ORIGIN TRUE)
target_include_directories(
protean PUBLIC .)
target_link_libraries(
protean PUBLIC Boost::iostreams z)
if(ENABLE_XML_SUPPORT)
target_link_libraries(
protean PUBLIC xerces-c)
endif()
# Target protean_test
if(ENABLE_TESTS)
enable_testing()
find_package(
Boost REQUIRED COMPONENTS unit_test_framework)
file(
GLOB_RECURSE TestSourceFiles
CONFIGURE_DEPENDS
"test/*.cpp")
add_executable(
protean_test ${TestSourceFiles})
target_compile_definitions(
protean_test PRIVATE BOOST_TEST_DYN_LINK)
target_link_libraries(
protean_test PRIVATE protean Boost::unit_test_framework)
endif()