mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 11:25:51 +00:00
and the cmake directory into a new directory ``contrib/cmake`` that mirrors the directory structure of the root. This is a comprimise between me and Christoph Wintersteiger that was suggested by Arie Gurfinkel that allows the CMake build system to live in the Z3 repository but not impact the Z3 developers that want to avoid the CMake build system. The build system will not work in its new location and a bootstrap script will soon be provided that allows a developer to copy the files back to their correct location.
40 lines
1.4 KiB
CMake
40 lines
1.4 KiB
CMake
set(GCC_AND_CLANG_WARNINGS
|
|
"-Wall"
|
|
)
|
|
set(GCC_ONLY_WARNINGS "")
|
|
set(CLANG_ONLY_WARNINGS "")
|
|
set(MSVC_WARNINGS "/W3")
|
|
|
|
set(WARNING_FLAGS_TO_CHECK "")
|
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
|
list(APPEND WARNING_FLAGS_TO_CHECK ${GCC_AND_CLANG_WARNINGS})
|
|
list(APPEND WARNING_FLAGS_TO_CHECK ${GCC_ONLY_WARNINGS})
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
list(APPEND WARNING_FLAGS_TO_CHECK ${GCC_AND_CLANG_WARNINGS})
|
|
list(APPEND WARNING_FLAGS_TO_CHECK ${CLANG_ONLY_WARNINGS})
|
|
# FIXME: Remove "x.." when CMP0054 is set to NEW
|
|
elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
|
|
list(APPEND WARNING_FLAGS_TO_CHECK ${MSVC_WARNINGS})
|
|
else()
|
|
message(AUTHOR_WARNING "Unknown compiler")
|
|
endif()
|
|
|
|
# Loop through flags and use the ones which the compiler supports
|
|
foreach (flag ${WARNING_FLAGS_TO_CHECK})
|
|
z3_add_cxx_flag("${flag}")
|
|
endforeach()
|
|
|
|
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
|
|
if (WARNINGS_AS_ERRORS)
|
|
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"))
|
|
list(APPEND Z3_COMPONENT_CXX_FLAGS "-Werror")
|
|
# FIXME: Remove "x.." when CMP0054 is set to NEW
|
|
elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
|
|
list(APPEND Z3_COMPONENT_CXX_FLAGS "/WX")
|
|
else()
|
|
message(AUTHOR_WARNING "Unknown compiler")
|
|
endif()
|
|
message(STATUS "Treating compiler warnings as errors")
|
|
else()
|
|
message(STATUS "Not treating compiler warnings as errors")
|
|
endif()
|