MCPcopy Create free account
hub / github.com/Kitware/CMake / FindInstallSource

Function FindInstallSource

Source/cmInstallFilesCommand.cxx:137–160  ·  view source on GitHub ↗

* Find a file in the build or source tree for installation given a * relative path from the CMakeLists.txt file. This will favor files * present in the build tree. If a full path is given, it is just * returned. */

Source from the content-addressed store, hash-verified

135 * returned.
136 */
137static std::string FindInstallSource(cmMakefile& makefile, char const* name)
138{
139 if (cmSystemTools::FileIsFullPath(name) ||
140 cmGeneratorExpression::Find(name) == 0) {
141 // This is a full path.
142 return name;
143 }
144
145 // This is a relative path.
146 std::string tb = cmStrCat(makefile.GetCurrentBinaryDirectory(), '/', name);
147 std::string ts = cmStrCat(makefile.GetCurrentSourceDirectory(), '/', name);
148
149 if (cmSystemTools::FileExists(tb)) {
150 // The file exists in the binary tree. Use it.
151 return tb;
152 }
153 if (cmSystemTools::FileExists(ts)) {
154 // The file exists in the source tree. Use it.
155 return ts;
156 }
157 // The file doesn't exist. Assume it will be present in the
158 // binary tree when the install occurs.
159 return tb;
160}

Callers 2

cmInstallFilesCommandFunction · 0.70
FinalActionFunction · 0.70

Calls 2

cmStrCatFunction · 0.70
FileExistsFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…