refactor: Simplify CMake function for detecting host compiler
Simplified the CMake function to improve the process of detecting the host compiler.
This commit is contained in:
parent
46b4c8da44
commit
efe4b14e60
1 changed files with 6 additions and 20 deletions
|
@ -4,29 +4,15 @@ cmake_policy(SET CMP0114 NEW)
|
||||||
find_package(Vulkan COMPONENTS glslc REQUIRED)
|
find_package(Vulkan COMPONENTS glslc REQUIRED)
|
||||||
|
|
||||||
function(detect_host_compiler)
|
function(detect_host_compiler)
|
||||||
find_program(GNU_C_COMPILER gcc NO_CMAKE_FIND_ROOT_PATH)
|
|
||||||
find_program(GNU_CXX_COMPILER g++ NO_CMAKE_FIND_ROOT_PATH)
|
|
||||||
find_program(CLANG_C_COMPILER clang NO_CMAKE_FIND_ROOT_PATH)
|
|
||||||
find_program(CLANG_CXX_COMPILER clang++ NO_CMAKE_FIND_ROOT_PATH)
|
|
||||||
|
|
||||||
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||||
find_program(MSVC_COMPILER cl NO_CMAKE_FIND_ROOT_PATH)
|
find_program(HOST_C_COMPILER NAMES cl gcc clang NO_CMAKE_FIND_ROOT_PATH)
|
||||||
if (MSVC_COMPILER)
|
find_program(HOST_CXX_COMPILER NAMES cl g++ clang++ NO_CMAKE_FIND_ROOT_PATH)
|
||||||
set(HOST_C_COMPILER "${MSVC_COMPILER}" PARENT_SCOPE)
|
|
||||||
set(HOST_CXX_COMPILER "${MSVC_COMPILER}" PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (GNU_C_COMPILER AND GNU_CXX_COMPILER)
|
|
||||||
set(HOST_C_COMPILER "${GNU_C_COMPILER}" PARENT_SCOPE)
|
|
||||||
set(HOST_CXX_COMPILER "${GNU_CXX_COMPILER}" PARENT_SCOPE)
|
|
||||||
elseif (CLANG_C_COMPILER AND CLANG_CXX_COMPILER)
|
|
||||||
set(HOST_C_COMPILER "${CLANG_C_COMPILER}" PARENT_SCOPE)
|
|
||||||
set(HOST_CXX_COMPILER "${CLANG_CXX_COMPILER}" PARENT_SCOPE)
|
|
||||||
else()
|
else()
|
||||||
message(WARNING "No suitable host compiler found")
|
find_program(HOST_C_COMPILER NAMES gcc clang NO_CMAKE_FIND_ROOT_PATH)
|
||||||
|
find_program(HOST_CXX_COMPILER NAMES g++ clang++ NO_CMAKE_FIND_ROOT_PATH)
|
||||||
endif()
|
endif()
|
||||||
|
set(HOST_C_COMPILER "${HOST_C_COMPILER}" PARENT_SCOPE)
|
||||||
|
set(HOST_CXX_COMPILER "${HOST_CXX_COMPILER}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if (Vulkan_FOUND)
|
if (Vulkan_FOUND)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue