Skip to content

Commit 3206c26

Browse files
committed
cmake: require libc++ and clang headers when building with tests or install
libc++ and clang header includes are required when running tests, or when installing mrdocs. Make the CMakeLists.txt enforce that requirement. Otherwise, the tests fail in non-obvious ways.
1 parent 3fd05bb commit 3206c26

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,23 @@ endif()
8989
find_package(LLVM REQUIRED CONFIG)
9090
find_package(Clang REQUIRED CONFIG)
9191

92-
if (LLVM_ROOT)
93-
set(LIBCXX_DIR "${LLVM_ROOT}/include/c++/v1/")
92+
if (MRDOCS_TEST OR MRDOCS_INSTALL)
93+
set(LIBCXX_DIR "${LLVM_INCLUDE_DIR}/c++/v1/" CACHE PATH
94+
"Path to libc++ include directory")
9495
message(STATUS "LIBCXX_DIR: ${LIBCXX_DIR}")
9596
if (NOT EXISTS "${LIBCXX_DIR}")
9697
message(FATAL_ERROR
9798
"LIBCXX_DIR (${LIBCXX_DIR}) does not exist.\n"
98-
"LLVM_ROOT is set, but LIBCXX_DIR (/include/c++/v1) does not exist.\n")
99+
"Please provide a LLVM with libc++ enabled\n")
99100
endif()
100-
set(STDLIB_INCLUDE_DIR "${LLVM_ROOT}/lib/clang/${Clang_VERSION_MAJOR}/include/")
101+
102+
set(STDLIB_INCLUDE_DIR "${LLVM_BINARY_DIR}/lib/clang/${Clang_VERSION_MAJOR}/include/"
103+
CACHE PATH "Path to the clang headers include directory")
101104
message(STATUS "STDLIB_INCLUDE_DIR: ${STDLIB_INCLUDE_DIR}")
102105
if (NOT EXISTS "${STDLIB_INCLUDE_DIR}")
103106
message(FATAL_ERROR
104107
"STDLIB_INCLUDE_DIR (${STDLIB_INCLUDE_DIR}) does not exist.\n"
105-
"LLVM_ROOT is set, but STDLIB_INCLUDE_DIR (/lib/clang/${Clang_VERSION_MAJOR}/include) does not exist.\n")
108+
"Missing clang headers\n")
106109
endif()
107110
endif()
108111

0 commit comments

Comments
 (0)