Skip to content

Commit

Permalink
#1602: CMake: use PUBLIC for flags that should impact dependent projects
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Nov 23, 2021
1 parent 19dfa35 commit 98666b0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions cmake-modules/SetCXXCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,38 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
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)
list(APPEND TARGET_CXX_FLAGS -Wno-unused-variable)
list(APPEND TARGET_PRIVATE_CXX_FLAGS -Wno-unused-variable)
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
list(APPEND TARGET_CXX_FLAGS -ftemplate-depth=900)
list(APPEND TARGET_PUBLIC_CXX_FLAGS -ftemplate-depth=900)
if (APPLE)
list(APPEND TARGET_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_EQUAL 7)
list(APPEND TARGET_CXX_FLAGS -DCLI11_EXPERIMENTAL_OPTIONAL=0)
list(APPEND TARGET_PUBLIC_CXX_FLAGS -DCLI11_EXPERIMENTAL_OPTIONAL=0)
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6)
list(APPEND TARGET_CXX_FLAGS -Wno-missing-braces)
list(APPEND TARGET_PRIVATE_CXX_FLAGS -Wno-missing-braces)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2021.3.0)
list(APPEND TARGET_CXX_FLAGS -fhonor-infinites -fhonor-nans)
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)
list(APPEND TARGET_CXX_FLAGS -fsanitize=address -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)
list(APPEND TARGET_CXX_FLAGS -fsanitize=undefined -fno-omit-frame-pointer)
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=undefined -fno-omit-frame-pointer)
endif()

message(DEBUG "Target ${vt_target} compile options: ${TARGET_CXX_FLAGS}")
target_compile_options(${vt_target} PRIVATE ${TARGET_CXX_FLAGS})
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()

0 comments on commit 98666b0

Please sign in to comment.