5 # Find include-what-you-use executable.
10 # This module defines the following variables:
21 # .. command:: add_include_what_you_use
25 # add_include_what_you_use([OPTIONS opt] [TARGETS tgt ...] [tgt ...])
27 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
28 find_program(IWYU_EXECUTABLE NAMES include-what-you-use)
29 mark_as_advanced(IWYU_EXECUTABLE)
31 if(EXISTS "${IWYU_EXECUTABLE}")
32 execute_process(COMMAND ${IWYU_EXECUTABLE} --version OUTPUT_VARIABLE IWYU_VERSION)
33 string(REGEX REPLACE ".*use ([^ ]+).*" "\\1" IWYU_VERSION "${IWYU_VERSION}")
36 find_package_handle_standard_args(IWYU
46 function(add_include_what_you_use)
47 if(CMAKE_VERSION VERSION_LESS 3.3)
50 cmake_parse_arguments(IWYU "" "" "TARGETS;OPTIONS" ${ARGN})
51 list(APPEND IWYU_TARGETS ${IWYU_UNPARSED_ARGUMENTS})
52 set_target_properties(${IWYU_TARGETS} PROPERTIES C_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE};${IWYU_OPTIONS}")
53 set_target_properties(${IWYU_TARGETS} PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE};${IWYU_OPTIONS}")