From 08699cec6807bd3104fd0aae11377662bb1db957 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 24 Jan 2020 11:03:30 -0500 Subject: add_custom_command: Fix dependency on macOS framework target When the `DEPENDS` option names a logical target name, convert to the "real" path of that target rather than any of the symlink-provided alternative file names. This makes the dependencies consistent with the outputs named by link rules producing the target artifacts. Fixes: #20264 --- Source/cmLocalGenerator.cxx | 3 ++- Tests/CustomCommand/CMakeLists.txt | 8 ++++++++ Tests/CustomCommand/mac_fw.c | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Tests/CustomCommand/mac_fw.c diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index d1a3454..261413a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1969,7 +1969,8 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::MODULE_LIBRARY: case cmStateEnums::UNKNOWN_LIBRARY: - dep = target->GetLocation(config); + dep = target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true); return true; case cmStateEnums::OBJECT_LIBRARY: // An object library has no single file on which to depend. diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 196fea3..53d56bf 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -566,3 +566,11 @@ add_custom_command( ) add_custom_target(depends_on_in_rel_source_path ALL DEPENDS "depends_on_in_rel_source_path.txt") + +add_library(mac_fw SHARED mac_fw.c) +set_target_properties(mac_fw PROPERTIES + FRAMEWORK 1 + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib + ) +add_custom_command(OUTPUT mac_fw.txt COMMAND ${CMAKE_COMMAND} -E touch mac_fw.txt DEPENDS mac_fw) +add_custom_target(drive_mac_fw ALL DEPENDS mac_fw.txt) diff --git a/Tests/CustomCommand/mac_fw.c b/Tests/CustomCommand/mac_fw.c new file mode 100644 index 0000000..cb35b44 --- /dev/null +++ b/Tests/CustomCommand/mac_fw.c @@ -0,0 +1,4 @@ +int mac_fw(void) +{ + return 0; +} -- cgit v0.12