aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRechi <Rechi@users.noreply.github.com>2020-10-05 01:48:47 +0200
committerRechi <Rechi@users.noreply.github.com>2020-10-05 01:48:47 +0200
commitcc69cc21e609216cec13b56f5dcfab2e0fcf1c63 (patch)
tree12e293157a95d84f214faaef711f13e602ac8862
parent2b0753e10408c1a2b2607c40b3f1d46f0bcc33dd (diff)
[cmake] add include-what-you-use support
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmake/modules/FindIncludeWhatYouUse.cmake26
-rw-r--r--lib/libUPnP/CMakeLists.txt1
3 files changed, 29 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c5cb79d62a..019854b680 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,7 @@ option(VERBOSE "Enable verbose output?" OFF)
option(ENABLE_CLANGTIDY "Enable clang-tidy support?" OFF)
option(ENABLE_CPPCHECK "Enable cppcheck support?" OFF)
option(ENABLE_DVDCSS "Enable libdvdcss support?" ON)
+option(ENABLE_INCLUDEWHATYOUUSE "Enable include-what-you-use support?" OFF)
option(ENABLE_UPNP "Enable UPnP support?" ON)
option(ENABLE_AIRTUNES "Enable AirTunes support?" ON)
option(ENABLE_OPTICAL "Enable optical support?" ON)
@@ -152,6 +153,7 @@ set(optional_deps Alsa
Cppcheck
Dav1d
DBus
+ IncludeWhatYouUse
Iso9660pp
LCMS2
LircClient
diff --git a/cmake/modules/FindIncludeWhatYouUse.cmake b/cmake/modules/FindIncludeWhatYouUse.cmake
new file mode 100644
index 0000000000..b22225ae5c
--- /dev/null
+++ b/cmake/modules/FindIncludeWhatYouUse.cmake
@@ -0,0 +1,26 @@
+#.rst:
+# FindIncludeWhatYouUse
+# ---------------------
+# Finds include-what-you-use and sets it up to run along with the compiler for C and CXX.
+
+find_program(IWYU_EXECUTABLE NAMES include-what-you-use iwyu)
+
+if(IWYU_EXECUTABLE)
+ execute_process(COMMAND "${IWYU_EXECUTABLE}" --version
+ OUTPUT_VARIABLE IWYU_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[^\n]*include-what-you-use [^\n]*" IWYU_VERSION "${IWYU_VERSION}")
+ string(REGEX REPLACE "include-what-you-use ([^ \n\r\t]+).*" "\\1" IWYU_VERSION "${IWYU_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(IncludeWhatYouUse REQUIRED_VARS IWYU_EXECUTABLE
+ VERSION_VAR IWYU_VERSION)
+
+if(INCLUDEWHATYOUUSE_FOUND)
+ # Supports Unix Makefiles and Ninja
+ set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE}" PARENT_SCOPE)
+ set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE}" PARENT_SCOPE)
+endif()
+
+mark_as_advanced(IWYU_EXECUTABLE)
diff --git a/lib/libUPnP/CMakeLists.txt b/lib/libUPnP/CMakeLists.txt
index 92b3732e3f..c8f25ec95e 100644
--- a/lib/libUPnP/CMakeLists.txt
+++ b/lib/libUPnP/CMakeLists.txt
@@ -122,6 +122,7 @@ if(CORE_SYSTEM_NAME STREQUAL windows OR CORE_SYSTEM_NAME STREQUAL windowsstore)
endif()
set_target_properties(upnp PROPERTIES CXX_CLANG_TIDY "")
set_target_properties(upnp PROPERTIES CXX_CPPCHECK "")
+set_target_properties(upnp PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "")
set_target_properties(upnp PROPERTIES FOLDER lib)
source_group_by_folder(upnp)
set(core_DEPENDS upnp ${core_DEPENDS} CACHE STRING "" FORCE)