From 7ad218dddc05ef33140fef464796fe435fd18bfc Mon Sep 17 00:00:00 2001 From: king Date: Fri, 31 Jul 2009 13:19:19 +0000 Subject: [PATCH] Set current directory variables in CTest scripts The commit "Fix get_filename_component ABSOLUTE mode" broke the code get_filename_component(cwd . ABSOLUTE) because CTest scripts did not make cmMakefile::GetCurrentDirectory() available. This commit fixes the problem by setting the proper information on CTest script instances of cmMakefile. This also makes CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR available to CTest scripts. They are set to the working directory at script startup. --- Source/CTest/cmCTestScriptHandler.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 776f24570..a2abc0ea3 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestScriptHandler.cxx,v $ Language: C++ - Date: $Date: 2009-07-28 14:46:46 $ - Version: $Revision: 1.52 $ + Date: $Date: 2009-07-31 13:19:19 $ + Version: $Revision: 1.53 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -337,6 +337,12 @@ void cmCTestScriptHandler::CreateCMake() this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(); this->Makefile = this->LocalGenerator->GetMakefile(); + // Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR. + // Also, some commands need Makefile->GetCurrentDirectory(). + std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); + this->Makefile->SetStartDirectory(cwd.c_str()); + this->Makefile->SetStartOutputDirectory(cwd.c_str()); + // remove all cmake commands which are not scriptable, since they can't be // used in ctest scripts this->CMake->RemoveUnscriptableCommands(); -- 2.11.4.GIT