added CMake option `EXTERNALS_AS_SYSTEM` to treat external includes as `SYSTEM` ones (#5386)
Although these files are part of our repo changes are being done via their original projects so it might make sense to treat these as system includes for some people instead of local ones. Co-authored-by: Daniel Marjamäki <daniel.marjamaki@gmail.com>
This commit is contained in:
parent
8d64d12e5d
commit
dd869cf808
|
@ -6,11 +6,11 @@ list(REMOVE_ITEM srcs ${mainfile})
|
|||
add_library(cli_objs OBJECT ${hdrs} ${srcs})
|
||||
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
target_externals_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
else()
|
||||
target_include_directories(cli_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
target_externals_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
|
||||
target_precompile_headers(cli_objs PRIVATE precompiled.h)
|
||||
endif()
|
||||
|
@ -38,11 +38,11 @@ endif()
|
|||
add_executable(cppcheck ${cppcheck_SOURCES})
|
||||
target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
target_externals_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
else()
|
||||
target_include_directories(cppcheck SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
target_externals_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
if (HAVE_RULES)
|
||||
target_link_libraries(cppcheck ${PCRE_LIBRARY})
|
||||
endif()
|
||||
|
|
|
@ -16,6 +16,14 @@ function(target_compile_options_safe TARGET FLAG)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
function(target_externals_include_directories TARGET)
|
||||
if (EXTERNALS_AS_SYSTEM)
|
||||
target_include_directories(${TARGET} SYSTEM ${ARGN})
|
||||
else()
|
||||
target_include_directories(${TARGET} ${ARGN})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Weverything)
|
||||
endif()
|
||||
|
|
|
@ -17,7 +17,9 @@ option(ANALYZE_ADDRESS "Clang dynamic analyzer: fast memory error detector.
|
|||
option(ANALYZE_THREAD "Clang dynamic analyzer: tool that detects data races. " OFF)
|
||||
option(ANALYZE_UNDEFINED "Clang dynamic analyzer: undefined behavior checker. " OFF)
|
||||
option(ANALYZE_DATAFLOW "Clang dynamic analyzer: general dynamic dataflow analysis." OFF)
|
||||
|
||||
option(WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF)
|
||||
option(EXTERNALS_AS_SYSTEM "Treat externals as system includes" OFF)
|
||||
|
||||
set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
|
||||
set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify)
|
||||
|
|
|
@ -25,7 +25,9 @@ message( STATUS "ANALYZE_ADDRESS = ${ANALYZE_ADDRESS}" )
|
|||
message( STATUS "ANALYZE_THREAD = ${ANALYZE_THREAD}" )
|
||||
message( STATUS "ANALYZE_UNDEFINED = ${ANALYZE_UNDEFINED}" )
|
||||
message( STATUS "ANALYZE_DATAFLOW = ${ANALYZE_DATAFLOW}" )
|
||||
message( STATUS )
|
||||
message( STATUS "WARNINGS_ARE_ERRORS = ${WARNINGS_ARE_ERRORS}" )
|
||||
message( STATUS "EXTERNALS_AS_SYSTEM = ${EXTERNALS_AS_SYSTEM}" )
|
||||
message( STATUS )
|
||||
message( STATUS "USE_MATCHCOMPILER = ${USE_MATCHCOMPILER}" )
|
||||
message( STATUS "USE_MATCHCOMPILER_OPT = ${USE_MATCHCOMPILER_OPT}" )
|
||||
|
|
|
@ -38,7 +38,7 @@ CheckOptions:
|
|||
set_target_properties(cppcheck-gui PROPERTIES WIN32_EXECUTABLE ON)
|
||||
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
target_externals_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
else()
|
||||
target_include_directories(cppcheck-gui SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
|
|
@ -10,7 +10,8 @@ add_executable(test-filelist
|
|||
${CMAKE_SOURCE_DIR}/lib/utils.cpp
|
||||
$<TARGET_OBJECTS:simplecpp_objs>
|
||||
)
|
||||
target_include_directories(test-filelist PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp)
|
||||
target_include_directories(test-filelist PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib)
|
||||
target_externals_include_directories(test-filelist PRIVATE ${CMAKE_SOURCE_DIR}/externals/simplecpp)
|
||||
target_compile_definitions(test-filelist PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
target_link_libraries(test-filelist ${QT_CORE_LIB} ${QT_TEST_LIB})
|
||||
|
||||
|
|
|
@ -43,14 +43,14 @@ if (BUILD_CORE_DLL)
|
|||
else()
|
||||
add_library(cppcheck-core OBJECT ${srcs_lib} ${hdrs})
|
||||
endif()
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/)
|
||||
target_externals_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
target_externals_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
else()
|
||||
target_include_directories(cppcheck-core SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
target_externals_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
|
||||
target_externals_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
if (HAVE_RULES)
|
||||
target_include_directories(cppcheck-core SYSTEM PRIVATE ${PCRE_INCLUDE})
|
||||
endif()
|
||||
|
|
|
@ -16,4 +16,4 @@ Deprecations:
|
|||
-
|
||||
|
||||
Other:
|
||||
-
|
||||
- Added CMake option 'EXTERNALS_AS_SYSTEM' to treat external includes as 'SYSTEM' ones.
|
||||
|
|
|
@ -12,11 +12,11 @@ if (BUILD_TESTS)
|
|||
add_executable(testrunner ${testrunner_SOURCES})
|
||||
target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/cli/)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2)
|
||||
target_externals_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2)
|
||||
else()
|
||||
target_include_directories(testrunner SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
target_externals_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
if (HAVE_RULES)
|
||||
target_link_libraries(testrunner ${PCRE_LIBRARY})
|
||||
endif()
|
||||
|
|
|
@ -17,7 +17,8 @@ add_executable(dmake EXCLUDE_FROM_ALL
|
|||
${CMAKE_SOURCE_DIR}/lib/utils.cpp
|
||||
$<TARGET_OBJECTS:simplecpp_objs>
|
||||
)
|
||||
target_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/cli ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp)
|
||||
target_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/cli ${CMAKE_SOURCE_DIR}/lib)
|
||||
target_externals_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/externals/simplecpp)
|
||||
if (WIN32 AND NOT BORLAND)
|
||||
if(NOT MINGW)
|
||||
target_link_libraries(dmake Shlwapi.lib)
|
||||
|
|
Loading…
Reference in New Issue