diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-08-18 12:25:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-01 13:25:19 (GMT) |
commit | f14b390198222f5d7eca9e5109fabcb0188da762 (patch) | |
tree | ad67bb4af6f85bf6fb2f4b157881a2f1e1a4a9da /Tests/RunCMake/GenEx-TARGET_FILE | |
parent | 5294febcaf378589dba49801321d19f93f67464e (diff) | |
download | CMake-f14b390198222f5d7eca9e5109fabcb0188da762.zip CMake-f14b390198222f5d7eca9e5109fabcb0188da762.tar.gz CMake-f14b390198222f5d7eca9e5109fabcb0188da762.tar.bz2 |
GenEx: Remove unneeded dependencies from target info queries
Only generate a graph dependency between a custom command and
a target when the custom command queries for the file path
of an artifact of the target.
This makes generator expressions such as `TARGET_FILE_DIR`
behave the same way as `TARGET_PROPERTY` which never generated
a graph dependency.
Diffstat (limited to 'Tests/RunCMake/GenEx-TARGET_FILE')
5 files changed, 34 insertions, 1 deletions
diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake index ccec633..55b0f9b 100644 --- a/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake @@ -2,8 +2,10 @@ include(RunCMake) run_cmake(TARGET_FILE-recursion) run_cmake(OUTPUT_NAME-recursion) -run_cmake(TARGET_FILE_PREFIX) +run_cmake(TARGET_FILE_DIR-dependency) +run_cmake(TARGET_FILE_DIR-no-dependency) run_cmake(TARGET_FILE_PREFIX-imported-target) +run_cmake(TARGET_FILE_PREFIX) run_cmake(TARGET_FILE_PREFIX-non-valid-target) run_cmake(TARGET_LINKER_FILE_PREFIX-non-valid-target) run_cmake(TARGET_FILE_SUFFIX) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-result.txt b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-stderr.txt b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-stderr.txt new file mode 100644 index 0000000..0a79032 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-stderr.txt @@ -0,0 +1,6 @@ +.*Policy CMP0112 is not set.* +.*Dependency being added to target.* +.*exec1.* +CMake Error: The inter-target dependency graph.* +.*"exec1" of type EXECUTABLE + depends on "copyFile" \(strong\) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency.cmake new file mode 100644 index 0000000..e18ccd9 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency.cmake @@ -0,0 +1,12 @@ +set(CMAKE_POLICY_WARNING_CMP0112 TRUE) + +enable_language (C) + +add_executable (exec1 empty.c) + +add_custom_target(copyFile + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" + "$<TARGET_FILE_DIR:exec1>/$<TARGET_FILE_BASE_NAME:exec1>_e.c" +) +add_dependencies(exec1 copyFile) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-no-dependency.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-no-dependency.cmake new file mode 100644 index 0000000..e048e10 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-no-dependency.cmake @@ -0,0 +1,12 @@ +cmake_policy(SET CMP0112 NEW) + +enable_language (C) + +add_executable (exec1 empty.c) + +add_custom_target(copyFile + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" + "$<TARGET_FILE_DIR:exec1>/$<TARGET_FILE_BASE_NAME:exec1>_e.c" +) +add_dependencies(exec1 copyFile) |