-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1765: CMake: make
set_darma_compiler_flags
a function
- Loading branch information
Showing
1 changed file
with
28 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
# Call this from all CMakeLists.txt files that can be built independently. | ||
|
||
macro(set_darma_compiler_flags vt_target) | ||
|
||
if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") | ||
# 4.9.3 complains about std::min not being constexpr | ||
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5)) | ||
message("${PROJECT_NAME} currently requires g++ 5 or greater. If you need it to work with 4.9, please complain.") | ||
endif () | ||
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -ftemplate-depth=900) | ||
if (APPLE) | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -stdlib=libc++) | ||
function(set_darma_compiler_flags vt_target) | ||
if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") | ||
# 4.9.3 complains about std::min not being constexpr | ||
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5)) | ||
message("${PROJECT_NAME} currently requires g++ 5 or greater. If you need it to work with 4.9, please complain.") | ||
endif () | ||
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -ftemplate-depth=900) | ||
if (APPLE) | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -stdlib=libc++) | ||
endif () | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2021.3.0) | ||
list(APPEND TARGET_PRIVATE_CXX_FLAGS -fhonor-infinites -fhonor-nans) | ||
elseif (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Intel") | ||
message(FATAL_ERROR "Your C++ compiler may not support C++14.") | ||
endif () | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2021.3.0) | ||
list(APPEND TARGET_PRIVATE_CXX_FLAGS -fhonor-infinites -fhonor-nans) | ||
elseif (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Intel") | ||
message(FATAL_ERROR "Your C++ compiler may not support C++14.") | ||
endif () | ||
|
||
if ("${vt_target}" STREQUAL "${VIRTUAL_TRANSPORT_LIBRARY}") | ||
if (vt_asan_enabled) | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls) | ||
endif() | ||
if ("${vt_target}" STREQUAL "${VIRTUAL_TRANSPORT_LIBRARY}") | ||
if (vt_asan_enabled) | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls) | ||
endif() | ||
|
||
if (vt_ubsan_enabled) | ||
add_definitions(-DVT_UBSAN_ENABLED) | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=undefined -fno-omit-frame-pointer) | ||
if (vt_ubsan_enabled) | ||
add_definitions(-DVT_UBSAN_ENABLED) | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=undefined -fno-omit-frame-pointer) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
message(DEBUG "Target ${vt_target} public compile options: ${TARGET_PUBLIC_CXX_FLAGS}") | ||
target_compile_options(${vt_target} PUBLIC ${TARGET_PUBLIC_CXX_FLAGS}) | ||
|
||
message(DEBUG "Target ${vt_target} private compile options: ${TARGET_PRIVATE_CXX_FLAGS}") | ||
target_compile_options(${vt_target} PRIVATE ${TARGET_PRIVATE_CXX_FLAGS}) | ||
message(DEBUG "Target ${vt_target} public compile options: ${TARGET_PUBLIC_CXX_FLAGS}") | ||
target_compile_options(${vt_target} PUBLIC ${TARGET_PUBLIC_CXX_FLAGS}) | ||
|
||
endmacro() | ||
message(DEBUG "Target ${vt_target} private compile options: ${TARGET_PRIVATE_CXX_FLAGS}") | ||
target_compile_options(${vt_target} PRIVATE ${TARGET_PRIVATE_CXX_FLAGS}) | ||
endfunction() |