-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
77 lines (64 loc) · 2.54 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
#=========================================================================
#
# Copyright Niels Dekker, LKEB, Leiden University Medical Center
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#=========================================================================
# Note: VERSION 3.13 would be preferable, as it has IPO (LTCG) for VS.
# However, Travis CI (Ubuntu 16.04.6 LTS) still runs CMake 3.12.4,
# at the moment (8 May 2020).
cmake_minimum_required( VERSION 3.12.4 )
project (noexcept_benchmark)
message(STATUS "[${PROJECT_NAME}] CMAKE_VERSION = ${CMAKE_VERSION}")
message(STATUS "[${PROJECT_NAME}] CMAKE_GENERATOR = ${CMAKE_GENERATOR}")
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Release)
else()
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_VERBOSE_MAKEFILE ON)
set(NOEXCEPT_BENCHMARK_THROW_EXCEPTION ON CACHE BOOL "throw_exception_if should throw std::exception{}")
if(NOEXCEPT_BENCHMARK_THROW_EXCEPTION)
set(NOEXCEPT_BENCHMARK_THROW_EXCEPTION_COMPILE_DEFINITION "NOEXCEPT_BENCHMARK_THROW_EXCEPTION=1")
else()
set(NOEXCEPT_BENCHMARK_THROW_EXCEPTION_COMPILE_DEFINITION "NOEXCEPT_BENCHMARK_THROW_EXCEPTION=0")
endif()
file(GLOB SHARED_LIB_SOURCE_FILES lib/*.cpp lib/*.h)
add_library(noexcept_lib
SHARED ${SHARED_LIB_SOURCE_FILES})
target_compile_definitions(noexcept_lib PRIVATE
${NOEXCEPT_BENCHMARK_THROW_EXCEPTION_COMPILE_DEFINITION}
SPECIFY_NOEXCEPT=1
)
target_include_directories(noexcept_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_library(implicit_lib
SHARED ${SHARED_LIB_SOURCE_FILES})
target_compile_definitions(implicit_lib PRIVATE
${NOEXCEPT_BENCHMARK_THROW_EXCEPTION_COMPILE_DEFINITION}
SPECIFY_NOEXCEPT=0
)
target_include_directories(implicit_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(${PROJECT_NAME}
${PROJECT_NAME}.h
${PROJECT_NAME}_main.cpp)
target_compile_definitions(${PROJECT_NAME} PRIVATE
${NOEXCEPT_BENCHMARK_THROW_EXCEPTION_COMPILE_DEFINITION}
)
target_link_libraries(${PROJECT_NAME}
noexcept_lib
implicit_lib
)