llvm.org GIT mirror llvm / b56900a
llvm-config: Add support for CMake build trees in which the build mode does not form part of the path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149010 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 7 years ago
1 changed file(s) with 19 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
168168 // and from an installed path. We try and auto-detect which case we are in so
169169 // that we can report the correct information when run from a development
170170 // tree.
171 bool IsInDevelopmentTree, DevelopmentTreeLayoutIsCMakeStyle;
171 bool IsInDevelopmentTree;
172 enum { MakefileStyle, CMakeStyle, CMakeBuildModeStyle } DevelopmentTreeLayout;
172173 llvm::SmallString<256> CurrentPath(GetExecutablePath(argv[0]).str());
173174 std::string CurrentExecPrefix;
174175 std::string ActiveObjRoot;
184185 // symbolic links, but is good enough.
185186 if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE) {
186187 IsInDevelopmentTree = true;
187 DevelopmentTreeLayoutIsCMakeStyle = false;
188 DevelopmentTreeLayout = MakefileStyle;
188189
189190 // If we are in a development tree, then check if we are in a BuildTools
190191 // directory. This indicates we are built for the build triple, but we
194195 } else {
195196 ActiveObjRoot = LLVM_OBJ_ROOT;
196197 }
198 } else if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT)) {
199 IsInDevelopmentTree = true;
200 DevelopmentTreeLayout = CMakeStyle;
201 ActiveObjRoot = LLVM_OBJ_ROOT;
197202 } else if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/bin") {
198203 IsInDevelopmentTree = true;
199 DevelopmentTreeLayoutIsCMakeStyle = true;
204 DevelopmentTreeLayout = CMakeBuildModeStyle;
200205 ActiveObjRoot = LLVM_OBJ_ROOT;
201206 } else {
202207 IsInDevelopmentTree = false;
212217
213218 // CMake organizes the products differently than a normal prefix style
214219 // layout.
215 if (DevelopmentTreeLayoutIsCMakeStyle) {
220 switch (DevelopmentTreeLayout) {
221 case MakefileStyle:
222 ActiveBinDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/bin";
223 ActiveLibDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/lib";
224 break;
225 case CMakeStyle:
226 ActiveBinDir = ActiveObjRoot + "/bin";
227 ActiveLibDir = ActiveObjRoot + "/lib";
228 break;
229 case CMakeBuildModeStyle:
216230 ActiveBinDir = ActiveObjRoot + "/bin/" + LLVM_BUILDMODE;
217231 ActiveLibDir = ActiveObjRoot + "/lib/" + LLVM_BUILDMODE;
218 } else {
219 ActiveBinDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/bin";
220 ActiveLibDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/lib";
232 break;
221233 }
222234
223235 // We need to include files from both the source and object trees.