This fixes a bug where tests would be disabled when LLVM_EXTERNAL_LIT
was set if lit couldn't be found in any of the standard search paths.
Details
- Reviewers
mgorny phosek Ericson2314 kwk
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/CMakeLists.txt | ||
---|---|---|
97 | I don't think you need to do this if you rename the var, find_program() doesn't seem to do any searching when the var is already set. I've tested with a dummy CMakeLists: set(FOO /bin/true) find_program(FOO NAMES foo) message(FATAL_ERROR ${FOO}) gives /bin/true for me. |
As much as I would like this to be fixed. I vote against this patch because in lld/CMakeLists.txt there's an almost (if not entirely) identical piece of code that screams to be outsourced into a /cmake/Modules/FindLit.cmake (to be created). I'll have a look at this and see if I can come up with a patch for this. Afterall /cmake is the central place to distribute shared CMake code between subprojects, right @phosek (didn't you create /cmake in the first place)?
Alternatively, we can copy the code from lld/CMakeLists.txt and outsource it afterwards so that the shared code becomes more obvious.
If there're any objections regarding outsourcing to FindLit.cmake, then I would only ask to copy the code from lld/CMakeLists.txt. There the find_program part sits below the if block.
clang/CMakeLists.txt | ||
---|---|---|
97 |
This might be true but it is counter intuitive to assume that find_program does nothing. So for readability I'd keep the if (NOT LLVM_EXTERNAL_LIT). I know it is not needed but with the if it won't look like find_program(LLVM_EXTERNAL_LIT is the only/central place to set the variable LLVM_EXTERNAL_LIT. With the guard around it, it becomes more obvious that this is more of a fallback. |
My eventual goal is to move this out into a separate CMake file, but I was hoping to simplify the code first before doing this.
clang/CMakeLists.txt | ||
---|---|---|
97 | @mgorny The documentation confirms this too: "Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again." |
I don't think you need to do this if you rename the var, find_program() doesn't seem to do any searching when the var is already set.
I've tested with a dummy CMakeLists:
gives /bin/true for me.