From 0fe0523810b1408c94c722ebae8aa47429d55d6d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 9 Oct 2006 21:25:58 -0400 Subject: BUG: Fixed out-of-source subdirectories to work when they are also out-of-binary. Updated the OutOfSource test to test this feature. --- Source/cmMakefileTargetGenerator.cxx | 5 ++--- Tests/OutOfBinary/CMakeLists.txt | 2 ++ Tests/OutOfBinary/outlib.c | 2 ++ Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt | 2 +- Tests/OutOfSource/OutOfSourceSubdir/simple.cxx | 5 +++++ Tests/OutOfSource/SubDir/CMakeLists.txt | 5 +++++ 6 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Tests/OutOfBinary/CMakeLists.txt create mode 100644 Tests/OutOfBinary/outlib.c diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 449d37a..381df2e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/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(), diff --git a/Tests/OutOfBinary/CMakeLists.txt b/Tests/OutOfBinary/CMakeLists.txt new file mode 100644 index 0000000..fcf90bd --- /dev/null +++ b/Tests/OutOfBinary/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_LIBRARY(outlib outlib.c) + diff --git a/Tests/OutOfBinary/outlib.c b/Tests/OutOfBinary/outlib.c new file mode 100644 index 0000000..9ea579b --- /dev/null +++ b/Tests/OutOfBinary/outlib.c @@ -0,0 +1,2 @@ +int outlib() { return 456; } + diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt index 02ab4f6..bbdaa55 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt +++ b/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 diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx index 3c9be09..124b7f9 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx +++ b/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; } diff --git a/Tests/OutOfSource/SubDir/CMakeLists.txt b/Tests/OutOfSource/SubDir/CMakeLists.txt index 47fa54b..4fc48e1 100644 --- a/Tests/OutOfSource/SubDir/CMakeLists.txt +++ b/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 ) -- cgit v0.12