]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
2 | ||
3 | # Generated by `boostdep --cmake safe_numerics` | |
4 | # Copyright 2020, 2021 Peter Dimov | |
5 | # Distributed under the Boost Software License, Version 1.0. | |
6 | # https://www.boost.org/LICENSE_1_0.txt | |
7 | ||
8 | cmake_minimum_required(VERSION 3.8...3.20) | |
9 | ||
10 | project(boost_safe_numerics VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) | |
11 | ||
12 | add_library(boost_safe_numerics INTERFACE) | |
13 | add_library(Boost::safe_numerics ALIAS boost_safe_numerics) | |
14 | ||
15 | target_include_directories(boost_safe_numerics INTERFACE include) | |
16 | ||
17 | target_link_libraries(boost_safe_numerics | |
18 | INTERFACE | |
19 | Boost::concept_check | |
20 | Boost::config | |
21 | Boost::core | |
22 | Boost::integer | |
23 | Boost::logic | |
24 | Boost::mp11 | |
25 | ) | |
26 | ||
27 | target_compile_features(boost_safe_numerics INTERFACE cxx_std_14) | |
28 | ||
29 | else() | |
30 | ||
92f5a8d4 TL |
31 | # CMake build control file for safe numerics Library Examples |
32 | ||
33 | cmake_minimum_required(VERSION 3.8.6) | |
34 | ||
35 | project("SafeIntegers") | |
36 | enable_language(CXX) | |
37 | ||
38 | ######################################################## | |
39 | # Create interface library | |
40 | # | |
41 | add_library(boost_safe_numerics INTERFACE) | |
42 | add_library(Boost::safe_numerics ALIAS boost_safe_numerics) | |
43 | ||
44 | target_include_directories(boost_safe_numerics INTERFACE "${Boost_INCLUDE_DIRS}") | |
45 | target_compile_features(boost_safe_numerics INTERFACE cxx_std_14) | |
46 | ||
47 | ######################################################## | |
48 | # Compiler settings - special settings for known compilers | |
49 | # | |
50 | ||
51 | set(CMAKE_CXX_STANDARD 14) | |
52 | set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
53 | set(CMAKE_CXX_EXTENSIONS OFF) | |
54 | ||
55 | message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" ) | |
56 | ||
57 | if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) | |
f67539c2 | 58 | add_compile_options(-Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wall -Wextra -W -Wshadow -Wsign-compare ) |
20effc67 | 59 | add_compile_options( -ftemplate-depth=255 ) |
92f5a8d4 | 60 | elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" ) |
f67539c2 | 61 | # warning level 4 and all warnings as errors |
20effc67 | 62 | add_compile_options(/W4 /WX /wd4996 /wd4068) |
92f5a8d4 | 63 | elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) |
f67539c2 | 64 | add_compile_options(-Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wall -Wextra -W -Wshadow -Wsign-compare ) |
20effc67 TL |
65 | add_compile_options( -ftemplate-depth=255 ) |
66 | add_compile_options( -fbracket-depth=2048 ) | |
f67539c2 | 67 | elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) |
f67539c2 | 68 | add_compile_options(-Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wall -Wextra -W -Wshadow -Wsign-compare ) |
20effc67 TL |
69 | add_compile_options( -ftemplate-depth=255 ) |
70 | add_compile_options( -fbracket-depth=2048 ) | |
92f5a8d4 TL |
71 | endif() |
72 | ||
73 | # | |
74 | # Project settings | |
75 | # | |
76 | ||
77 | find_package(Boost ) | |
78 | ||
79 | if(Boost_FOUND) | |
80 | if( CMAKE_HOST_APPLE ) | |
81 | set(Boost_ADDRESS_MODEL 64 CACHE STRING "32/64 bits") | |
82 | endif() | |
83 | message(STATUS "Boost directories found at ${Boost_INCLUDE_DIRS}") | |
84 | message(STATUS "Boost version found is ${Boost_VERSION}") | |
85 | include_directories("${Boost_INCLUDE_DIRS}") # note: sets header search path? | |
86 | elseif() | |
87 | message("Boost NOT Found!") | |
88 | endif() | |
89 | ||
90 | message(STATUS "include directories are:" ) | |
91 | get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) | |
92 | foreach(dir ${dirs}) | |
93 | message(STATUS " ${dir}") | |
94 | endforeach() | |
95 | ||
96 | #use folders in organization of the IDE | |
97 | set(USE_FOLDERS TRUE) | |
98 | ||
99 | ########################### | |
100 | # testing and submitting test results to the test dashboard | |
101 | ||
102 | if(0) | |
103 | ||
104 | ## Create a file named CTestConfig.cmake adjacent to the current file. | |
105 | ## This new file should contain the following: | |
106 | ||
107 | set(CTEST_PROJECT_NAME "Safe Numerics") | |
108 | set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") | |
109 | ||
110 | set(CTEST_DROP_METHOD "http") | |
111 | set(CTEST_DROP_SITE "my.cdash.org") | |
112 | # set(CTEST_DROP_LOCATION "/cdash/submit.php?project=MyProject") | |
113 | set(CTEST_DROP_LOCATION "/index.php?project=Safe+Numerics") | |
114 | set(CTEST_DROP_SITE_CDASH TRUE) | |
115 | ||
116 | endif() | |
117 | ||
118 | function(test_run_pass base_name ) | |
119 | message(STATUS ${base_name}) | |
120 | add_executable(${base_name} ${base_name}.cpp) | |
121 | add_test(NAME ${base_name} COMMAND ${base_name}) | |
122 | endfunction(test_run_pass) | |
123 | ||
124 | function(test_compile_pass base_name ) | |
125 | message(STATUS ${base_name} - compile only) | |
126 | add_library(${base_name} OBJECT ${base_name}) | |
127 | endfunction(test_compile_pass) | |
128 | ||
129 | function(test_compile_fail base_name ) | |
130 | message(STATUS ${base_name}) | |
131 | # Add failing-to-compile targets | |
132 | add_executable(${base_name} ${base_name}.cpp) | |
133 | ||
134 | # Avoid building these targets normally | |
135 | set_target_properties(${base_name} PROPERTIES | |
136 | EXCLUDE_FROM_ALL TRUE | |
137 | EXCLUDE_FROM_DEFAULT_BUILD TRUE | |
138 | ) | |
139 | ||
140 | # Add the tests. These invoke "cmake --build ..." which is a | |
141 | # cross-platform way of building the given target. | |
142 | add_test(NAME ${base_name} | |
143 | COMMAND ${CMAKE_COMMAND} --build . --target ${base_name} --config $<CONFIGURATION> | |
144 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
145 | ) | |
146 | ||
147 | # Expect these tests to fail | |
148 | # (i.e. cmake --build should return a non-zero value) | |
149 | set_tests_properties(${base_name} PROPERTIES WILL_FAIL TRUE) | |
150 | endfunction( test_compile_fail base_name ) | |
151 | ||
152 | ######################################################## | |
153 | # End Compiler settings | |
154 | # | |
155 | ||
156 | enable_testing() | |
157 | ||
158 | add_subdirectory("include/boost/safe_numerics") | |
159 | add_subdirectory("example") | |
160 | add_subdirectory("test") | |
161 | ||
1e59de90 | 162 | endif() |