@@ -6,19 +6,28 @@ if(DEFINED CMAKE_BUILD_TYPE)
66endif ()
77
88if (NOT CMAKE_BUILD_TYPE )
9+ message (STATUS "No build type set - defaulting to Debug" )
910 set (CMAKE_BUILD_TYPE "Debug" )
1011endif ()
1112
1213# ----------------------------------------------------------------------------
1314# PROJECT CONFIGURATION
1415# ----------------------------------------------------------------------------
15- option (ANALYZE_MEMORY "Clang dynamic analyzer: detector of uninitialized reads." OFF )
16- option (ANALYZE_ADDRESS "Clang dynamic analyzer: fast memory error detector. " OFF )
17- option (ANALYZE_THREAD "Clang dynamic analyzer: tool that detects data races. " OFF )
18- option (ANALYZE_UNDEFINED "Clang dynamic analyzer: undefined behavior checker. " OFF )
19- option (ANALYZE_DATAFLOW "Clang dynamic analyzer: general dynamic dataflow analysis." OFF )
16+ option (ANALYZE_MEMORY "Build with MemorySanitizer to detect usage of uninitialized memory" OFF )
17+ if (ANALYZE_MEMORY)
18+ message (STATUS "MemorySanitzer requires an instrumented libc++" )
19+ endif ()
20+ option (ANALYZE_ADDRESS "Build with AddressSanitzer to detect memory error" OFF )
21+ option (ANALYZE_THREAD "Build with ThreadSanitizer to detect data races" OFF )
22+ option (ANALYZE_UNDEFINED "Build with UndefinedBehaviorSanitizer to detect undefined behavior" OFF )
2023
2124option (WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
25+ if (WARNINGS_ARE_ERRORS)
26+ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24" )
27+ message (WARNING "WARNINGS_ARE_ERRORS is deprecated - please use CMAKE_COMPILE_WARNING_AS_ERROR instead" )
28+ endif ()
29+ set (CMAKE_COMPILE_WARNING_AS_ERROR On )
30+ endif ()
2231option (EXTERNALS_AS_SYSTEM "Treat externals as system includes" OFF )
2332
2433set (USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler" )
4251endif ()
4352
4453option (BUILD_CORE_DLL "Build lib as cppcheck-core.dll with Visual Studio" OFF )
45- if (NOT MSVC )
46- set (BUILD_CORE_DLL OFF )
54+ if (BUILD_CORE_DLL AND NOT MSVC )
55+ message (FATAL_ERROR "Building of lib as DLL is only supported with Visual Studio" )
4756endif ()
4857option (BUILD_TESTS "Build tests" OFF )
4958option (REGISTER_TESTS "Register tests in CTest" ON )
@@ -60,19 +69,21 @@ option(REGISTER_GUI_TESTS "Register GUI tests in CTest"
6069option (BUILD_ONLINE_HELP "Build online help" OFF )
6170
6271option (HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF )
63- option (USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON )
64- if (BUILD_CORE_DLL)
65- set (USE_BUNDLED_TINYXML2 ON )
72+ option (USE_BUNDLED_TINYXML2 "Usage of bundled TinyXML2 library" ON )
73+ if (BUILD_CORE_DLL AND NOT USE_BUNDLED_TINYXML2 )
74+ message (FATAL_ERROR "Cannot use external TinyXML2 library when building lib as DLL" )
6675endif ()
6776option (CPPCHK_GLIBCXX_DEBUG "Usage of STL debug checks in Debug build" ON )
6877option (DISALLOW_THREAD_EXECUTOR "Disallow usage of ThreadExecutor for -j" OFF )
69- option (USE_BOOST "Usage of Boost" OFF )
70- option (USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF )
71- option (USE_LIBCXX "Use libc++ instead of libstdc++" OFF )
72-
7378if (DISALLOW_THREAD_EXECUTOR AND WIN32 )
7479 message (FATAL_ERROR "Cannot disable usage of ThreadExecutor on Windows as no other executor implementation is currently available" )
7580endif ()
81+ option (USE_BOOST "Usage of Boost" OFF )
82+ option (USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF )
83+ if (NOT USE_BOOST AND USE_BOOST_INT128)
84+ message (FATAL_ERROR "USE_BOOST_INT128 requires USE_BOOST to be enabled" )
85+ endif ()
86+ option (USE_LIBCXX "Use libc++ instead of libstdc++" OFF )
7687
7788option (DISABLE_CRTDBG_MAP_ALLOC "Disable usage of Visual Studio C++ memory leak detection in Debug build" OFF )
7889option (NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling" OFF )
@@ -82,7 +93,7 @@ option(NO_WINDOWS_SEH "Disable usage of Windows SEH"
8293# TODO: disable by default like make build?
8394option (FILESDIR "Hard-coded directory for files to load from" OFF )
8495
85- if (CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16" )
96+ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.16" )
8697 set (CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers" )
8798 # need to disable the prologue or it will be treated like a system header and not emit any warnings
8899 # see https://gitlab.kitware.com/cmake/cmake/-/issues/21219
0 commit comments