ENH: make relative paths optional and default off, and add a test for them

This commit is contained in:
Bill Hoffman 2004-03-31 10:01:52 -05:00
parent d1185c5910
commit d0cea4c7bb
5 changed files with 31 additions and 6 deletions

View File

@ -322,6 +322,17 @@ IF(BUILD_TESTING)
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin" --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin"
--test-command complex) --test-command complex)
ADD_TEST(complexRelativePaths ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Complex"
"${CMake_BINARY_DIR}/Tests/ComplexRelativePaths"
--build-generator ${CMAKE_GENERATOR}
--build-project complex
--build-makeprogram ${MAKEPROGRAM}
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexRelativePaths/bin"
--build-options -DCMAKE_USE_RELATIVE_PATHS:BOOL=ON
--test-command complex)
ENDIF(NOT COMPILER_IS_COMO) ENDIF(NOT COMPILER_IS_COMO)
ADD_TEST(Example ${CMAKE_CTEST_COMMAND} ADD_TEST(Example ${CMAKE_CTEST_COMMAND}

View File

@ -354,7 +354,7 @@ std::string cmLocalGenerator::GetFullTargetName(const char* n,
std::string cmLocalGenerator::ConvertToRelativeOutputPath(const char* p) std::string cmLocalGenerator::ConvertToRelativeOutputPath(const char* p)
{ {
if ( m_Makefile->GetDefinition("CMAKE_NO_RELATIVE_PATHS") ) if ( !m_Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS") )
{ {
return cmSystemTools::ConvertToOutputPath(p); return cmSystemTools::ConvertToOutputPath(p);
} }

View File

@ -32,6 +32,7 @@ cmLocalUnixMakefileGenerator::cmLocalUnixMakefileGenerator()
m_MakefileVariableSize = 0; m_MakefileVariableSize = 0;
m_IgnoreLibPrefix = false; m_IgnoreLibPrefix = false;
m_PassMakeflags = false; m_PassMakeflags = false;
m_UseRelativePaths = false;
} }
cmLocalUnixMakefileGenerator::~cmLocalUnixMakefileGenerator() cmLocalUnixMakefileGenerator::~cmLocalUnixMakefileGenerator()
@ -41,6 +42,7 @@ cmLocalUnixMakefileGenerator::~cmLocalUnixMakefileGenerator()
void cmLocalUnixMakefileGenerator::Generate(bool fromTheTop) void cmLocalUnixMakefileGenerator::Generate(bool fromTheTop)
{ {
m_UseRelativePaths = m_Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS");
// suppoirt override in output directories // suppoirt override in output directories
if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
{ {
@ -700,12 +702,12 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
if(emitted.insert(libpath).second) if(emitted.insert(libpath).second)
{ {
std::string fullLibPath; std::string fullLibPath;
if(!m_WindowsShell) if(!m_WindowsShell && m_UseRelativePaths)
{ {
fullLibPath = "\"`cd "; fullLibPath = "\"`cd ";
} }
fullLibPath += libpath; fullLibPath += libpath;
if(!m_WindowsShell) if(!m_WindowsShell && m_UseRelativePaths)
{ {
fullLibPath += ";pwd`\""; fullLibPath += ";pwd`\"";
} }
@ -1076,16 +1078,16 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
std::string outpath; std::string outpath;
std::string outdir = this->ConvertToRelativeOutputPath(m_LibraryOutputPath.c_str()); std::string outdir = this->ConvertToRelativeOutputPath(m_LibraryOutputPath.c_str());
if(!m_WindowsShell && outdir.size()) if(!m_WindowsShell && m_UseRelativePaths && outdir.size())
{ {
outpath = "\"`cd "; outpath = "\"`cd ";
} }
outpath += outdir; outpath += outdir;
if(!m_WindowsShell && outdir.size()) if(!m_WindowsShell && m_UseRelativePaths && outdir.size())
{ {
outpath += ";pwd`\"/"; outpath += ";pwd`\"/";
} }
if(outdir.size() == 0 && !m_WindowsShell) if(outdir.size() == 0 && m_UseRelativePaths && !m_WindowsShell)
{ {
outpath = "\"`pwd`\"/"; outpath = "\"`pwd`\"/";
} }

View File

@ -246,6 +246,7 @@ protected:
std::string m_ExecutableOutputPath; std::string m_ExecutableOutputPath;
std::string m_LibraryOutputPath; std::string m_LibraryOutputPath;
bool m_WindowsShell; bool m_WindowsShell;
bool m_UseRelativePaths;
bool m_PassMakeflags; bool m_PassMakeflags;
private: private:
}; };

View File

@ -1085,6 +1085,17 @@ int cmake::Configure()
"Single output directory for building all executables.", "Single output directory for building all executables.",
cmCacheManager::PATH); cmCacheManager::PATH);
} }
if(!m_CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS"))
{
m_CacheManager->AddCacheEntry("CMAKE_USE_RELATIVE_PATHS", false,
"If true, cmake will use relative paths in makefiles and projects.");
cmCacheManager::CacheIterator it =
m_CacheManager->GetCacheIterator("CMAKE_USE_RELATIVE_PATHS");
if ( !it.PropertyExists("ADVANCED") )
{
it.SetProperty("ADVANCED", "1");
}
}
if(cmSystemTools::GetFatalErrorOccured() && if(cmSystemTools::GetFatalErrorOccured() &&
(!this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") || (!this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") ||