Browse Source

add_subdirectory: Fix error message on missing CMakeLists.txt (#15680)

Refactoring in commit v3.3.0-rc1~76^2 (cmMakefile: Handle CMP0014 before
configuring the generator, 2015-05-14) accidentally left the file name
"/CMakeLists.txt" in the error message.  Remove it and add a test case.
Brad King 10 years ago
parent
commit
c4d2f64f3c

+ 2 - 2
Source/cmMakefile.cxx

@@ -1564,8 +1564,8 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
     cmSystemTools::Message(msg.c_str());
     }
 
-  currentStart += "/CMakeLists.txt";
-  if(!cmSystemTools::FileExists(currentStart.c_str(), true))
+  std::string const currentStartFile = currentStart + "/CMakeLists.txt";
+  if (!cmSystemTools::FileExists(currentStartFile, true))
     {
     // The file is missing.  Check policy CMP0014.
     std::ostringstream e;

+ 1 - 0
Tests/RunCMake/CMakeLists.txt

@@ -118,6 +118,7 @@ add_RunCMake_test(Syntax)
 add_RunCMake_test(add_custom_command)
 add_RunCMake_test(add_custom_target)
 add_RunCMake_test(add_dependencies)
+add_RunCMake_test(add_subdirectory)
 add_RunCMake_test(build_command)
 add_RunCMake_test(execute_process)
 add_RunCMake_test(export)

+ 3 - 0
Tests/RunCMake/add_subdirectory/CMakeLists.txt

@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.2)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)

+ 1 - 0
Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt

@@ -0,0 +1 @@
+1

+ 5 - 0
Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt

@@ -0,0 +1,5 @@
+^CMake Error at DoesNotExist.cmake:1 \(add_subdirectory\):
+  add_subdirectory given source "DoesNotExist" which is not an existing
+  directory.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$

+ 1 - 0
Tests/RunCMake/add_subdirectory/DoesNotExist.cmake

@@ -0,0 +1 @@
+add_subdirectory(DoesNotExist)

+ 1 - 0
Tests/RunCMake/add_subdirectory/Missing-result.txt

@@ -0,0 +1 @@
+1

+ 8 - 0
Tests/RunCMake/add_subdirectory/Missing-stderr.txt

@@ -0,0 +1,8 @@
+^CMake Error at Missing.cmake:1 \(add_subdirectory\):
+  The source directory
+
+    .*/Tests/RunCMake/add_subdirectory/Missing
+
+  does not contain a CMakeLists.txt file.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$

+ 1 - 0
Tests/RunCMake/add_subdirectory/Missing.cmake

@@ -0,0 +1 @@
+add_subdirectory(Missing)

+ 0 - 0
Tests/RunCMake/add_subdirectory/Missing/Missing.txt


+ 4 - 0
Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake

@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(DoesNotExist)
+run_cmake(Missing)