From d45eb35350abc72887784802f1e093ad1c4ff5b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 22 Feb 2013 08:14:18 -0500 Subject: [PATCH] Tests: Generalize decision for 'make' tool supporting spaces Some make tools do not support spaces inside the source tree paths. Decide early whether to add tests that depend on support for spaces so we can use the result in a decision for any test. --- Tests/CMakeLists.txt | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9231605737..d74fffd70a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -50,6 +50,26 @@ if(BUILD_TESTING) set(TEST_CompileCommandOutput 1) endif() + set(MAKE_IS_GNU ) + if(${CMAKE_TEST_MAKEPROGRAM} MATCHES make) + execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version + RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) + if("${res}" STREQUAL "0") + if("${out}" MATCHES "GNU") + set(MAKE_IS_GNU 1) + endif() + endif() + endif() + + # some old versions of make simply cannot handle spaces in paths + if (MAKE_IS_GNU OR + "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR + "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode|Borland") + set(MAKE_SUPPORTS_SPACES 1) + else() + set(MAKE_SUPPORTS_SPACES 0) + endif() + set(build_generator_args --build-generator ${CMAKE_TEST_GENERATOR} --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} @@ -1238,22 +1258,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys") endif() - set(MAKE_IS_GNU ) - if(${CMAKE_TEST_MAKEPROGRAM} MATCHES make) - execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version - RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) - if("${res}" STREQUAL "0") - if("${out}" MATCHES "GNU") - set(MAKE_IS_GNU 1) - endif() - endif() - endif() - # only add this test on platforms that support it - # some old versions of make simply cannot handle spaces in paths - if (MAKE_IS_GNU OR - "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR - "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode|Borland") + if(MAKE_SUPPORTS_SPACES) add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SubDirSpaces" @@ -2396,7 +2402,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(TEST_CompileCommandOutput) set(CompileCommandOutput_EXTRA_OPTIONS - --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_IS_GNU}) + --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}) ADD_TEST_MACRO(CompileCommandOutput "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands") endif()