1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00
openrw/cmake/modules/FindIncludeWhatYouUse.cmake
Anonymous Maarten a40a2706a9 cmake: add support for include-what-you-use to check #include's
The output is currently very verbose and includes many false positives.
Adding a mapping file should solve this.

See
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUMappings.md
2017-10-29 20:40:57 +00:00

30 lines
826 B
CMake

find_program(
INCLUDE_WHAT_YOU_USE_PROGRAM
NAMES include_what_you_use iwyu
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IncludeWhatYouUse
REQUIRED_VARS
INCLUDE_WHAT_YOU_USE_PROGRAM
)
if(INCLUDEWHATYOUUSE_FOUND)
include(CMakeParseArguments)
function(iwyu_check)
cmake_parse_arguments("IWYU" "" "TARGET" "EXTRA_OPTS" ${ARGN})
set(IWYU_CMD "${INCLUDE_WHAT_YOU_USE_PROGRAM}")
foreach(OPT ${IWYU_EXTRA_OPTS})
list(APPEND IWYU_CMD "-Xiwyu" ${OPT})
endforeach()
set_target_properties("${IWYU_TARGET}"
PROPERTIES
C_INCLUDE_WHAT_YOU_USE
"${IWYU_CMD}"
CXX_INCLUDE_WHAT_YOU_USE
"${IWYU_CMD}"
)
endfunction()
endif()