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
|
# This file provides a special "standard_settings" target which is supposed to
# be linked privately by all other targets.
add_library(standard_settings INTERFACE)
if(MSVC)
target_compile_options(standard_settings INTERFACE "/FI${CMAKE_BINARY_DIR}/config.h")
else()
target_compile_options(
standard_settings
INTERFACE -include ${CMAKE_BINARY_DIR}/config.h
)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$" AND NOT MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(standard_settings INTERFACE _GLIBCXX_ASSERTIONS)
endif()
option(ENABLE_COVERAGE "Enable coverage reporting for GCC/Clang" FALSE)
if(ENABLE_COVERAGE)
target_compile_options(standard_settings INTERFACE --coverage -O0 -g)
target_link_libraries(standard_settings INTERFACE --coverage)
endif()
set(SANITIZERS "")
option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" FALSE)
if(ENABLE_SANITIZER_ADDRESS)
list(APPEND SANITIZERS "address")
endif()
option(ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" FALSE)
if(ENABLE_SANITIZER_MEMORY)
list(APPEND SANITIZERS "memory")
endif()
option(
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
"Enable undefined behavior sanitizer"
FALSE)
if(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR)
list(APPEND SANITIZERS "undefined")
endif()
option(ENABLE_SANITIZER_THREAD "Enable thread sanitizer" FALSE)
if(ENABLE_SANITIZER_THREAD)
list(APPEND SANITIZERS "thread")
endif()
foreach(SANITIZER IN LISTS SANITIZERS)
target_compile_options(
standard_settings
INTERFACE -fsanitize=${SANITIZER})
target_link_libraries(
standard_settings
INTERFACE -fsanitize=${SANITIZER})
endforeach()
include(StdAtomic)
include(StdFilesystem)
elseif(MSVC AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(standard_settings INTERFACE
/Zc:__cplusplus
$<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,19.25>:/Zc:preprocessor>
/utf-8
)
endif()
if(WIN32)
target_compile_definitions(
standard_settings
INTERFACE WIN32_LEAN_AND_MEAN _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS
)
endif()
|