-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
156 lines (125 loc) · 3.63 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
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
cmake_minimum_required(VERSION 3.1)
project(stltracking)
#
# common directories
#
set(stltracking_ROOT ${PROJECT_SOURCE_DIR})
set(stltracking_EXT_ROOT ${stltracking_ROOT}/ext)
if (WIN32)
set(extra_INCLUDE ${stltracking_ROOT}/ext)
else()
set(extra_INCLUDE ${stltracking_ROOT}/ext)
endif()
#
# common compiler settings
#
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
#add_compile_options(-std=c++11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# enable all warnings and treat warnings as errors
add_compile_options(-Wall -Werror -pedantic -Wno-unused-function)
# always enable debugging symbols
add_compile_options(-g)
elseif (MSVC)
# generic preprocessor definitions
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# config-specific preprocessor definitions
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:Debug>:_DEBUG>
$<$<CONFIG:Debug>:_ITERATOR_DEBUG_LEVEL=2>
)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:Release>:NDEBUG>
)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:RelWithDebInfo>:NDEBUG>
$<$<CONFIG:RelWithDebInfo>:DBGREL>
)
# enable all warnings and treat warnings as errors
add_compile_options(/W4 /WX)
# set static runtime libs in all configurations
# enable multiprocessor build in release config
add_compile_options(
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:Release>:/MP>
)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
)
add_compile_options(
$<$<CONFIG:RelWithDebInfo>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MP>
$<$<CONFIG:RelWithDebInfo>:/INCREMENTAL:NO>
$<$<CONFIG:RelWithDebInfo>:/Zi>
$<$<CONFIG:RelWithDebInfo>:/Zo>
)
endif()
#
# sources
#
file (GLOB_RECURSE stltracking_EXTERNAL_SOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
ext/stltracking/*.h
ext/stltracking/*.hpp
ext/stltracking/*.cpp
)
set(Shared_SOURCES
)
if (WIN32)
set(Platform_SOURCES
)
else()
set(Platform_SOURCES
)
endif()
set(stltracking_SOURCES
app/stltracking/main.cpp
)
#message("External sources:\n${stltracking_EXTERNAL_SOURCES}")
# deal with subdirectories in external sources
foreach(source IN LISTS stltracking_EXTERNAL_SOURCES)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "/" "\\" source_path_msvc "${source_path}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
# deal with subdirectories in sources
foreach(source IN LISTS stltracking_SOURCES)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "/" "\\" source_path_msvc "${source_path}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
#
# executable target
#
add_executable(stltracking
${stltracking_EXTERNAL_SOURCES}
${stltracking_SOURCES}
${Platform_SOURCES}
${Shared_SOURCES}
)
target_include_directories(stltracking PUBLIC
${stltracking_EXT_ROOT}
${stltracking_EXT_ROOT}/stltracking
${stltracking_ROOT}/include
${extra_INCLUDE}
)
if (WIN32)
target_link_libraries(stltracking
)
else()
target_link_libraries(stltracking
-ldl
-lpthread
)
endif()
set(stltracking_BIN_DIR ${stltracking_ROOT}/bin)
if (stltracking_BUILD_PLATFORM)
set(stltracking_BIN_DIR ${stltracking_BIN_DIR}/${stltracking_BUILD_PLATFORM})
endif()
if (CMAKE_BUILD_TYPE)
set(stltracking_BIN_DIR ${stltracking_BIN_DIR}/${CMAKE_BUILD_TYPE})
endif()
set_target_properties(stltracking
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${stltracking_BIN_DIR}
)