diff --git a/cmake/options.cmake b/cmake/options.cmake index d63d67079af..a18592f588a 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -22,19 +22,23 @@ option(WARNINGS_ARE_ERRORS "Treat warnings as errors" option(EXTERNALS_AS_SYSTEM "Treat externals as system includes" OFF) set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler") -set(_MATCHCOMPILER_STRINGS Auto Off On Verify) -set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS ${_MATCHCOMPILER_STRINGS}) -if (NOT ${USE_MATCHCOMPILER} IN_LIST _MATCHCOMPILER_STRINGS) - message(FATAL_ERROR "Invalid USE_MATCHCOMPILER value '${USE_MATCHCOMPILER}'") -endif() -if (USE_MATCHCOMPILER STREQUAL "Auto") - if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - set(USE_MATCHCOMPILER_OPT "On") +set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify) +if(USE_MATCHCOMPILER) + if(USE_MATCHCOMPILER STREQUAL "Auto") + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + message(STATUS "Non-debug build detected - enabling matchcompiler") + set(USE_MATCHCOMPILER_OPT "On") + else() + message(STATUS "Debug build detected - disabling matchcompiler") + set(USE_MATCHCOMPILER_OPT "Off") + endif() + elseif(USE_MATCHCOMPILER STREQUAL "Verify") + set(USE_MATCHCOMPILER_OPT "Verify") else() - set(USE_MATCHCOMPILER_OPT "Off") + set(USE_MATCHCOMPILER_OPT "On") endif() else() - set(USE_MATCHCOMPILER_OPT ${USE_MATCHCOMPILER}) + set(USE_MATCHCOMPILER_OPT "Off") endif() option(BUILD_CORE_DLL "Build lib as cppcheck-core.dll with Visual Studio" OFF) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 86a3970d8ff..7a884164761 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -10,7 +10,7 @@ function(build_src output filename) get_filename_component(file ${filename} NAME) set(outfile ${CMAKE_CURRENT_BINARY_DIR}/build/mc_${file}) set(${output} ${${output}} ${outfile} PARENT_SCOPE) - if (USE_MATCHCOMPILER STREQUAL "Verify") + if (USE_MATCHCOMPILER_OPT STREQUAL "Verify") set(verify_option "--verify") endif() add_custom_command(