123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- include(CheckCXXCompilerFlag)
- function(add_cxx_flag_if_supported_to_targets flagname targets)
- string(MAKE_C_IDENTIFIER ${flagname} flag_identifier )
- check_cxx_compiler_flag("${flagname}" HAVE_FLAG_${flag_identifier})
- if (HAVE_FLAG_${flag_identifier})
- foreach(target ${targets})
- target_compile_options(${target} PUBLIC ${flagname})
- endforeach()
- endif()
- endfunction()
- function(add_warnings_to_targets targets)
- LIST(LENGTH targets TARGETS_LEN)
-
-
- if (MSVC)
- foreach(target ${targets})
-
- target_compile_options( ${target} PRIVATE /utf-8 )
-
- if (CATCH_ENABLE_WERROR)
- target_compile_options( ${target} PRIVATE /WX )
- endif()
-
- if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
- STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
- target_compile_options( ${target} PRIVATE /w44265 /w44061 /w44062 /w45038 )
- endif()
- endforeach()
- endif()
- if (NOT MSVC)
- set(CHECKED_WARNING_FLAGS
- "-Wabsolute-value"
- "-Wall"
- "-Wc++20-compat"
- "-Wcall-to-pure-virtual-from-ctor-dtor"
- "-Wcast-align"
- "-Wcatch-value"
- "-Wdangling"
- "-Wdeprecated"
- "-Wdeprecated-register"
- "-Wexceptions"
- "-Wexit-time-destructors"
- "-Wextra"
- "-Wextra-semi"
- "-Wfloat-equal"
- "-Wglobal-constructors"
- "-Winit-self"
- "-Wmisleading-indentation"
- "-Wmismatched-new-delete"
- "-Wmismatched-return-types"
- "-Wmismatched-tags"
- "-Wmissing-braces"
- "-Wmissing-declarations"
- "-Wmissing-noreturn"
- "-Wmissing-prototypes"
- "-Wmissing-variable-declarations"
- "-Wnull-dereference"
- "-Wold-style-cast"
- "-Woverloaded-virtual"
- "-Wparentheses"
- "-Wpedantic"
- "-Wreorder"
- "-Wreturn-std-move"
- "-Wshadow"
- "-Wstrict-aliasing"
- "-Wsuggest-destructor-override"
- "-Wsuggest-override"
- "-Wundef"
- "-Wuninitialized"
- "-Wunneeded-internal-declaration"
- "-Wunreachable-code"
- "-Wunused"
- "-Wunused-function"
- "-Wunused-parameter"
- "-Wvla"
- "-Wweak-vtables"
-
-
-
-
-
-
- )
- foreach(warning ${CHECKED_WARNING_FLAGS})
- add_cxx_flag_if_supported_to_targets(${warning} "${targets}")
- endforeach()
- if (CATCH_ENABLE_WERROR)
- foreach(target ${targets})
-
- target_compile_options( ${target} PRIVATE -Werror )
- endforeach()
- endif()
- endif()
- endfunction()
- function(add_build_reproducibility_settings target)
-
- if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
- add_cxx_flag_if_supported_to_targets("-ffile-prefix-map=${CATCH_DIR}/=" "${target}")
- endif()
- endfunction()
|