summaryrefslogtreecommitdiff
path: root/Source/cmFindPathCommand.cxx
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2017-10-11 15:16:57 +0900
committerMyungJoo Ham <myungjoo.ham@samsung.com>2017-10-11 15:16:57 +0900
commit915c76ded744c0f5f151402b9fa69f3fd8452573 (patch)
treeca6a387466543248890f346847acaa8343989b22 /Source/cmFindPathCommand.cxx
parent317dbdb79761ef65e45c7358cfc7571c6afa54ad (diff)
downloadcmake-915c76ded744c0f5f151402b9fa69f3fd8452573.tar.gz
cmake-915c76ded744c0f5f151402b9fa69f3fd8452573.tar.bz2
cmake-915c76ded744c0f5f151402b9fa69f3fd8452573.zip
Imported Upstream version 3.9.4upstream/3.9.4
Diffstat (limited to 'Source/cmFindPathCommand.cxx')
-rw-r--r--Source/cmFindPathCommand.cxx227
1 files changed, 72 insertions, 155 deletions
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index 6a432984d..d3541ca94 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -1,18 +1,14 @@
-/*============================================================================
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFindPathCommand.h"
- Distributed under the OSI-approved BSD License (the "License");
- see accompanying file Copyright.txt for details.
+#include "cmsys/Glob.hxx"
- This software is distributed WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the License for more information.
-============================================================================*/
-#include "cmFindPathCommand.h"
-#include "cmCacheManager.h"
+#include "cmMakefile.h"
+#include "cmStateTypes.h"
+#include "cmSystemTools.h"
-#include <cmsys/Glob.hxx>
+class cmExecutionStatus;
cmFindPathCommand::cmFindPathCommand()
{
@@ -20,223 +16,144 @@ cmFindPathCommand::cmFindPathCommand()
this->IncludeFileInPath = false;
}
-void cmFindPathCommand::GenerateDocumentation()
-{
- this->cmFindBase::GenerateDocumentation();
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "FIND_XXX", "find_path");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "CMAKE_XXX_PATH", "CMAKE_INCLUDE_PATH");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "CMAKE_XXX_MAC_PATH",
- "CMAKE_FRAMEWORK_PATH");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "CMAKE_SYSTEM_XXX_MAC_PATH",
- "CMAKE_SYSTEM_FRAMEWORK_PATH");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "XXX_SYSTEM", "INCLUDE");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "CMAKE_SYSTEM_XXX_PATH",
- "CMAKE_SYSTEM_INCLUDE_PATH");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "SEARCH_XXX_DESC",
- "directory containing the named file");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "SEARCH_XXX", "file in a directory");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "XXX_SUBDIR", "include");
- cmSystemTools::ReplaceString(
- this->GenericDocumentation,
- "XXX_EXTRA_PREFIX_ENTRY",
- " <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and\n");
- cmSystemTools::ReplaceString(this->GenericDocumentation,
- "CMAKE_FIND_ROOT_PATH_MODE_XXX",
- "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE");
- if(!this->IncludeFileInPath)
- {
- this->GenericDocumentation +=
- "\n"
- "When searching for frameworks, if the file is specified as "
- "A/b.h, then the framework search will look for "
- "A.framework/Headers/b.h. "
- "If that is found the path will be set to the path to the framework. "
- "CMake will convert this to the correct -F option to include the "
- "file. ";
- }
-}
-
// cmFindPathCommand
-bool cmFindPathCommand
-::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &)
+bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn,
+ cmExecutionStatus&)
{
this->VariableDocumentation = "Path to a file.";
this->CMakePathName = "INCLUDE";
- if(!this->ParseArguments(argsIn))
- {
+ if (!this->ParseArguments(argsIn)) {
return false;
- }
- if(this->AlreadyInCache)
- {
+ }
+ if (this->AlreadyInCache) {
// If the user specifies the entry on the command line without a
// type we should add the type and docstring but keep the original
// value.
- if(this->AlreadyInCacheWithoutMetaInfo)
- {
+ if (this->AlreadyInCacheWithoutMetaInfo) {
this->Makefile->AddCacheDefinition(
- this->VariableName.c_str(), "",
- this->VariableDocumentation.c_str(),
- (this->IncludeFileInPath ?
- cmCacheManager::FILEPATH :cmCacheManager::PATH)
- );
- }
- return true;
+ this->VariableName, "", this->VariableDocumentation.c_str(),
+ (this->IncludeFileInPath ? cmStateEnums::FILEPATH
+ : cmStateEnums::PATH));
}
+ return true;
+ }
std::string result = this->FindHeader();
- if(result.size() != 0)
- {
- this->Makefile->AddCacheDefinition
- (this->VariableName.c_str(), result.c_str(),
- this->VariableDocumentation.c_str(),
- (this->IncludeFileInPath) ?
- cmCacheManager::FILEPATH :cmCacheManager::PATH);
+ if (!result.empty()) {
+ this->Makefile->AddCacheDefinition(
+ this->VariableName, result.c_str(), this->VariableDocumentation.c_str(),
+ (this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH);
return true;
- }
- this->Makefile->AddCacheDefinition
- (this->VariableName.c_str(),
- (this->VariableName + "-NOTFOUND").c_str(),
- this->VariableDocumentation.c_str(),
- (this->IncludeFileInPath) ?
- cmCacheManager::FILEPATH :cmCacheManager::PATH);
+ }
+ this->Makefile->AddCacheDefinition(
+ this->VariableName, (this->VariableName + "-NOTFOUND").c_str(),
+ this->VariableDocumentation.c_str(),
+ (this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH);
return true;
}
-//----------------------------------------------------------------------------
std::string cmFindPathCommand::FindHeader()
{
std::string header;
- if(this->SearchFrameworkFirst || this->SearchFrameworkOnly)
- {
+ if (this->SearchFrameworkFirst || this->SearchFrameworkOnly) {
header = this->FindFrameworkHeader();
- }
- if(header.empty() && !this->SearchFrameworkOnly)
- {
+ }
+ if (header.empty() && !this->SearchFrameworkOnly) {
header = this->FindNormalHeader();
- }
- if(header.empty() && this->SearchFrameworkLast)
- {
+ }
+ if (header.empty() && this->SearchFrameworkLast) {
header = this->FindFrameworkHeader();
- }
+ }
return header;
}
-std::string
-cmFindPathCommand::FindHeaderInFramework(std::string const& file,
- std::string const& dir)
+std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
+ std::string const& dir)
{
- cmStdString fileName = file;
- cmStdString frameWorkName;
- cmStdString::size_type pos = fileName.find("/");
+ std::string fileName = file;
+ std::string frameWorkName;
+ std::string::size_type pos = fileName.find('/');
// if there is a / in the name try to find the header as a framework
// For example bar/foo.h would look for:
// bar.framework/Headers/foo.h
- if(pos != fileName.npos)
- {
+ if (pos != std::string::npos) {
// remove the name from the slash;
- fileName = fileName.substr(pos+1);
+ fileName = fileName.substr(pos + 1);
frameWorkName = file;
frameWorkName =
- frameWorkName.substr(0, frameWorkName.size()-fileName.size()-1);
+ frameWorkName.substr(0, frameWorkName.size() - fileName.size() - 1);
// if the framework has a path in it then just use the filename
- if(frameWorkName.find("/") != frameWorkName.npos)
- {
+ if (frameWorkName.find('/') != std::string::npos) {
fileName = file;
frameWorkName = "";
- }
- if(frameWorkName.size())
- {
+ }
+ if (!frameWorkName.empty()) {
std::string fpath = dir;
fpath += frameWorkName;
fpath += ".framework";
std::string intPath = fpath;
intPath += "/Headers/";
intPath += fileName;
- if(cmSystemTools::FileExists(intPath.c_str()))
- {
- if(this->IncludeFileInPath)
- {
+ if (cmSystemTools::FileExists(intPath.c_str())) {
+ if (this->IncludeFileInPath) {
return intPath;
- }
- return fpath;
}
+ return fpath;
}
}
+ }
// if it is not found yet or not a framework header, then do a glob search
// for all frameworks in the directory: dir/*.framework/Headers/<file>
- cmStdString glob = dir;
+ std::string glob = dir;
glob += "*.framework/Headers/";
glob += file;
cmsys::Glob globIt;
globIt.FindFiles(glob);
std::vector<std::string> files = globIt.GetFiles();
- if(files.size())
- {
- cmStdString fheader = cmSystemTools::CollapseFullPath(files[0].c_str());
- if(this->IncludeFileInPath)
- {
+ if (!files.empty()) {
+ std::string fheader = cmSystemTools::CollapseFullPath(files[0]);
+ if (this->IncludeFileInPath) {
return fheader;
- }
- fheader = cmSystemTools::GetFilenamePath(fheader);
- return fheader;
}
+ fheader.resize(fheader.size() - file.size());
+ return fheader;
+ }
return "";
}
-//----------------------------------------------------------------------------
std::string cmFindPathCommand::FindNormalHeader()
{
std::string tryPath;
- for(std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end() ; ++ni)
- {
- for(std::vector<std::string>::const_iterator
- p = this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p)
- {
+ for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+ ni != this->Names.end(); ++ni) {
+ for (std::vector<std::string>::const_iterator p =
+ this->SearchPaths.begin();
+ p != this->SearchPaths.end(); ++p) {
tryPath = *p;
tryPath += *ni;
- if(cmSystemTools::FileExists(tryPath.c_str()))
- {
- if(this->IncludeFileInPath)
- {
+ if (cmSystemTools::FileExists(tryPath.c_str())) {
+ if (this->IncludeFileInPath) {
return tryPath;
- }
- else
- {
- return *p;
- }
}
+ return *p;
}
}
+ }
return "";
}
-//----------------------------------------------------------------------------
std::string cmFindPathCommand::FindFrameworkHeader()
{
- for(std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end() ; ++ni)
- {
- for(std::vector<std::string>::const_iterator
- p = this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p)
- {
+ for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+ ni != this->Names.end(); ++ni) {
+ for (std::vector<std::string>::const_iterator p =
+ this->SearchPaths.begin();
+ p != this->SearchPaths.end(); ++p) {
std::string fwPath = this->FindHeaderInFramework(*ni, *p);
- if(!fwPath.empty())
- {
+ if (!fwPath.empty()) {
return fwPath;
- }
}
}
+ }
return "";
}