0

Hi im using google test libraire on my project and i want launch cppecheck with cmake on src and test folders only this my Project structure ---Project --src --test and google test will generate on builded folder

find_program(CMAKE_CXX_CPPCHECK  NAMES cppcheck HINTS $ENV{PROGRAMFILES}/cppcheck)
# If CppCheck executable found
if (CMAKE_CXX_CPPCHECK)
    # Check CppCheck version
    message(STATUS "CppCheck  found.")
    set(CPP_CHECK_CMD ${CMAKE_CXX_CPPCHECK} --version)
    execute_process(COMMAND ${CPP_CHECK_CMD}
            WORKING_DIRECTORY ${analyze_dir}
            RESULT_VARIABLE CPP_CHECK_RESULT
            OUTPUT_VARIABLE CPP_CHECK_VERSION
            ERROR_VARIABLE CPP_CHECK_ERROR)


else ()
    message(STATUS "CppCheck not found.")
endif ()

273K
  • 29,503
  • 10
  • 41
  • 64
  • Do you really need `execute_process`? Can't you just set [`_CPPCHECK`](https://cmake.org/cmake/help/latest/prop_tgt/LANG_CPPCHECK.html) in the directory scopes that you want to get checked? – starball Nov 08 '22 at 08:01
  • it doesn't work , i don't know why but it check all the project – Safouen Aouadi Nov 08 '22 at 23:37
  • it's a target property. You can set it on a per-target-basis using [`set_target_properties`](https://cmake.org/cmake/help/latest/command/set_target_properties.html), or you can set a default value for all targets defined under a CMake subdirectory using the [corresponding variable](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CPPCHECK.html). – starball Nov 09 '22 at 00:53

0 Answers0