-
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.
Merge pull request #1613 from DARMA-tasking/1602-refactor-cmake-compi…
…ler-flags #1602: stop using CMAKE_CXX_FLAGS for setting compile options
- Loading branch information
Showing
10 changed files
with
115 additions
and
171 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
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,44 +1,40 @@ | ||
# Compiler-specific C++14 activation. | ||
# Call this from all CMakeLists.txt files that can be built independently. | ||
|
||
macro(set_darma_compiler_flags) | ||
macro(set_darma_compiler_flags vt_target) | ||
|
||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") | ||
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 5 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 5)) | ||
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 () | ||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") | ||
endif() | ||
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=900") | ||
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -ftemplate-depth=900) | ||
if (APPLE) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -DCLI11_EXPERIMENTAL_OPTIONAL=0") | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -stdlib=libc++ -DCLI11_EXPERIMENTAL_OPTIONAL=0) | ||
endif () | ||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCLI11_EXPERIMENTAL_OPTIONAL=0") | ||
endif() | ||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces") | ||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7) | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -DCLI11_EXPERIMENTAL_OPTIONAL=0) | ||
endif() | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2021.3.0) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fhonor-infinites") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fhonor-nans") | ||
elseif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") | ||
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_asan_enabled) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer) | ||
endif() | ||
|
||
if (vt_ubsan_enabled) | ||
add_definitions(-DVT_UBSAN_ENABLED) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") | ||
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=undefined -fno-omit-frame-pointer) | ||
endif() | ||
|
||
message(DEBUG "Target ${vt_target} public compile options: ${TARGET_CXX_FLAGS}") | ||
target_compile_options(${vt_target} PUBLIC ${TARGET_PUBLIC_CXX_FLAGS}) | ||
|
||
message(DEBUG "Target ${vt_target} private compile options: ${TARGET_CXX_FLAGS}") | ||
target_compile_options(${vt_target} PRIVATE ${TARGET_PRIVATE_CXX_FLAGS}) | ||
|
||
endmacro() |
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
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
Oops, something went wrong.