forked from Manu343726/ctti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
61 lines (44 loc) · 1.58 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
project(ctti)
cmake_minimum_required(VERSION 2.8)
option(CTTI_BUILD_TESTS "Build ctti feature tests" OFF)
option(CTTI_BUILD_EXAMPLES "Build ctti examples" ON)
include(cmake/vs_source_groups.cmake)
set(CTTI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
function(ctti_target prefix name)
# To see the headers in the solution...
if(MSVC)
generate_vs_source_groups(${prefix}s ${CTTI_SOURCE_DIR}/${prefix}s ${prefix}_files)
generate_vs_source_groups(include ${CTTI_SOURCE_DIR}/include ctti_files)
endif()
add_executable(${prefix}_${name} ${CTTI_SOURCE_DIR}/${prefix}s/${name}.cpp
${${prefix}_files} ${ctti_files}
)
target_compile_options(${prefix}_${name} PRIVATE
${CTTI_GLOBAL_ALL_COMPILE_OPTIONS}
${CTTI_${prefix}_ALL_COMPILE_OPTIONS}
$<$<CONFIG:Debug>:${CTTI_GLOBAL_DEBUG_COMPILE_OPTIONS}>
$<$<CONFIG:Release>:${CTTI_GLOBAL_RELEASE_COMPILE_OPTIONS}>
$<$<CONFIG:Debug>:${CTTI_${prefix}_DEBUG_COMPILE_OPTIONS}>
$<$<CONFIG:Release>:${CTTI_${prefix}_RELEASE_COMPILE_OPTIONS}>
)
target_include_directories(${prefix}_${name} PRIVATE
${CTTI_SOURCE_DIR}/include/ # ctti headers
${CTTI_SOURCE_DIR}/${prefix}s/include/ # examples/tests extra includes
)
endfunction()
function(ctti_example example_name)
ctti_target(example "${example_name}")
endfunction()
function(ctti_test test_name)
ctti_target(test "${example_name}")
endfunction()
if(NOT MSVC)
set(CTTI_GLOBAL_ALL_COMPILE_OPTIONS -std=c++11)
endif()
include_directories(include)
if(CTTI_BUILD_TESTS)
add_subdirectory(tests)
endif()
if(CTTI_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()