Skip to content

Commit

Permalink
feat: Set cppcheck default std
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims committed Aug 13, 2024
1 parent 9ea0e32 commit d40ef51
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/StaticAnalyzers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,21 @@ macro(enable_cppcheck CPPCHECK_OPTIONS)
set(CMAKE_C_CPPCHECK ${CMAKE_CXX_CPPCHECK})

if(NOT "${CMAKE_CXX_STANDARD}" STREQUAL "")
set(CMAKE_CXX_CPPCHECK ${CMAKE_CXX_CPPCHECK} --std=c++${CMAKE_CXX_STANDARD})
if(CMAKE_CXX_STANDARD IN_LIST 03 11 14 17 20)
set(CMAKE_CXX_CPPCHECK ${CMAKE_CXX_CPPCHECK} --std=c++${CMAKE_CXX_STANDARD})
else()
message(${WARNING_MESSAGE} "cppcheck dosen't support specified C++ standard ${CMAKE_CXX_STANDARD}. Using the cppcheck default C++ standard version.")
endif()
endif()

if(NOT "${CMAKE_C_STANDARD}" STREQUAL "")
set(CMAKE_C_CPPCHECK ${CMAKE_C_CPPCHECK} --std=c${CMAKE_C_STANDARD})
if(CMAKE_C_STANDARD IN_LIST 90)
set(CMAKE_C_CPPCHECK ${CMAKE_C_CPPCHECK} --std=c89)
elseif(CMAKE_C_STANDARD IN_LIST 99 11)
set(CMAKE_C_CPPCHECK ${CMAKE_C_CPPCHECK} --std=c${CMAKE_C_STANDARD})
else()
message(${WARNING_MESSAGE} "cppcheck dosen't support specified C standard ${CMAKE_C_STANDARD}. Using the cppcheck default C standard version.")
endif()
endif()

else()
Expand Down

0 comments on commit d40ef51

Please sign in to comment.