Skip to content

Commit 4b83740

Browse files
authored
Use find_program to locate llvm-config (#218)
Use `find_program` to locate the llvm-config binary. cmake will raise an error if the binary is not located.
1 parent fc38576 commit 4b83740

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

cmake/apple-clang.cmake

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ set (CXX_FLAGS
2020

2121
option(DETECT_TARGET_TRIPLE "Automatically detect the target triple for clang" ON)
2222
if (DETECT_TARGET_TRIPLE)
23-
execute_process (
24-
COMMAND bash -c "llvm-config --host-target | tr -d '\n'"
25-
OUTPUT_VARIABLE LLVM_TARGET_TRIPLE
26-
)
27-
list(APPEND CXX_FLAGS "-target ${LLVM_TARGET_TRIPLE}")
23+
find_program(LLVM_CONFIG_BIN llvm-config)
24+
if (NOT LLVM_CONFIG_BIN)
25+
message(FATAL_ERROR "llvm-config not found!")
26+
endif()
27+
message(STATUS "Using llvm-config: " ${LLVM_CONFIG_BIN})
28+
29+
execute_process (
30+
COMMAND bash -c "${LLVM_CONFIG_BIN} --host-target | tr -d '\n'"
31+
OUTPUT_VARIABLE LLVM_TARGET_TRIPLE
32+
)
33+
list(APPEND CXX_FLAGS "-target ${LLVM_TARGET_TRIPLE}")
2834
endif()
2935

3036
list (JOIN CXX_FLAGS " " CXX_FLAGS_STR)

0 commit comments

Comments
 (0)