Skip to content

Commit

Permalink
fixed #12666 - got rid of ill-conceived USE_MATCHCOMPILER CMake opt…
Browse files Browse the repository at this point in the history
…ion validation (danmar#6348)

I went quite overboard when I introduced the validation of the define.
That was not necessary in CMake as we provide feedback on the usage of
the matchcompiler. So only handle the special options and otherwise rely
on the regular CMake logic.
  • Loading branch information
firewave committed May 3, 2024
1 parent 57e0ea5 commit c4be14d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c4be14d

Please sign in to comment.