summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2004-04-23 16:52:48 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2004-04-23 16:52:48 (GMT)
commit8b0b749a11138107189f9264494f828778c0cf8b (patch)
tree08419721f7f8169515c3ebf1bb7cae6179c935e8 /Source
parenteae3d4cf0679212099204db7dc40514a28b1c493 (diff)
downloadCMake-8b0b749a11138107189f9264494f828778c0cf8b.zip
CMake-8b0b749a11138107189f9264494f828778c0cf8b.tar.gz
CMake-8b0b749a11138107189f9264494f828778c0cf8b.tar.bz2
ENH: add SUBDIR PREORDER and fix clean for non-relative paths
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt10
-rw-r--r--Source/cmLocalUnixMakefileGenerator.cxx116
-rw-r--r--Source/cmLocalUnixMakefileGenerator.h4
-rw-r--r--Source/cmMakefile.cxx11
-rw-r--r--Source/cmMakefile.h16
-rw-r--r--Source/cmSubdirCommand.cxx8
6 files changed, 124 insertions, 41 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 3ba2ff1..13b2416 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -228,6 +228,16 @@ IF(BUILD_TESTING)
--build-two-config
--test-command simple)
+ ADD_TEST(PreOrder ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/PreOrder"
+ "${CMake_BINARY_DIR}/Tests/PreOrder"
+ --build-generator ${CMAKE_GENERATOR}
+ --build-project PreOrder
+ --build-makeprogram ${MAKEPROGRAM}
+ --build-two-config
+ --test-command simple)
+
ADD_TEST(conly ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/COnly"
diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx
index be05453..3bf17e1 100644
--- a/Source/cmLocalUnixMakefileGenerator.cxx
+++ b/Source/cmLocalUnixMakefileGenerator.cxx
@@ -1781,13 +1781,20 @@ void cmLocalUnixMakefileGenerator::OutputBuildTargetInDirWindows(std::ostream& f
const char* library,
const char* fullpath)
{
- std::string jumpBack =
- cmSystemTools::RelativePath(cmSystemTools::GetProgramPath(path).c_str(),
- m_Makefile->GetCurrentOutputDirectory());
+ std::string jumpBack;
+ if(m_UseRelativePaths)
+ {
+ cmSystemTools::Message("using relative paths??");
+ jumpBack = cmSystemTools::RelativePath(cmSystemTools::GetProgramPath(path).c_str(),
+ m_Makefile->GetCurrentOutputDirectory());
+ }
+ else
+ {
+ jumpBack = m_Makefile->GetCurrentOutputDirectory();
+ }
jumpBack = this->ConvertToOutputForExisting(jumpBack.c_str());
std::string wpath = this->ConvertToOutputForExisting(path);
std::string wfullpath = this->ConvertToOutputForExisting(fullpath);
-
fout << wfullpath
<< ":\n\tcd " << wpath << "\n"
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends\n"
@@ -2008,23 +2015,32 @@ BuildInSubDirectoryWindows(std::ostream& fout,
}
fout << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) " << target2 << "\n";
}
- std::string currentDir = dir;
- cmSystemTools::ConvertToUnixSlashes(currentDir);
- std::string cdback = "..";
- unsigned int i = 0;
- if(currentDir.size() > 2 && currentDir[0] == '.' && currentDir[1] == '/')
- {
- // start past ./ if it starts with ./
- i = 2;
- }
- for(; i < currentDir.size(); ++i)
+ std::string currentDir;
+ if(m_UseRelativePaths)
{
- if(currentDir[i] == '/')
+ currentDir = dir;
+ cmSystemTools::ConvertToUnixSlashes(currentDir);
+ std::string cdback = "..";
+ unsigned int i = 0;
+ if(currentDir.size() > 2 && currentDir[0] == '.' && currentDir[1] == '/')
{
- cdback += "/..";
+ // start past ./ if it starts with ./
+ i = 2;
}
+ for(; i < currentDir.size(); ++i)
+ {
+ if(currentDir[i] == '/')
+ {
+ cdback += "/..";
+ }
+ }
+ fout << "\tcd " << this->ConvertToOutputForExisting(cdback.c_str()) << "\n\n";
+ }
+ else
+ {
+ currentDir = m_Makefile->GetCurrentOutputDirectory();
+ fout << "\tcd " << this->ConvertToOutputForExisting(currentDir.c_str()) << "\n\n";
}
- fout << "\tcd " << this->ConvertToOutputForExisting(cdback.c_str()) << "\n\n";
}
@@ -2074,7 +2090,7 @@ OutputSubDirectoryVars(std::ostream& fout,
const char* target2,
const char* depend,
const std::vector<std::pair<cmStdString, bool> >& SubDirectories,
- bool silent)
+ bool silent, int order)
{
if(!depend)
{
@@ -2087,27 +2103,68 @@ OutputSubDirectoryVars(std::ostream& fout,
fout << "# Variable for making " << target << " in subdirectories.\n";
fout << var << " = ";
unsigned int ii;
+
+ // make sure all the pre-order subdirectories are fist
+ // other than that keep the same order that the user specified
+ std::vector<std::pair<cmStdString, bool> > orderedDirs;
+ // collect pre-order first
+ for(ii =0; ii < SubDirectories.size(); ii++)
+ {
+ if(m_Makefile->IsDirectoryPreOrder(SubDirectories[ii].first.c_str()))
+ {
+ orderedDirs.push_back(SubDirectories[ii]);
+ }
+ }
+ // now collect post order dirs
for(ii =0; ii < SubDirectories.size(); ii++)
+ {
+ if(!m_Makefile->IsDirectoryPreOrder(SubDirectories[ii].first.c_str()))
+ {
+ orderedDirs.push_back(SubDirectories[ii]);
+ }
+ }
+
+ for(ii =0; ii < orderedDirs.size(); ii++)
{
- if(!SubDirectories[ii].second)
+ if(!orderedDirs[ii].second)
+ {
+ continue;
+ }
+ if(order == 1 && m_Makefile->IsDirectoryPreOrder(orderedDirs[ii].first.c_str()))
+ {
+ continue;
+ }
+ if(order == 2 && !m_Makefile->IsDirectoryPreOrder(orderedDirs[ii].first.c_str()))
{
continue;
}
+
fout << " \\\n";
- std::string subdir = FixDirectoryName(SubDirectories[ii].first.c_str());
+ std::string subdir = FixDirectoryName(orderedDirs[ii].first.c_str());
fout << target << "_" << subdir.c_str();
}
fout << " \n\n";
fout << "# Targets for making " << target << " in subdirectories.\n";
std::string last = "";
- for(unsigned int cc =0; cc < SubDirectories.size(); cc++)
+ for(unsigned int cc =0; cc < orderedDirs.size(); cc++)
{
- if(!SubDirectories[cc].second)
+ if(!orderedDirs[cc].second)
{
continue;
+ }
+ std::string subdir = FixDirectoryName(orderedDirs[cc].first.c_str());
+ if(order == 1 && m_Makefile->IsDirectoryPreOrder(orderedDirs[cc].first.c_str()))
+ {
+ last = subdir;
+ continue;
+ }
+ if(order == 2 && !m_Makefile->IsDirectoryPreOrder(orderedDirs[cc].first.c_str()))
+ {
+ last = subdir;
+ continue;
}
- std::string subdir = FixDirectoryName(SubDirectories[cc].first.c_str());
+
fout << target << "_" << subdir.c_str() << ": " << depend;
// Make each subdirectory depend on previous one. This forces
@@ -2122,7 +2179,7 @@ OutputSubDirectoryVars(std::ostream& fout,
last = subdir;
std::string dir = m_Makefile->GetCurrentOutputDirectory();
dir += "/";
- dir += SubDirectories[cc].first;
+ dir += orderedDirs[cc].first;
this->BuildInSubDirectory(fout, dir.c_str(),
target1, target2, silent);
}
@@ -2148,7 +2205,14 @@ void cmLocalUnixMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout)
"default_target",
0, "$(TARGETS)",
SubDirectories,
- false);
+ false, 1);
+ this->OutputSubDirectoryVars(fout,
+ "SUBDIR_PREORDER_BUILD",
+ "default_target",
+ "default_target",
+ 0, "$(TARGETS)",
+ SubDirectories,
+ false, 2);
this->OutputSubDirectoryVars(fout, "SUBDIR_CLEAN", "clean",
"clean",
0, 0,
@@ -2442,7 +2506,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
this->OutputMakeRule(fout,
"default build rule",
"all",
- "cmake.depends $(TARGETS) $(SUBDIR_BUILD)",
+ "cmake.depends $(SUBDIR_PREORDER_BUILD) $(TARGETS) $(SUBDIR_BUILD)",
0);
this->OutputMakeRule(fout,
"clean generated files",
diff --git a/Source/cmLocalUnixMakefileGenerator.h b/Source/cmLocalUnixMakefileGenerator.h
index 713d1b5..c5a8a73 100644
--- a/Source/cmLocalUnixMakefileGenerator.h
+++ b/Source/cmLocalUnixMakefileGenerator.h
@@ -151,7 +151,7 @@ protected:
const char* target1,
const char* target2,
bool silent = false);
-
+ ///! order == 0, then all subdirs are output, 1 = post order, 2 = preorder
virtual void OutputSubDirectoryVars(std::ostream& fout,
const char* var,
const char* target,
@@ -160,7 +160,7 @@ protected:
const char* depend,
const std::vector<std::pair<cmStdString, bool> >&
SubDirectories,
- bool silent = false);
+ bool silent = false, int order = 0);
virtual void OutputMakeRule(std::ostream&,
const char* comment,
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index aa8b1af..b073bf9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -840,8 +840,17 @@ void cmMakefile::AddLinkDirectory(const char* dir)
}
}
-void cmMakefile::AddSubDirectory(const char* sub, bool topLevel)
+bool cmMakefile::IsDirectoryPreOrder(const char* dir)
{
+ return (m_SubDirectoryOrder.find(dir) != m_SubDirectoryOrder.end());
+}
+
+void cmMakefile::AddSubDirectory(const char* sub, bool topLevel, bool preorder)
+{
+ if(preorder)
+ {
+ m_SubDirectoryOrder[sub] = preorder;
+ }
std::pair<cmStdString, bool> p(sub, topLevel);
// make sure it isn't already there
if (std::find(m_SubDirectories.begin(),
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 194729e..39c937a 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -216,7 +216,7 @@ public:
/**
* Add a subdirectory to the build.
*/
- void AddSubDirectory(const char*, bool includeTopLevel=true);
+ void AddSubDirectory(const char*, bool includeTopLevel=true, bool preorder = false);
/**
* Add an include directory to the build.
@@ -276,16 +276,6 @@ public:
const std::vector<std::string> &srcs);
/**
- * Add a class/source file to the build.
- */
- //void AddSource(cmSourceFile& ,const char *srcListName);
-
- /**
- * Remove a class/source file from the build.
- */
- //void RemoveSource(cmSourceFile& ,const char *srcListName);
-
- /**
* Add a source group for consideration when adding a new source.
*/
void AddSourceGroup(const char* name, const char* regex=0);
@@ -648,6 +638,9 @@ public:
* Return a location of a file in cmake or custom modules directory
*/
std::string GetModulesFile(const char* name);
+
+ ///! Return true if the directory is preorder.
+ bool IsDirectoryPreOrder(const char* dir);
protected:
// add link libraries and directories to the target
@@ -720,6 +713,7 @@ private:
typedef std::map<cmStdString, cmStdString> StringStringMap;
StringStringMap m_MacrosMap;
+ std::map<cmStdString, bool> m_SubDirectoryOrder;
// used in AddDefinition for performance improvement
DefinitionMap::key_type m_TemporaryDefinitionKey;
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index 3bcd1a0..e2c52bd 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -26,6 +26,7 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args)
}
bool res = true;
bool intoplevel = true;
+ bool preorder = false;
for(std::vector<std::string>::const_iterator i = args.begin();
i != args.end(); ++i)
@@ -35,11 +36,16 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args)
intoplevel = false;
continue;
}
+ if(*i == "PREORDER")
+ {
+ preorder = true;
+ continue;
+ }
std::string directory = std::string(m_Makefile->GetCurrentDirectory()) +
"/" + i->c_str();
if ( cmSystemTools::FileIsDirectory(directory.c_str()) )
{
- m_Makefile->AddSubDirectory(i->c_str(), intoplevel);
+ m_Makefile->AddSubDirectory(i->c_str(), intoplevel, preorder);
}
else
{