From 078e35defbe6e0ee3b216dd2e83ca85d49920fc3 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 21 Nov 2012 10:23:17 -0500 Subject: NMake: Add a test to demonstrate EmptyDepends issue (#13392) --- Tests/CMakeLists.txt | 2 ++ Tests/EmptyDepends/CMakeLists.txt | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Tests/EmptyDepends/CMakeLists.txt diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index f2a198c..7dc2643 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -573,6 +573,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand") + ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND}) + add_test(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory" diff --git a/Tests/EmptyDepends/CMakeLists.txt b/Tests/EmptyDepends/CMakeLists.txt new file mode 100644 index 0000000..a24382c --- /dev/null +++ b/Tests/EmptyDepends/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) +project(EmptyDepends) + +include(CTest) + +set(extra_dep) + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/qrc_my.cxx + COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/qrc_my.cxx" + DEPENDS "${extra_dep}" "${CMAKE_BINARY_DIR}/my.qrc") + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/my.qrc + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/my.qrc) + +add_library(qrc SHARED ${CMAKE_BINARY_DIR}/qrc_my.cxx) -- cgit v0.12 From 7ae7d6650344f7a36216af8424abbf0b834688d1 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 21 Nov 2012 11:23:14 -0500 Subject: NMake: Fix problem with empty DEPENDS args (#13392) add_custom_command can have empty DEPENDS arguments, which was triggering invalid makefile generation for the NMake Makefiles generator. We were mistakenly emitting the build directory appended with "/" plus the empty string... which was then translated to a string ending in \" in build.make... which nmake choked on. The solution is not to emit any dependency when the input DEPENDS is the empty string. Return early from GetRealDependency in this empty input case. --- Source/cmLocalGenerator.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4952a8c..d48f43a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1875,6 +1875,14 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, // modify the name so stripping down to just the file name should // produce the target name in this case. std::string name = cmSystemTools::GetFilenameName(inName); + + // If the input name is the empty string, there is no real + // dependency. Short-circuit the other checks: + if(name == "") + { + return false; + } + if(cmSystemTools::GetFilenameLastExtension(name) == ".exe") { name = cmSystemTools::GetFilenameWithoutLastExtension(name); -- cgit v0.12