ソースを参照

Tests/RunCMake/BuildDepends: Enable more depfile cases with Ninja

Brad King 1 年間 前
コミット
48ced5fb12

+ 13 - 1
Tests/RunCMake/BuildDepends/CompileDepends.cmake

@@ -12,7 +12,7 @@ set(check_exes
   \"$<TARGET_FILE:main>\"
   )
 
-if (check_step EQUAL 2)
+if (RunCMake_GENERATOR MATCHES \"Make\" AND check_step EQUAL 2)
   include(\"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Makefile.cmake\")
   if (NOT CMAKE_DEPEND_INFO_FILES)
     set(RunCMake_TEST_FAILED \"Variable CMAKE_DEPEND_INFO_FILES not found.\")
@@ -46,4 +46,16 @@ if (check_step EQUAL 2)
     endforeach()
   endif()
 endif()
+
+if (RunCMake_GENERATOR STREQUAL \"Ninja\" AND check_step EQUAL 2)
+  execute_process(
+    COMMAND \${RunCMake_MAKE_PROGRAM} -t deps
+    WORKING_DIRECTORY \${RunCMake_TEST_BINARY_DIR}
+    OUTPUT_VARIABLE deps
+  )
+  if(NOT deps MATCHES \"CompileDepends.c\" OR NOT deps MATCHES \"CompileDepends.h\")
+    string(REPLACE deps \"\\n\" \"\\n  \" \"  \${deps}\")
+    set(RunCMake_TEST_FAILED \"Dependencies not detected correctly:\\n\${deps}\")
+  endif()
+endif()
 ")

+ 13 - 1
Tests/RunCMake/BuildDepends/CustomCommandDepends.cmake

@@ -20,7 +20,7 @@ set(check_exes
   \"$<TARGET_FILE:main>\"
   )
 
-if (check_step EQUAL 2)
+if (RunCMake_GENERATOR MATCHES \"Make\" AND check_step EQUAL 2)
   include(\"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Makefile.cmake\")
   if (NOT CMAKE_DEPEND_INFO_FILES)
     set(RunCMake_TEST_FAILED \"Variable CMAKE_DEPEND_INFO_FILES not found.\")
@@ -70,4 +70,16 @@ if (check_step EQUAL 2)
     endforeach()
   endif()
 endif()
+
+if (RunCMake_GENERATOR STREQUAL \"Ninja\" AND check_step EQUAL 2)
+  execute_process(
+    COMMAND \${RunCMake_MAKE_PROGRAM} -t deps
+    WORKING_DIRECTORY \${RunCMake_TEST_BINARY_DIR}
+    OUTPUT_VARIABLE deps
+  )
+  if(NOT deps MATCHES \"main.c:.*main.c.in\")
+    string(REPLACE deps \"\\n\" \"\\n  \" \"  \${deps}\")
+    set(RunCMake_TEST_FAILED \"Dependencies not detected correctly:\\n\${deps}\")
+  endif()
+endif()
 ")

+ 3 - 1
Tests/RunCMake/BuildDepends/RunCMakeTest.cmake

@@ -170,7 +170,9 @@ if ((RunCMake_GENERATOR STREQUAL "Unix Makefiles"
         OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
     OR (RunCMake_GENERATOR STREQUAL "NMake Makefiles"
       AND MSVC_VERSION GREATER 1300
-      AND CMAKE_C_COMPILER_ID STREQUAL "MSVC"))
+      AND CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+    OR RunCMake_GENERATOR MATCHES "Ninja"
+    )
   run_BuildDepends(CompileDepends)
   run_BuildDepends(CustomCommandDepends)
 endif()