summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CMakeLists.txt
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2016-06-02 22:08:30 (GMT)
committerBrad King <brad.king@kitware.com>2016-06-17 14:56:40 (GMT)
commit96242f8022fa4bc718ef36cda43f5dfe6236c066 (patch)
treeeb344591def11380b95fba62e71aa950e3671b87 /Tests/RunCMake/CMakeLists.txt
parentba92e11f8b461513566d5cc3c0b53b2215bb85f7 (diff)
downloadCMake-96242f8022fa4bc718ef36cda43f5dfe6236c066.zip
CMake-96242f8022fa4bc718ef36cda43f5dfe6236c066.tar.gz
CMake-96242f8022fa4bc718ef36cda43f5dfe6236c066.tar.bz2
Add options to run `ldd -u -r` as a "link-what-you-use" tool
Create a LINK_WHAT_YOU_USE target property and corresponding CMAKE_LINK_WHAT_YOU_USE variable to enable this behavior. Extend link commands by running `ldd -u -r` to detect shared libraries that are linked but not needed.
Diffstat (limited to 'Tests/RunCMake/CMakeLists.txt')
-rw-r--r--Tests/RunCMake/CMakeLists.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index d16e5e7..b6d1c38 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -307,6 +307,14 @@ if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]"
endif()
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ if(UNIX AND NOT CYGWIN)
+ execute_process(COMMAND ldd --help
+ OUTPUT_VARIABLE LDD_HELP)
+ if("${LDD_HELP}" MATCHES
+ "(-r, --function-relocs.*process data and function relocations.*-u, --unused.*print unused direct dependencies)")
+ add_RunCMake_test(LinkWhatYouUse)
+ endif()
+ endif()
add_executable(pseudo_tidy pseudo_tidy.c)
add_executable(pseudo_iwyu pseudo_iwyu.c)
add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>)