forked from Morwenn/static_math
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
87 lines (70 loc) · 2.82 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
cmake_minimum_required(VERSION 3.0)
project(static_math)
set(CMAKE_CXX_STANDARD 14)
option(STATIC_MATH_BUILD_TESTS "Build the tests them." ON)
option(USE_CCACHE "Use `ccache` if available" ON)
if (NOT CMAKE_BUILD_TYPE)
if(CMAKE_GENERATOR STREQUAL "Xcode")
set(CMAKE_BUILD_TYPE "Debug")
else()
set(CMAKE_BUILD_TYPE "Release")
endif()
message(STATUS "No build type selected, default to ${CMAKE_BUILD_TYPE}")
endif()
if (USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
message(STATUS "Using ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
endif(USE_CCACHE)
set(headers include/static_math/cmath.h
include/static_math/complex.h
include/static_math/constant.h
include/static_math/constants.h
include/static_math/formula.h
include/static_math/rational.h
include/static_math/static_math.h
include/static_math/trigonometry.h
include/static_math/vector.h)
set(detail_headers
include/static_math/detail/can_fit.h
include/static_math/detail/cmath.inl
include/static_math/detail/complex.inl
include/static_math/detail/constant.inl
include/static_math/detail/core.h
include/static_math/detail/formula.inl
include/static_math/detail/parse.h
include/static_math/detail/rational.inl
include/static_math/detail/trigonometry.inl
include/static_math/detail/vector.inl)
install(DIRECTORY include/
DESTINATION include/)
if (STATIC_MATH_BUILD_TESTS)
include(CTest)
enable_testing()
include_directories(./include)
# Generate all of the example parsers
function(build_test test_tgt check_tgt)
# Add executable for the example
add_executable(test-${test_tgt} ${headers} ${detail_headers} test/${test_tgt}.cpp)
add_custom_target(run-test-${test_tgt} COMMAND $<TARGET_FILE:test-${test_tgt}> )
add_test(NAME ${test_tgt}
COMMAND test-${test_tgt})
if(TARGET ${check_tgt})
add_dependencies(${check_tgt} test-${test_tgt})
endif()
endfunction(build_test)
add_custom_target(all_tests ALL)
build_test(cmath all_tests)
build_test(complex all_tests)
build_test(constant all_tests)
build_test(formula all_tests)
build_test(rational all_tests)
build_test(trigonometry all_tests)
build_test(vector all_tests)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" --output-on-failure
DEPENDS all_tests
VERBATIM)
endif()