Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ endif()
if(CPPCHK_GLIBCXX_DEBUG AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(USE_LIBCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 18 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
else()
add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
Expand Down
6 changes: 3 additions & 3 deletions cmake/compileroptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
# "Release" uses -O3 by default
add_compile_options(-O2)
endif()
if(WARNINGS_ARE_ERRORS)
if(CMAKE_COMPILE_WARNING_AS_ERROR)
add_compile_options(-Werror)
endif()
add_compile_options(-pedantic) # TODO: is this implied by -Weverything?
Expand Down Expand Up @@ -86,7 +86,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
#add_compile_options_safe(-Wunused-macros)
#add_compile_options_safe(-Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14)
# TODO: verify this regression still exists in clang-15
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# work around performance regression - see https://github.com/llvm/llvm-project/issues/53555
Expand Down Expand Up @@ -158,7 +158,7 @@ if(MSVC)
# General
add_compile_options(/W4) # Warning Level
add_compile_options(/Zi) # Debug Information Format - Program Database
if(WARNINGS_ARE_ERRORS)
if(CMAKE_COMPILE_WARNING_AS_ERROR)
add_compile_options(/WX) # Treat Warning As Errors
endif()
add_compile_options(/MP) # Multi-processor Compilation
Expand Down
6 changes: 0 additions & 6 deletions cmake/dynamic_analyzer_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,3 @@ if(ANALYZE_UNDEFINED)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=nullability")
endif()
endif()

if(ANALYZE_DATAFLOW)
add_compile_options(-fsanitize=dataflow)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=dataflow")
endif()
41 changes: 26 additions & 15 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@ if(DEFINED CMAKE_BUILD_TYPE)
endif()

if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type set - defaulting to Debug")
set(CMAKE_BUILD_TYPE "Debug")
endif()

# ----------------------------------------------------------------------------
# PROJECT CONFIGURATION
# ----------------------------------------------------------------------------
option(ANALYZE_MEMORY "Clang dynamic analyzer: detector of uninitialized reads." OFF)
option(ANALYZE_ADDRESS "Clang dynamic analyzer: fast memory error detector. " OFF)
option(ANALYZE_THREAD "Clang dynamic analyzer: tool that detects data races. " OFF)
option(ANALYZE_UNDEFINED "Clang dynamic analyzer: undefined behavior checker. " OFF)
option(ANALYZE_DATAFLOW "Clang dynamic analyzer: general dynamic dataflow analysis." OFF)
option(ANALYZE_MEMORY "Build with MemorySanitizer to detect usage of uninitialized memory" OFF)
if(ANALYZE_MEMORY)
message(STATUS "MemorySanitzer requires an instrumented libc++")
endif()
option(ANALYZE_ADDRESS "Build with AddressSanitzer to detect memory error" OFF)
option(ANALYZE_THREAD "Build with ThreadSanitizer to detect data races" OFF)
option(ANALYZE_UNDEFINED "Build with UndefinedBehaviorSanitizer to detect undefined behavior" OFF)

option(WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF)
if(WARNINGS_ARE_ERRORS)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
message(WARNING "WARNINGS_ARE_ERRORS is deprecated - please use CMAKE_COMPILE_WARNING_AS_ERROR instead")
endif()
set(CMAKE_COMPILE_WARNING_AS_ERROR On)
endif()
option(EXTERNALS_AS_SYSTEM "Treat externals as system includes" OFF)

set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
Expand All @@ -42,8 +51,8 @@ else()
endif()

option(BUILD_CORE_DLL "Build lib as cppcheck-core.dll with Visual Studio" OFF)
if(NOT MSVC)
set(BUILD_CORE_DLL OFF)
if(BUILD_CORE_DLL AND NOT MSVC)
message(FATAL_ERROR "Building of lib as DLL is only supported with Visual Studio")
endif()
option(BUILD_TESTS "Build tests" OFF)
option(REGISTER_TESTS "Register tests in CTest" ON)
Expand All @@ -60,19 +69,21 @@ option(REGISTER_GUI_TESTS "Register GUI tests in CTest"
option(BUILD_ONLINE_HELP "Build online help" OFF)

option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
option(USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON)
if(BUILD_CORE_DLL)
set(USE_BUNDLED_TINYXML2 ON)
option(USE_BUNDLED_TINYXML2 "Usage of bundled TinyXML2 library" ON)
if(BUILD_CORE_DLL AND NOT USE_BUNDLED_TINYXML2)
message(FATAL_ERROR "Cannot use external TinyXML2 library when building lib as DLL")
endif()
option(CPPCHK_GLIBCXX_DEBUG "Usage of STL debug checks in Debug build" ON)
option(DISALLOW_THREAD_EXECUTOR "Disallow usage of ThreadExecutor for -j" OFF)
option(USE_BOOST "Usage of Boost" OFF)
option(USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF)
option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF)

if(DISALLOW_THREAD_EXECUTOR AND WIN32)
message(FATAL_ERROR "Cannot disable usage of ThreadExecutor on Windows as no other executor implementation is currently available")
endif()
option(USE_BOOST "Usage of Boost" OFF)
option(USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF)
if (NOT USE_BOOST AND USE_BOOST_INT128)
message(FATAL_ERROR "USE_BOOST_INT128 requires USE_BOOST to be enabled")
endif()
option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF)

option(DISABLE_CRTDBG_MAP_ALLOC "Disable usage of Visual Studio C++ memory leak detection in Debug build" OFF)
option(NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling" OFF)
Expand All @@ -82,7 +93,7 @@ option(NO_WINDOWS_SEH "Disable usage of Windows SEH"
# TODO: disable by default like make build?
option(FILESDIR "Hard-coded directory for files to load from" OFF)

if(CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16")
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16")
set(CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers")
# need to disable the prologue or it will be treated like a system header and not emit any warnings
# see https://gitlab.kitware.com/cmake/cmake/-/issues/21219
Expand Down
1 change: 0 additions & 1 deletion cmake/printInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ message(STATUS "ANALYZE_MEMORY = ${ANALYZE_MEMORY}")
message(STATUS "ANALYZE_ADDRESS = ${ANALYZE_ADDRESS}")
message(STATUS "ANALYZE_THREAD = ${ANALYZE_THREAD}")
message(STATUS "ANALYZE_UNDEFINED = ${ANALYZE_UNDEFINED}")
message(STATUS "ANALYZE_DATAFLOW = ${ANALYZE_DATAFLOW}")
message(STATUS)
message(STATUS "WARNINGS_ARE_ERRORS = ${WARNINGS_ARE_ERRORS}")
message(STATUS "EXTERNALS_AS_SYSTEM = ${EXTERNALS_AS_SYSTEM}")
Expand Down