diff options
author | Brad King <brad.king@kitware.com> | 2016-06-17 15:06:44 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-06-17 15:06:44 (GMT) |
commit | e4cb7d76095c429690255620a101b1a6f66f65df (patch) | |
tree | f65370811868c80fa3209bc76fff540182d1f19b /Tests | |
parent | 5889eb43eaad2e377cee36f813872ddb381b2e43 (diff) | |
parent | a0902efaa747d567fdd35729c8f0dac7b4fbee6d (diff) | |
download | CMake-e4cb7d76095c429690255620a101b1a6f66f65df.zip CMake-e4cb7d76095c429690255620a101b1a6f66f65df.tar.gz CMake-e4cb7d76095c429690255620a101b1a6f66f65df.tar.bz2 |
Merge topic 'link_what_you_use'
a0902efa Help: Add notes for topic 'link_what_you_use'
96242f80 Add options to run `ldd -u -r` as a "link-what-you-use" tool
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/C-Build-stdout.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/C-launch-Build-stdout.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/C-launch.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/C.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/CXX-Build-stdout.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/CXX-launch-Build-stdout.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/CXX-launch.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/CXX.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/RunCMakeTest.cmake | 21 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/main.c | 4 | ||||
-rw-r--r-- | Tests/RunCMake/LinkWhatYouUse/main.cxx | 4 |
13 files changed, 62 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>) diff --git a/Tests/RunCMake/LinkWhatYouUse/C-Build-stdout.txt b/Tests/RunCMake/LinkWhatYouUse/C-Build-stdout.txt new file mode 100644 index 0000000..95eafad --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/C-Build-stdout.txt @@ -0,0 +1,2 @@ +.*Warning: Unused direct dependencies.* +.*libm.* diff --git a/Tests/RunCMake/LinkWhatYouUse/C-launch-Build-stdout.txt b/Tests/RunCMake/LinkWhatYouUse/C-launch-Build-stdout.txt new file mode 100644 index 0000000..95eafad --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/C-launch-Build-stdout.txt @@ -0,0 +1,2 @@ +.*Warning: Unused direct dependencies.* +.*libm.* diff --git a/Tests/RunCMake/LinkWhatYouUse/C-launch.cmake b/Tests/RunCMake/LinkWhatYouUse/C-launch.cmake new file mode 100644 index 0000000..e66ca20 --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/C-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C.cmake) diff --git a/Tests/RunCMake/LinkWhatYouUse/C.cmake b/Tests/RunCMake/LinkWhatYouUse/C.cmake new file mode 100644 index 0000000..4c3f428 --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/C.cmake @@ -0,0 +1,4 @@ +enable_language(C) +set(CMAKE_LINK_WHAT_YOU_USE TRUE) +add_executable(main main.c) +target_link_libraries(main m) diff --git a/Tests/RunCMake/LinkWhatYouUse/CMakeLists.txt b/Tests/RunCMake/LinkWhatYouUse/CMakeLists.txt new file mode 100644 index 0000000..18dfd26 --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/LinkWhatYouUse/CXX-Build-stdout.txt b/Tests/RunCMake/LinkWhatYouUse/CXX-Build-stdout.txt new file mode 100644 index 0000000..95eafad --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/CXX-Build-stdout.txt @@ -0,0 +1,2 @@ +.*Warning: Unused direct dependencies.* +.*libm.* diff --git a/Tests/RunCMake/LinkWhatYouUse/CXX-launch-Build-stdout.txt b/Tests/RunCMake/LinkWhatYouUse/CXX-launch-Build-stdout.txt new file mode 100644 index 0000000..95eafad --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/CXX-launch-Build-stdout.txt @@ -0,0 +1,2 @@ +.*Warning: Unused direct dependencies.* +.*libm.* diff --git a/Tests/RunCMake/LinkWhatYouUse/CXX-launch.cmake b/Tests/RunCMake/LinkWhatYouUse/CXX-launch.cmake new file mode 100644 index 0000000..3002c9d --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/CXX-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX.cmake) diff --git a/Tests/RunCMake/LinkWhatYouUse/CXX.cmake b/Tests/RunCMake/LinkWhatYouUse/CXX.cmake new file mode 100644 index 0000000..9555832 --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/CXX.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +set(CMAKE_LINK_WHAT_YOU_USE TRUE) +add_executable(main main.cxx) +target_link_libraries(main m) diff --git a/Tests/RunCMake/LinkWhatYouUse/RunCMakeTest.cmake b/Tests/RunCMake/LinkWhatYouUse/RunCMakeTest.cmake new file mode 100644 index 0000000..897f568 --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/RunCMakeTest.cmake @@ -0,0 +1,21 @@ +include(RunCMake) + + +function(run_lwyu lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${lang}) + + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .) +endfunction() + +run_lwyu(CXX) +run_lwyu(C) +if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_lwyu(C-launch) + run_lwyu(CXX-launch) +endif() diff --git a/Tests/RunCMake/LinkWhatYouUse/main.c b/Tests/RunCMake/LinkWhatYouUse/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/LinkWhatYouUse/main.cxx b/Tests/RunCMake/LinkWhatYouUse/main.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |