mirror of
https://github.com/Z3Prover/z3
synced 2025-04-04 16:44:07 +00:00
to allow a new mode `SERIOUS_ONLY`. Modes: `ON` - All warnings are treated as errors (same as before) `OFF` - Warnings are not treated as errors (same as before) `SERIOUS_ONLY` - A subset of "serious" warnings are treated as errors. Upgrade code is included to upgrade old CMake cache's to use the new type of `WARNINGS_AS_ERRORS`. We should remove it eventually. The user's previous setting is preserved when doing this. Very few warnings are treated as errors for now. Developers can add more later as they see fit.
30 lines
1.3 KiB
CMake
30 lines
1.3 KiB
CMake
include(CheckCXXCompilerFlag)
|
|
include(CMakeParseArguments)
|
|
|
|
function(z3_add_cxx_flag flag)
|
|
CMAKE_PARSE_ARGUMENTS(z3_add_flag "REQUIRED;GLOBAL" "" "" ${ARGN})
|
|
string(REPLACE "-" "_" SANITIZED_FLAG_NAME "${flag}")
|
|
string(REPLACE "/" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
|
string(REPLACE "=" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
|
string(REPLACE " " "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
|
string(REPLACE ":" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
|
string(REPLACE "+" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
|
unset(HAS_${SANITIZED_FLAG_NAME})
|
|
CHECK_CXX_COMPILER_FLAG("${flag}" HAS_${SANITIZED_FLAG_NAME})
|
|
if (z3_add_flag_REQUIRED AND NOT HAS_${SANITIZED_FLAG_NAME})
|
|
message(FATAL_ERROR "The flag \"${flag}\" is required but your C++ compiler doesn't support it")
|
|
endif()
|
|
if (HAS_${SANITIZED_FLAG_NAME})
|
|
message(STATUS "C++ compiler supports ${flag}")
|
|
if (z3_add_flag_GLOBAL)
|
|
# Set globally
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag} " PARENT_SCOPE)
|
|
else()
|
|
list(APPEND Z3_COMPONENT_CXX_FLAGS "${flag}")
|
|
set(Z3_COMPONENT_CXX_FLAGS "${Z3_COMPONENT_CXX_FLAGS}" PARENT_SCOPE)
|
|
endif()
|
|
else()
|
|
message(STATUS "C++ compiler does not support ${flag}")
|
|
endif()
|
|
endfunction()
|