Skip to content

Commit ed908fa

Browse files
committed
Add ENABLE_IWTU CMake option
Add CMake handling for `-DENABLE_IWYU=1" to enable scanning with include-what-you-use (if `iwyu` binary is found in PATH), and e.g. `-DIWYU_OPTS="--max_line_length=120 --verbose=1"` to supply args.
1 parent bcc62f9 commit ed908fa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ include(FeatureSummary)
3636
################ OPTIONS ##################
3737
# Optional build settings for libopenshot
3838
OPTION(USE_SYSTEM_JSONCPP "Use system installed JsonCpp" OFF)
39+
option(ENABLE_IWYU "Enable 'Include What You Use' scanner" OFF)
3940

4041
################ WINDOWS ##################
4142
# Set some compiler options for Windows
@@ -181,6 +182,21 @@ endif(USE_SYSTEM_JSONCPP)
181182
#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
182183
#set(PROFILER "/usr/lib/libtcmalloc.so.4")
183184

185+
if(ENABLE_IWYU)
186+
find_program(IWYU_PATH NAMES "iwyu"
187+
DOC "include-what-you-use source code scanner executable")
188+
if(IWYU_PATH)
189+
if(IWYU_OPTS)
190+
separate_arguments(IWYU_OPTS)
191+
list(APPEND _iwyu_cmd ${IWYU_PATH} "-Xiwyu" ${IWYU_OPTS})
192+
endif()
193+
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${_iwyu_cmd})
194+
else()
195+
set(ENABLE_IWYU FALSE)
196+
endif()
197+
endif()
198+
add_feature_info("IWYU (include-what-you-use)" ENABLE_IWYU "Scan all source files with 'iwyu'")
199+
184200
#### GET LIST OF EFFECT FILES ####
185201
FILE(GLOB EFFECT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/effects/*.cpp")
186202

0 commit comments

Comments
 (0)