forked from foonathan/type_safe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
104 lines (92 loc) · 4.56 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
# Copyright (C) 2016-2017 Jonathan Müller <[email protected]>
# This file is subject to the license terms in the LICENSE file
# found in the top-level directory of this distribution.
cmake_minimum_required(VERSION 3.1)
project(TYPE_SAFE)
include(external/external.cmake)
# options
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(_type_safe_default_assertions ON)
else()
set(_type_safe_default_assertions OFF)
endif()
option(TYPE_SAFE_ENABLE_ASSERTIONS "whether or not to enable internal assertions for the type_safe library" ${_type_safe_default_assertions})
if(${TYPE_SAFE_ENABLE_ASSERTIONS})
set(_type_safe_enable_assertions 1)
else()
set(_type_safe_enable_assertions 0)
endif()
option(TYPE_SAFE_ENABLE_PRECONDITION_CHECKS "whether or not to enable precondition checks" ON)
if(${TYPE_SAFE_ENABLE_PRECONDITION_CHECKS})
set(_type_safe_enable_precondition_checks 1)
else()
set(_type_safe_enable_precondition_checks 0)
endif()
option(TYPE_SAFE_ENABLE_WRAPPER "whether or not the wrappers in types.hpp are used" ON)
if(${TYPE_SAFE_ENABLE_WRAPPER})
set(_type_safe_enable_wrapper 1)
else()
set(_type_safe_enable_wrapper 0)
endif()
option(TYPE_SAFE_ARITHMETIC_UB "whether or not the undefined_behavior_arithmetic policy is used" ON)
if(${TYPE_SAFE_ARITHMETIC_UB})
set(_type_safe_arithmetic_ub 1)
else()
set(_type_safe_arithmetic_ub 0)
endif()
# interface target
set(detail_header_files
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/aligned_union.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/all_of.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/assert.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/assign_or_construct.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/copy_move_control.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/force_inline.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/is_nothrow_swappable.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/detail/variant_impl.hpp)
set(header_files
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/config.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/arithmetic_policy.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/boolean.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/bounded_type.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/compact_optional.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/constrained_type.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/deferred_construction.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/downcast.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/flag.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/floating_point.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/index.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/integer.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/narrow_cast.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/optional.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/optional_ref.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/output_parameter.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/reference.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/strong_typedef.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/tagged_union.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/types.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/variant.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/type_safe/visitor.hpp)
add_library(type_safe INTERFACE)
target_sources(type_safe INTERFACE ${detail_header_files} ${header_files})
target_include_directories(type_safe INTERFACE include/)
target_compile_definitions(type_safe INTERFACE
TYPE_SAFE_ENABLE_ASSERTIONS=${_type_safe_enable_assertions}
TYPE_SAFE_ENABLE_PRECONDITION_CHECKS=${_type_safe_enable_precondition_checks}
TYPE_SAFE_ENABLE_WRAPPER=${_type_safe_enable_wrapper}
TYPE_SAFE_ARITHMETIC_UB=${_type_safe_arithmetic_ub})
target_link_libraries(type_safe INTERFACE debug_assert)
if(MSVC)
target_compile_options(type_safe INTERFACE /wd4800) # truncation to bool warning
endif()
# other subdirectories
# only add if not inside add_subdirectory()
option(TYPE_SAFE_BUILD_TEST_EXAMPLE "build test and example" OFF)
if(${TYPE_SAFE_BUILD_TEST_EXAMPLE} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
add_subdirectory(example/)
add_subdirectory(test/)
endif()
option(TYPE_SAFE_BUILD_DOC "generate documentation" OFF)
if(TYPE_SAFE_BUILD_DOC)
add_subdirectory(doc/)
endif()