瀏覽代碼

BUG: Fixed out-of-source subdirectories to work when they are also out-of-binary. Updated the OutOfSource test to test this feature.

Brad King 19 年之前
父節點
當前提交
0fe0523810

+ 2 - 3
Source/cmMakefileTargetGenerator.cxx

@@ -1048,9 +1048,8 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
                                                       bool relink)
 {
   // Compute the name of the driver target.
-  std::string dir = this->Makefile->GetStartOutputDirectory();
-  dir += "/";
-  dir += this->LocalGenerator->GetTargetDirectory(*this->Target);
+  std::string dir =
+    this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
   std::string buildTargetRuleName = dir;
   buildTargetRuleName += relink?"/preinstall":"/build";
   buildTargetRuleName = this->Convert(buildTargetRuleName.c_str(),

+ 2 - 0
Tests/OutOfBinary/CMakeLists.txt

@@ -0,0 +1,2 @@
+ADD_LIBRARY(outlib outlib.c)
+

+ 2 - 0
Tests/OutOfBinary/outlib.c

@@ -0,0 +1,2 @@
+int outlib() { return 456; }
+

+ 1 - 1
Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt

@@ -4,7 +4,7 @@ IF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")
   SET(BUILD_SHARED_LIBS 1)
   ADD_LIBRARY(testlib testlib.cxx)
   ADD_EXECUTABLE (simple simple.cxx ../simple.cxx)
-  TARGET_LINK_LIBRARIES(simple testlib)
+  TARGET_LINK_LIBRARIES(simple testlib outlib)
 ENDIF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")
 
 # test getting a definition from a subdir

+ 5 - 0
Tests/OutOfSource/OutOfSourceSubdir/simple.cxx

@@ -5,6 +5,7 @@
 #include "testdp.h"
 
 extern int simple();
+extern "C" int outlib();
 
 int main ()
 {
@@ -21,5 +22,9 @@ int main ()
     {
     return -1;
     }
+  if(outlib() != 456)
+    {
+    return -4;
+    }
   return 0;
 }

+ 5 - 0
Tests/OutOfSource/SubDir/CMakeLists.txt

@@ -1,3 +1,8 @@
 PROJECT(ANOTHER_PROJ)
+
+# subdir to an out of source and out of binary directory
+ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/../OutOfBinary
+                 ${OutOfSource_BINARY_DIR}/../OutOfBinary)
+
 # subdir to a sibling dir
 ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/${KEN}OutOfSourceSubdir OutOfSourceSubdir )