From 09ba0a0a31ccc019020092f8cd219e26fb44fa03 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 23 Dec 2003 15:01:10 -0500 Subject: [PATCH] BUG: keep more of the case information --- Source/cmLocalGenerator.cxx | 69 ++++++++++++++++++++++++++-------- Source/cmTryCompileCommand.cxx | 9 +++-- Source/cmake.cxx | 6 +++ Source/cmake.h | 8 ++++ 4 files changed, 74 insertions(+), 18 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 66357f57c..1de737973 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -73,11 +73,6 @@ std::string cmLocalGenerator::ConvertToRelativeOutputPath(const char* p) m_CurrentOutputDirectory = m_Makefile->GetCurrentOutputDirectory(); m_HomeOutputDirectory = m_Makefile->GetHomeOutputDirectory(); m_HomeDirectory = m_Makefile->GetHomeDirectory(); -#if defined(_WIN32) || defined(__APPLE__) - m_CurrentOutputDirectory = cmSystemTools::LowerCase(m_CurrentOutputDirectory); - m_HomeOutputDirectory = cmSystemTools::LowerCase(m_HomeOutputDirectory); - m_HomeDirectory = cmSystemTools::LowerCase(m_HomeDirectory); -#endif if(m_RelativePathToSourceDir.size() == 0) { m_RelativePathToSourceDir = cmSystemTools::RelativePath( @@ -102,16 +97,53 @@ std::string cmLocalGenerator::ConvertToRelativeOutputPath(const char* p) // Do the work of converting to a relative path std::string pathIn = p; -#if defined(_WIN32) || defined(__APPLE__) - pathIn = cmSystemTools::LowerCase(pathIn); -#endif - std::string ret = pathIn; - cmSystemTools::ReplaceString(ret, m_CurrentOutputDirectory.c_str(), ""); - cmSystemTools::ReplaceString(ret, m_HomeDirectory.c_str(), - m_RelativePathToSourceDir.c_str()); - cmSystemTools::ReplaceString(ret, m_HomeOutputDirectory.c_str(), - m_RelativePathToBinaryDir.c_str()); + if(m_CurrentOutputDirectory.size() <= ret.size()) + { + std::string sub = ret.substr(0, m_CurrentOutputDirectory.size()); + if( +#if defined(_WIN32) || defined(__APPLE__) + cmSystemTools::LowerCase(sub) == + cmSystemTools::LowerCase(m_CurrentOutputDirectory) +#else + sub == m_CurrentOutputDirectory +#endif + ) + { + ret = ret.substr(m_CurrentOutputDirectory.size(), ret.npos); + } + } + if(m_HomeDirectory.size() <= ret.size()) + { + std::string sub = ret.substr(0, m_HomeDirectory.size()); + if( +#if defined(_WIN32) || defined(__APPLE__) + cmSystemTools::LowerCase(sub) == + cmSystemTools::LowerCase(m_HomeDirectory) +#else + sub == m_HomeDirectory +#endif + ) + { + ret = m_RelativePathToSourceDir + ret.substr(m_HomeDirectory.size(), ret.npos); + } + } + if(m_HomeOutputDirectory.size() <= ret.size()) + { + std::string sub = ret.substr(0, m_HomeOutputDirectory.size()); + if( +#if defined(_WIN32) || defined(__APPLE__) + cmSystemTools::LowerCase(sub) == + cmSystemTools::LowerCase(m_HomeOutputDirectory) +#else + sub == m_HomeOutputDirectory +#endif + ) + { + ret = m_RelativePathToBinaryDir + ret.substr(m_HomeOutputDirectory.size(), ret.npos); + } + } + std::string relpath = m_RelativePathToBinaryDir; if(relpath.size()) { @@ -121,7 +153,14 @@ std::string cmLocalGenerator::ConvertToRelativeOutputPath(const char* p) { relpath = "."; } - if(ret == m_HomeOutputDirectoryNoSlash) + if( +#if defined(_WIN32) || defined(__APPLE__) + cmSystemTools::LowerCase(ret) == + cmSystemTools::LowerCase(m_HomeOutputDirectoryNoSlash) +#else + ret == m_HomeOutputDirectoryNoSlash +#endif + ) { ret = relpath; } diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 6bea62d00..3719c6ffb 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -15,9 +15,9 @@ =========================================================================*/ #include "cmTryCompileCommand.h" +#include "cmake.h" #include "cmCacheManager.h" #include "cmListFileCache.h" - #include int cmTryCompileCommand::CoreTryCompileCode( @@ -236,9 +236,11 @@ int cmTryCompileCommand::CoreTryCompileCode( if (srcFileSignature && clean) { cmListFileCache::GetInstance()->FlushCache(outFileName.c_str()); - cmTryCompileCommand::CleanupFiles(binaryDirectory); + if(!mf->GetCMakeInstance()->GetDebugTryCompile()) + { + cmTryCompileCommand::CleanupFiles(binaryDirectory); + } } - return res; } @@ -266,6 +268,7 @@ void cmTryCompileCommand::CleanupFiles(const char* binDir) { return; } + std::string bdir = binDir; if(bdir.find("CMakeTmp") == std::string::npos) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index bba8a382b..19172f9b5 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -64,6 +64,7 @@ void cmNeedBackwardsCompatibility(const std::string& variable, cmake::cmake() { + m_DebugTryCompile = false; #ifdef __APPLE__ struct rlimit rlp; if(!getrlimit(RLIMIT_STACK, &rlp)) @@ -320,6 +321,11 @@ void cmake::SetArgs(const std::vector& args) { // skip for now } + else if(arg.find("--debug-trycompile",0) == 0) + { + std::cout << "debug trycompile on\n"; + this->DebugTryCompileOn(); + } else if(arg.find("-G",0) == 0) { std::string value = arg.substr(2); diff --git a/Source/cmake.h b/Source/cmake.h index eca769448..d81807043 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -1,3 +1,5 @@ +#ifndef cmake_h +#define cmake_h /*========================================================================= Program: CMake - Cross-Platform Makefile Generator @@ -252,6 +254,10 @@ class cmake void SetScriptMode(bool mode) { m_ScriptMode = mode; } bool GetScriptMode() { return m_ScriptMode; } + ///! Debug the try compile stuff by not delelting the files + bool GetDebugTryCompile(){return m_DebugTryCompile;} + void DebugTryCompileOn(){m_DebugTryCompile = true;} + protected: typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)(); typedef std::map RegisteredGeneratorsMap; @@ -294,6 +300,7 @@ private: std::string m_CMakeCommand; const char* m_CXXEnvironment; const char* m_CCEnvironment; + bool m_DebugTryCompile; }; #define CMAKE_STANDARD_OPTIONS_TABLE \ @@ -323,3 +330,4 @@ private: "included in each directory of a source tree with the name CMakeLists.txt. " \ "Users build a project by using CMake to generate a build system " \ "for a native tool on their platform.", 0} +#endif