diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-04-26 21:32:56 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-04-26 21:32:56 (GMT) |
commit | d6090a2395a2e8e0c506e62a95e0e9dd197c6572 (patch) | |
tree | 3030c69e7dcc93a84fe308a73db6b45044661d4b /Source | |
parent | 62fec96d993975775410ebc2dceaa65b03a12ae2 (diff) | |
download | CMake-d6090a2395a2e8e0c506e62a95e0e9dd197c6572.zip CMake-d6090a2395a2e8e0c506e62a95e0e9dd197c6572.tar.gz CMake-d6090a2395a2e8e0c506e62a95e0e9dd197c6572.tar.bz2 |
ENH: When source file is in subdirectory put object file in subdirectory. Fixes Bug #290 - Source files in subdirectories should produce object files in subdirectories
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Source/cmSourceFile.cxx | 22 |
2 files changed, 17 insertions, 9 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 13b2416..d38c37f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -580,7 +580,9 @@ IF(BUILD_TESTING) --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${MAKEPROGRAM} --build-project SUBDIR - --test-command test "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" + --test-command test + "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" + "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o" ) IF (APPLE) diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 138d5d2..b8a547a 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -27,9 +27,16 @@ void cmSourceFile::SetName(const char* name, const char* dir, const std::vector<std::string>& sourceExts, const std::vector<std::string>& headerExts) { + this->SetProperty("HEADER_FILE_ONLY","1"); - m_SourceName = name; + m_SourceName = cmSystemTools::GetFilenamePath(name); + if ( m_SourceName.size() > 0 ) + { + m_SourceName += "/"; + } + m_SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name); + std::string pathname = dir; // the name might include the full path already, so @@ -47,7 +54,7 @@ void cmSourceFile::SetName(const char* name, const char* dir, // First try and see whether the listed file can be found // as is without extensions added on. - pathname += m_SourceName; + pathname += name; std::string hname = pathname; if(cmSystemTools::FileExists(hname.c_str())) { @@ -55,14 +62,13 @@ void cmSourceFile::SetName(const char* name, const char* dir, if(pos != std::string::npos) { m_SourceExtension = hname.substr(pos+1, hname.size()-pos); - std::string::size_type pos2 = hname.rfind('/'); - if(pos2 != std::string::npos) + if ( cmSystemTools::FileIsFullPath(name) ) { + std::string::size_type pos2 = hname.rfind('/'); + if(pos2 != std::string::npos) + { m_SourceName = hname.substr(pos2+1, pos - pos2-1); - } - else - { - m_SourceName = hname.substr(0, pos); + } } } |