1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmFindPathCommand.cxx,v $
6 Date: $Date: 2002-03-29 19:20:18 $
7 Version: $Revision: 1.16 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmFindPathCommand.h"
18 #include "cmCacheManager.h"
21 bool cmFindPathCommand::InitialPass(std::vector
<std::string
> const& argsIn
)
25 this->SetError("called with incorrect number of arguments");
29 // Now check and see if the value has been stored in the cache
30 // already, if so use that value and don't look for the program
31 std::string helpString
= "What is the path where the file ";
32 helpString
+= argsIn
[1] + " can be found";
33 std::vector
<std::string
> argst
;
34 size_t size
= argsIn
.size();
35 for(unsigned int j
= 0; j
< size
; ++j
)
37 if(argsIn
[j
] != "DOC")
39 argst
.push_back(argsIn
[j
]);
45 helpString
= argsIn
[j
+1];
50 std::vector
<std::string
> args
;
51 cmSystemTools::ExpandListArguments(argst
, args
);
53 const char* cacheValue
54 = m_Makefile
->GetDefinition(args
[0].c_str());
55 if(cacheValue
&& strcmp(cacheValue
, "NOTFOUND"))
61 cmCacheManager::CacheEntry
* e
=
62 cmCacheManager::GetInstance()->GetCacheEntry(args
[0].c_str());
65 helpString
= e
->m_HelpString
;
68 std::vector
<std::string
> path
;
69 // add any user specified paths
70 for (unsigned int j
= 2; j
< args
.size(); j
++)
73 std::string exp
= args
[j
];
74 cmSystemTools::ExpandRegistryValues(exp
);
76 // Glob the entry in case of wildcards.
77 cmSystemTools::GlobDirs(exp
.c_str(), path
);
80 // add the standard path
81 cmSystemTools::GetPath(path
);
83 for(k
=0; k
< path
.size(); k
++)
85 std::string tryPath
= path
[k
];
88 if(cmSystemTools::FileExists(tryPath
.c_str()))
90 path
[k
] = cmSystemTools::CollapseFullPath(path
[k
].c_str());
91 m_Makefile
->AddCacheDefinition(args
[0].c_str(),
94 cmCacheManager::PATH
);
99 m_Makefile
->AddCacheDefinition(args
[0].c_str(),
102 cmCacheManager::PATH
);