Skip to content

Commit 59f3679

Browse files
committed
Address coderabbit review on cmake
1 parent fa39bd8 commit 59f3679

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

cmake/Toolchains/llvm-clang-15-toolchain.cmake

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Used for CMake toolchain setup. Sets `VAR_NAME` to `BINARY_PATH` after verifying the toolchain
2+
# binary exists. Stops configuration if the required binary is missing.
3+
#
4+
# @param {string} VAR_NAME Variable name to set.
5+
# @param {string} BINARY_PATH Path to the cmake toolchain binary.
6+
function(set_toolchian_binary_var VAR_NAME BINARY_PATH)
7+
if(NOT EXISTS "${BINARY_PATH}")
8+
message(FATAL_ERROR "Required cmake toolchain binary not found: ${BINARY_PATH}")
9+
endif()
10+
set(${VAR_NAME} "${BINARY_PATH}" PARENT_SCOPE)
11+
endfunction()
12+
113
message(STATUS "Setting up LLVM v15 toolchain...")
214

315
execute_process(
@@ -15,7 +27,7 @@ if(NOT 0 EQUAL BREW_RESULT)
1527
)
1628
endif()
1729

18-
set(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang")
19-
set(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++")
20-
set(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar")
21-
set(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib")
30+
set_toolchian_binary_var(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang")
31+
set_toolchian_binary_var(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++")
32+
set_toolchian_binary_var(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar")
33+
set_toolchian_binary_var(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib")

cmake/Toolchains/utils.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function(validate_compiler_versions)
4343
message(
4444
FATAL_ERROR
4545
"${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \
46-
least ${CXX_COMPILER_MIN_VERSION}."
46+
least ${CXX_COMPILER_MIN_VERSION}."
4747
)
4848
endif()
4949
endfunction()

0 commit comments

Comments
 (0)