From 269a4b876a34483c5cb664499dc6b1634fa453ff Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 10 Sep 2010 16:17:39 -0400 Subject: [PATCH 1/4] Enable calling commands with : in argv[1] (#9963) The solution seems hackish, but it works: for NMake only, prepend a no-op command before each real command that begins with ". This is really a work-around for an NMake problem. When a command begins with ", nmake truncates the first argument to the command after the first : in that arg. It has a parsing problem. Workaround..., hackish..., but it should solve the issue for #9963 and its related friends. Also, modify the CustomCommand test to replicate the problem reported in issue #9963. Before the NMake specific code change, the test failed. Now, it passes. Ahhhhhh. --- Source/cmLocalUnixMakefileGenerator3.cxx | 11 +++++++++-- Tests/CMakeLists.txt | 2 +- Tests/CustomCommand/CMakeLists.txt | 17 +++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 004d19a2d..f04d0a0ad 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1062,9 +1062,16 @@ cmLocalUnixMakefileGenerator3 } } } - if (useCall && launcher.empty()) + if (launcher.empty()) { - cmd = "call " + cmd; + if (useCall) + { + cmd = "call " + cmd; + } + else if (this->NMake && cmd[0]=='"') + { + cmd = "echo >nul && " + cmd; + } } commands1.push_back(cmd); } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8e8d0ca6f..e4c979e12 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -376,7 +376,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-generator ${CMAKE_TEST_GENERATOR} --build-project CustomCommand --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin dir" --test-command CustomCommand ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand") diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 4fc9fb5d4..6664fd6cd 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -9,12 +9,12 @@ ADD_SUBDIRECTORY(GeneratedHeader) # # Lib and exe path # -SET (LIBRARY_OUTPUT_PATH - ${PROJECT_BINARY_DIR}/bin/ CACHE INTERNAL +SET (LIBRARY_OUTPUT_PATH + "${PROJECT_BINARY_DIR}/bin dir" CACHE INTERNAL "Single output directory for building all libraries.") -SET (EXECUTABLE_OUTPUT_PATH - ${PROJECT_BINARY_DIR}/bin/ CACHE INTERNAL +SET (EXECUTABLE_OUTPUT_PATH + "${PROJECT_BINARY_DIR}/bin dir" CACHE INTERNAL "Single output directory for building all executables.") ################################################################ @@ -221,6 +221,7 @@ ADD_CUSTOM_COMMAND(OUTPUT gen_redirect.c # Test non-trivial command line arguments in custom commands. SET(EXPECTED_ARGUMENTS) SET(CHECK_ARGS + -DPATH=c:/posix/path c:/posix/path c:\\windows\\path 'single-quotes' @@ -273,6 +274,8 @@ SET(CHECK_ARGS |nopipe "#two-pounds#" "one#pound" + ":two-colons:" + "one:colon" "#nocomment" "c:/posix/path/with space" "c:\\windows\\path\\with space" @@ -359,13 +362,15 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in @ONLY IMMEDIATE) ADD_EXECUTABLE(check_command_line ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c) +SET_PROPERTY(TARGET check_command_line + PROPERTY OUTPUT_NAME "check command line") # SET_TARGET_PROPERTIES(check_command_line PROPERTIES # COMPILE_FLAGS -DCHECK_COMMAND_LINE_VERBOSE) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/command_line_check COMMAND ${CMAKE_COMMAND} -DMARK_FILE=${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mark.cmake - COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line + COMMAND "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check command line" ${CHECK_ARGS} "" VERBATIM COMMENT "Checking custom command line escapes (single'quote)" @@ -375,7 +380,7 @@ SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/command_line_check ADD_CUSTOM_TARGET(do_check_command_line ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes" - COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line + COMMAND "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check command line" ${CHECK_ARGS} "" VERBATIM COMMENT "Checking custom target command line escapes ($dollar-signs$)" From 9d2e6489bf8e5087957ef578174e3b0516c32a50 Mon Sep 17 00:00:00 2001 From: David Cole Date: Sun, 12 Sep 2010 05:01:35 -0400 Subject: [PATCH 2/4] No extra spaces in CustomCommand test (#9963) The nightly dashboard showed that the following platforms had difficulties dealing with "bin dir" and/or "check command line" as directory and file names: AIX Borland 5.5, 5.6 and 5.8 IRIX NMake 6.0 OpenBSD VS 7.1 Watcom Re-visit later, after the release, to use spaces in the bin dir and in the target name where possible. --- Tests/CMakeLists.txt | 2 +- Tests/CustomCommand/CMakeLists.txt | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e4c979e12..8e8d0ca6f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -376,7 +376,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-generator ${CMAKE_TEST_GENERATOR} --build-project CustomCommand --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin dir" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin" --test-command CustomCommand ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand") diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 6664fd6cd..c6f6a7f36 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -9,12 +9,16 @@ ADD_SUBDIRECTORY(GeneratedHeader) # # Lib and exe path # +IF(NOT DEFINED bin_dir) + SET(bin_dir "bin") +ENDIF() + SET (LIBRARY_OUTPUT_PATH - "${PROJECT_BINARY_DIR}/bin dir" CACHE INTERNAL + ${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL "Single output directory for building all libraries.") SET (EXECUTABLE_OUTPUT_PATH - "${PROJECT_BINARY_DIR}/bin dir" CACHE INTERNAL + ${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL "Single output directory for building all executables.") ################################################################ @@ -362,15 +366,16 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in @ONLY IMMEDIATE) ADD_EXECUTABLE(check_command_line ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c) +SET(output_name "check_command_line") SET_PROPERTY(TARGET check_command_line - PROPERTY OUTPUT_NAME "check command line") + PROPERTY OUTPUT_NAME ${output_name}) # SET_TARGET_PROPERTIES(check_command_line PROPERTIES # COMPILE_FLAGS -DCHECK_COMMAND_LINE_VERBOSE) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/command_line_check COMMAND ${CMAKE_COMMAND} -DMARK_FILE=${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mark.cmake - COMMAND "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check command line" + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name} ${CHECK_ARGS} "" VERBATIM COMMENT "Checking custom command line escapes (single'quote)" @@ -380,7 +385,7 @@ SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/command_line_check ADD_CUSTOM_TARGET(do_check_command_line ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes" - COMMAND "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check command line" + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name} ${CHECK_ARGS} "" VERBATIM COMMENT "Checking custom target command line escapes ($dollar-signs$)" From 9b4ab06c2c46244c158b4349f1b2865f44a11a42 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 14 Sep 2010 10:36:43 -0400 Subject: [PATCH 3/4] Avoid CustomCommand test failure on VS71 (#9963) The new first arg in the test is the critical one to prove that the new NMake specific code works. The additional colons in the middle of the arg stream work fine everywhere else, but not on dash1.kitware with Visual Studio 7.1. Just avoid the failure for now by removing the unnecessary new args from the test. --- Tests/CustomCommand/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index c6f6a7f36..d2a0cf722 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -278,8 +278,6 @@ SET(CHECK_ARGS |nopipe "#two-pounds#" "one#pound" - ":two-colons:" - "one:colon" "#nocomment" "c:/posix/path/with space" "c:\\windows\\path\\with space" From a798bb7074dd45e4e375a3df69d08f62a17ab2ab Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 20 Sep 2010 13:20:15 -0400 Subject: [PATCH 4/4] Avoid CustomCommand test failure on VS71 (#9963) Test still failing on dash1.kitware. Give up on testing the new arg on MSVC71. Test it with newer nmakes instead. All other dashboards are fine with -DPATH=c:/posix/path as the first arg, so keep it except when MSVC71 is true. --- Tests/CustomCommand/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index d2a0cf722..76208d479 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -224,8 +224,12 @@ ADD_CUSTOM_COMMAND(OUTPUT gen_redirect.c ############################################################################## # Test non-trivial command line arguments in custom commands. SET(EXPECTED_ARGUMENTS) +SET(CHECK_ARGS) +IF(NOT MSVC71) + SET(CHECK_ARGS -DPATH=c:/posix/path) +ENDIF() SET(CHECK_ARGS - -DPATH=c:/posix/path + ${CHECK_ARGS} c:/posix/path c:\\windows\\path 'single-quotes'