Procházet zdrojové kódy

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.
Brad King před 13 roky
rodič
revize
d45eb35350
1 změnil soubory, kde provedl 22 přidání a 16 odebrání
  1. 22 16
      Tests/CMakeLists.txt

+ 22 - 16
Tests/CMakeLists.txt

@@ -50,6 +50,26 @@ if(BUILD_TESTING)
     set(TEST_CompileCommandOutput 1)
     set(TEST_CompileCommandOutput 1)
   endif()
   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
   set(build_generator_args
     --build-generator ${CMAKE_TEST_GENERATOR}
     --build-generator ${CMAKE_TEST_GENERATOR}
     --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
     --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")
     list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys")
   endif()
   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}
     add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
       --build-and-test
       --build-and-test
       "${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
       "${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
@@ -2396,7 +2402,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
 
 
   if(TEST_CompileCommandOutput)
   if(TEST_CompileCommandOutput)
     set(CompileCommandOutput_EXTRA_OPTIONS
     set(CompileCommandOutput_EXTRA_OPTIONS
-      --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_IS_GNU})
+      --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES})
     ADD_TEST_MACRO(CompileCommandOutput
     ADD_TEST_MACRO(CompileCommandOutput
       "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
       "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
   endif()
   endif()