Skip to content

Commit 44a6f6a

Browse files
mstorsjotstellar
authored andcommitted
[libcxx] [test] Fix restoring LLVM_DIR and Clang_DIR (llvm#132838)
In 664f345, a fix was introduced, attempting to restore LLVM_DIR and Clang_DIR after doing find_package(Clang). However, 6775285 added a return if the clangTidy target wasn't found. If this is hit, we don't restore LLVM_DIR and Clang_DIR, which causes strange effects if CMake is rerun a second time. Move the code for restoring LLVM_DIR and Clang_DIR to directly after the find_package calls, to make sure they are restored, regardless of the find_package outcome. (cherry picked from commit 51bceb4)
1 parent c1c4d71 commit 44a6f6a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libcxx/test/tools/clang_tidy_checks/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ set(Clang_DIR_SAVE ${Clang_DIR})
88
# versions must match. Otherwise there likely will be ODR-violations. This had
99
# led to crashes and incorrect output of the clang-tidy based checks.
1010
find_package(Clang ${CMAKE_CXX_COMPILER_VERSION})
11+
12+
set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
13+
set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
14+
1115
if(NOT Clang_FOUND)
1216
message(STATUS "Clang-tidy tests are disabled since the "
1317
"Clang development package is unavailable.")
@@ -19,9 +23,6 @@ if(NOT TARGET clangTidy)
1923
return()
2024
endif()
2125

22-
set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
23-
set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
24-
2526
message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
2627

2728
set(CMAKE_CXX_STANDARD 20)

0 commit comments

Comments
 (0)