2019-11-11 10:19:34 +00:00
unset ( IWYU_BIN CACHE )
find_program ( IWYU_BIN iwyu_tool.py )
if ( IWYU_BIN )
find_file ( PROJECT_FILE compile_commands.json PATH . )
if ( NOT PROJECT_FILE )
message ( STATUS "Found IWYU, but no \" compile_commands.json\ " file. To enable IWYU, set CMAKE_EXPORT_COMPILE_COMMANDS to \" ON\ " and build again." )
return ( )
endif ( )
if ( NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
2019-12-10 03:03:13 +00:00
message ( STATUS "Found IWYU, but clang++ is not used. To enable IWYU, set CMAKE_C_COMPILER to \" clang\ " and CMAKE_CXX_COMPILER to \" clang++\ " and build again." )
2019-11-11 10:19:34 +00:00
return ( )
endif ( )
include ( ProcessorCount )
ProcessorCount ( N )
add_custom_target ( iwyu
C O M M A N D e c h o " I W Y U i s a n a l y z i n g i n c l u d e s - t h i s m a y t a k e a w h i l e . . . "
C O M M A N D $ { I W Y U _ B I N } - j $ { N } - p . > i w y u . t x t
)
message ( STATUS "Found IWYU. To perform header analysis using IWYU, use: \" make iwyu\ ". Results will be stored in \" iwyu.txt\ "." )
endif ( )