Skip to content

Commit afc8974

Browse files
authored
Merge pull request #354 from ferdnyc/iwyu-cmd-fix
CMake: Fix IWYU invocation with unset IWYU_OPTS
2 parents 76725d9 + f09ac1b commit afc8974

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ include(FeatureSummary)
3333
################ OPTIONS ##################
3434
# Optional build settings for libopenshot
3535
OPTION(USE_SYSTEM_JSONCPP "Use system installed JsonCpp" OFF)
36-
option(ENABLE_IWYU "Enable 'Include What You Use' scanner" OFF)
36+
option(ENABLE_IWYU "Enable 'Include What You Use' scanner (CMake 3.3+)" OFF)
3737

3838
################ WINDOWS ##################
3939
# Set some compiler options for Windows
@@ -165,15 +165,20 @@ endif(USE_SYSTEM_JSONCPP)
165165
#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
166166
#set(PROFILER "/usr/lib/libtcmalloc.so.4")
167167

168+
if(CMAKE_VERSION VERSION_LESS 3.3)
169+
# IWYU wasn't supported internally in 3.2
170+
set(ENABLE_IWYU FALSE)
171+
endif()
172+
168173
if(ENABLE_IWYU)
169174
find_program(IWYU_PATH NAMES "iwyu"
170175
DOC "include-what-you-use source code scanner executable")
171176
if(IWYU_PATH)
172177
if(IWYU_OPTS)
173178
separate_arguments(IWYU_OPTS)
174-
list(APPEND _iwyu_cmd ${IWYU_PATH} "-Xiwyu" ${IWYU_OPTS})
179+
list(APPEND _iwyu_opts "-Xiwyu" ${IWYU_OPTS})
175180
endif()
176-
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${_iwyu_cmd})
181+
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH} ${_iwyu_opts})
177182
else()
178183
set(ENABLE_IWYU FALSE)
179184
endif()

0 commit comments

Comments
 (0)