blob: 348a71b5372fd339092716896419d1d25905e5ff (
plain)
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
|
# CMake build control file for safe numerics Library Examples
cmake_minimum_required(VERSION 3.8.6)
project("SafeIntegers")
enable_language(CXX)
########################################################
# Create interface library
#
add_library(boost_safe_numerics INTERFACE)
add_library(Boost::safe_numerics ALIAS boost_safe_numerics)
target_include_directories(boost_safe_numerics INTERFACE "${Boost_INCLUDE_DIRS}")
target_compile_features(boost_safe_numerics INTERFACE cxx_std_14)
########################################################
# Compiler settings - special settings for known compilers
#
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" )
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
add_definitions( -ftemplate-depth=300 )
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
add_definitions( /wd4996 )
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
add_definitions( -ftemplate-depth=300 )
add_compile_options(-Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wall -W -Wshadow -Wsign-compare )
endif()
#
# Project settings
#
find_package(Boost )
if(Boost_FOUND)
if( CMAKE_HOST_APPLE )
set(Boost_ADDRESS_MODEL 64 CACHE STRING "32/64 bits")
endif()
message(STATUS "Boost directories found at ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost version found is ${Boost_VERSION}")
include_directories("${Boost_INCLUDE_DIRS}") # note: sets header search path?
elseif()
message("Boost NOT Found!")
endif()
message(STATUS "include directories are:" )
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS " ${dir}")
endforeach()
#use folders in organization of the IDE
set(USE_FOLDERS TRUE)
###########################
# testing and submitting test results to the test dashboard
if(0)
## Create a file named CTestConfig.cmake adjacent to the current file.
## This new file should contain the following:
set(CTEST_PROJECT_NAME "Safe Numerics")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
# set(CTEST_DROP_LOCATION "/cdash/submit.php?project=MyProject")
set(CTEST_DROP_LOCATION "/index.php?project=Safe+Numerics")
set(CTEST_DROP_SITE_CDASH TRUE)
endif()
function(test_run_pass base_name )
message(STATUS ${base_name})
add_executable(${base_name} ${base_name}.cpp)
add_test(NAME ${base_name} COMMAND ${base_name})
endfunction(test_run_pass)
function(test_compile_pass base_name )
message(STATUS ${base_name} - compile only)
add_library(${base_name} OBJECT ${base_name})
endfunction(test_compile_pass)
function(test_compile_fail base_name )
message(STATUS ${base_name})
# Add failing-to-compile targets
add_executable(${base_name} ${base_name}.cpp)
# Avoid building these targets normally
set_target_properties(${base_name} PROPERTIES
EXCLUDE_FROM_ALL TRUE
EXCLUDE_FROM_DEFAULT_BUILD TRUE
)
# Add the tests. These invoke "cmake --build ..." which is a
# cross-platform way of building the given target.
add_test(NAME ${base_name}
COMMAND ${CMAKE_COMMAND} --build . --target ${base_name} --config $<CONFIGURATION>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# Expect these tests to fail
# (i.e. cmake --build should return a non-zero value)
set_tests_properties(${base_name} PROPERTIES WILL_FAIL TRUE)
endfunction( test_compile_fail base_name )
########################################################
# End Compiler settings
#
enable_testing()
add_subdirectory("include/boost/safe_numerics")
add_subdirectory("example")
add_subdirectory("test")
|