diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2001-11-03 03:32:39 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2001-11-03 03:32:39 (GMT) |
commit | ef74458b34dcf2d25b3948c535d59273c2307546 (patch) | |
tree | 3bc5ea621a5d171395e19666ae8515109bd95e79 /Source | |
parent | 2fcf59b96b6ac41a1963c8b0f2b06d61c8f255a2 (diff) | |
download | CMake-ef74458b34dcf2d25b3948c535d59273c2307546.zip CMake-ef74458b34dcf2d25b3948c535d59273c2307546.tar.gz CMake-ef74458b34dcf2d25b3948c535d59273c2307546.tar.bz2 |
Add optional BEFORE param to INCLUDE_DIRECTORIES so that include dirs can be specified before the actual include dirs
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmIncludeDirectoryCommand.cxx | 17 | ||||
-rw-r--r-- | Source/cmIncludeDirectoryCommand.h | 2 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 12 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 |
4 files changed, 25 insertions, 8 deletions
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index d56fe5c..be8f277 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -43,15 +43,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // cmIncludeDirectoryCommand bool cmIncludeDirectoryCommand::InitialPass(std::vector<std::string> const& args) { - if(args.size() < 1 ) + if(args.size() < 1 ) { this->SetError("called with incorrect number of arguments"); return false; } - for(std::vector<std::string>::const_iterator i = args.begin(); - i != args.end(); ++i) + + std::vector<std::string>::const_iterator i = args.begin(); + + bool before = false; + if ((*i) == "BEFORE") + { + before = true; + ++i; + } + + for(; i != args.end(); ++i) { - m_Makefile->AddIncludeDirectory((*i).c_str()); + m_Makefile->AddIncludeDirectory((*i).c_str(), before); } return true; } diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 579e24a..d3764c6 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -92,7 +92,7 @@ public: virtual const char* GetFullDocumentation() { return - "INCLUDE_DIRECTORIES(dir1 dir2 ...)"; + "INCLUDE_DIRECTORIES([BEFORE] dir1 dir2 ...)"; } cmTypeMacro(cmIncludeDirectoryCommand, cmCommand); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e1c94da..8e40fbc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -564,7 +564,7 @@ void cmMakefile::AddSubdirDependency(const char* subdir, m_SubdirDepends[subdir].insert(dependency); } -void cmMakefile::AddIncludeDirectory(const char* inc) +void cmMakefile::AddIncludeDirectory(const char* inc, bool before) { // Don't add an include directory that is already present. Yes, // this linear search results in n^2 behavior, but n won't be @@ -573,7 +573,15 @@ void cmMakefile::AddIncludeDirectory(const char* inc) if(std::find(m_IncludeDirectories.begin(), m_IncludeDirectories.end(), inc) == m_IncludeDirectories.end()) { - m_IncludeDirectories.push_back(inc); + if (before) + { + // WARNING: this *is* expensive (linear time) since it's a vector + m_IncludeDirectories.insert(m_IncludeDirectories.begin(), inc); + } + else + { + m_IncludeDirectories.push_back(inc); + } } } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 60d028e..1de4656 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -218,7 +218,7 @@ public: /** * Add an include directory to the build. */ - void AddIncludeDirectory(const char*); + void AddIncludeDirectory(const char*, bool before = false); /** * Add a variable definition to the build. This variable |