Skip to content

Commit

Permalink
#1005: cmake: cache compiler checks for warning flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nmm0 committed Nov 10, 2020
1 parent ec87e48 commit 7512923
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions cmake/turn_on_warnings.cmake
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
include(CheckCXXCompilerFlag)

function(enable_cxx_compiler_flag_if_supported flag)
function(enable_cxx_compiler_flag_if_supported flag var)
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set)
if(flag_already_set EQUAL -1)
check_cxx_compiler_flag("${flag}" flag_supported)
check_cxx_compiler_flag("${flag}" ${var})
if(flag_supported)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
unset(flag_supported CACHE)
endif()
endfunction()

get_directory_property(hasParent PARENT_DIRECTORY)
if(NOT hasParent)
enable_cxx_compiler_flag_if_supported("-Wall")
enable_cxx_compiler_flag_if_supported("-pedantic")
enable_cxx_compiler_flag_if_supported("-Wshadow")
enable_cxx_compiler_flag_if_supported("-Wno-unknown-pragmas")
enable_cxx_compiler_flag_if_supported("-Wsign-compare")
enable_cxx_compiler_flag_if_supported("-Wall" VT_WALL_FLAG_SUPPORTED)
enable_cxx_compiler_flag_if_supported("-pedantic" VT_PEDANTIC_FLAG_SUPPORTED)
enable_cxx_compiler_flag_if_supported("-Wshadow" VT_WSHADOW_FLAG_SUPPORTED)
enable_cxx_compiler_flag_if_supported("-Wno-unknown-pragmas" VT_WNO_UNKNOWN_PRAGMAS_FLAG_SUPPORTED)
enable_cxx_compiler_flag_if_supported("-Wsign-compare" VT_WSIGN_COMPARE_SUPPORTED)
# Not really a warning, is still diagnostic related..
enable_cxx_compiler_flag_if_supported("-ftemplate-backtrace-limit=100")
enable_cxx_compiler_flag_if_supported("-ftemplate-backtrace-limit=100" VT_FTEMPLATE_BACKTRACE_LIMIT_SUPPORTED)
endif()

0 comments on commit 7512923

Please sign in to comment.