Skip to content

Commit efe4b14

Browse files
committed
refactor: Simplify CMake function for detecting host compiler
Simplified the CMake function to improve the process of detecting the host compiler.
1 parent 46b4c8d commit efe4b14

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

ggml/src/ggml-vulkan/CMakeLists.txt

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,15 @@ cmake_policy(SET CMP0114 NEW)
44
find_package(Vulkan COMPONENTS glslc REQUIRED)
55

66
function(detect_host_compiler)
7-
find_program(GNU_C_COMPILER gcc NO_CMAKE_FIND_ROOT_PATH)
8-
find_program(GNU_CXX_COMPILER g++ NO_CMAKE_FIND_ROOT_PATH)
9-
find_program(CLANG_C_COMPILER clang NO_CMAKE_FIND_ROOT_PATH)
10-
find_program(CLANG_CXX_COMPILER clang++ NO_CMAKE_FIND_ROOT_PATH)
11-
127
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
13-
find_program(MSVC_COMPILER cl NO_CMAKE_FIND_ROOT_PATH)
14-
if (MSVC_COMPILER)
15-
set(HOST_C_COMPILER "${MSVC_COMPILER}" PARENT_SCOPE)
16-
set(HOST_CXX_COMPILER "${MSVC_COMPILER}" PARENT_SCOPE)
17-
return()
18-
endif()
19-
endif()
20-
21-
if (GNU_C_COMPILER AND GNU_CXX_COMPILER)
22-
set(HOST_C_COMPILER "${GNU_C_COMPILER}" PARENT_SCOPE)
23-
set(HOST_CXX_COMPILER "${GNU_CXX_COMPILER}" PARENT_SCOPE)
24-
elseif (CLANG_C_COMPILER AND CLANG_CXX_COMPILER)
25-
set(HOST_C_COMPILER "${CLANG_C_COMPILER}" PARENT_SCOPE)
26-
set(HOST_CXX_COMPILER "${CLANG_CXX_COMPILER}" PARENT_SCOPE)
8+
find_program(HOST_C_COMPILER NAMES cl gcc clang NO_CMAKE_FIND_ROOT_PATH)
9+
find_program(HOST_CXX_COMPILER NAMES cl g++ clang++ NO_CMAKE_FIND_ROOT_PATH)
2710
else()
28-
message(WARNING "No suitable host compiler found")
11+
find_program(HOST_C_COMPILER NAMES gcc clang NO_CMAKE_FIND_ROOT_PATH)
12+
find_program(HOST_CXX_COMPILER NAMES g++ clang++ NO_CMAKE_FIND_ROOT_PATH)
2913
endif()
14+
set(HOST_C_COMPILER "${HOST_C_COMPILER}" PARENT_SCOPE)
15+
set(HOST_CXX_COMPILER "${HOST_CXX_COMPILER}" PARENT_SCOPE)
3016
endfunction()
3117

3218
if (Vulkan_FOUND)

0 commit comments

Comments
 (0)