-
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.
#1602: use target_compile_options for enabling warnings
- Loading branch information
Showing
3 changed files
with
25 additions
and
21 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,26 +1,25 @@ | ||
include(CheckCXXCompilerFlag) | ||
|
||
function(enable_cxx_compiler_flag_if_supported flag) | ||
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set) | ||
if(flag_already_set EQUAL -1) | ||
check_cxx_compiler_flag("${flag}" flag_supported) | ||
if(flag_supported) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE) | ||
endif() | ||
unset(flag_supported CACHE) | ||
check_cxx_compiler_flag("${flag}" flag_supported) | ||
if(flag_supported) | ||
target_compile_options(${vt_target} PUBLIC ${flag}) | ||
endif() | ||
unset(flag_supported CACHE) | ||
endfunction() | ||
|
||
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") | ||
# Not really a warning, is still diagnostic related.. | ||
enable_cxx_compiler_flag_if_supported("-ftemplate-backtrace-limit=100") | ||
function(turn_on_warnings vt_target) | ||
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") | ||
# Not really a warning, is still diagnostic related.. | ||
enable_cxx_compiler_flag_if_supported("-ftemplate-backtrace-limit=100") | ||
|
||
if (vt_werror_enabled) # Treat warning as errors | ||
enable_cxx_compiler_flag_if_supported("-Werror") | ||
if (vt_werror_enabled) # Treat warning as errors | ||
enable_cxx_compiler_flag_if_supported("-Werror") | ||
endif() | ||
endif() | ||
endif() | ||
endfunction() |
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