-
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: CMake: enable warnings in tests and examples
- Loading branch information
Showing
3 changed files
with
27 additions
and
12 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,23 +1,31 @@ | ||
include(CheckCXXCompilerFlag) | ||
|
||
function(enable_cxx_compiler_flag_if_supported flag) | ||
macro(add_cxx_compiler_flag_if_supported flag) | ||
check_cxx_compiler_flag("${flag}" flag_supported) | ||
if(flag_supported) | ||
target_compile_options(${vt_target} PRIVATE ${flag}) | ||
list(APPEND VT_WARNING_FLAGS "${flag}") | ||
endif() | ||
unset(flag_supported CACHE) | ||
endfunction() | ||
endmacro() | ||
|
||
function(turn_on_warnings vt_target) | ||
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") | ||
if(NOT DEFINED VT_WARNING_FLAGS) | ||
add_cxx_compiler_flag_if_supported("-Wall") | ||
add_cxx_compiler_flag_if_supported("-pedantic") | ||
add_cxx_compiler_flag_if_supported("-Wshadow") | ||
add_cxx_compiler_flag_if_supported("-Wno-unknown-pragmas") | ||
add_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") | ||
add_cxx_compiler_flag_if_supported("-ftemplate-backtrace-limit=100") | ||
|
||
if (vt_werror_enabled) # Treat warning as errors | ||
enable_cxx_compiler_flag_if_supported("-Werror") | ||
add_cxx_compiler_flag_if_supported("-Werror") | ||
endif() | ||
endfunction() | ||
endif() | ||
|
||
set( | ||
VT_WARNING_FLAGS ${VT_WARNING_FLAGS} CACHE INTERNAL | ||
"Project's warning options") | ||
|
||
macro(turn_on_warnings vt_target) | ||
target_compile_options(${vt_target} PRIVATE ${VT_WARNING_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