mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 04:48:27 +00:00
Help the Skia build to find clang
..even if cmake sets CC/CXX to GCC.
This commit is contained in:
parent
779e216b2a
commit
8b478431a7
1 changed files with 50 additions and 32 deletions
|
|
@ -204,39 +204,57 @@ else(SLINT_STYLE)
|
|||
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE_DEFAULT})
|
||||
endif(SLINT_STYLE)
|
||||
|
||||
# The Skia cross-build requires a host C compiler (due to some build dependencies of rust-skia),
|
||||
# so cc.rs will first look for CC_<triplet> and then HOST_CC.
|
||||
# When cross-compiling, CMake doesn't really know what the host compiler is. Corrosion will set
|
||||
# HOST_CC to $CC, which is a good bet. Unfortunately in Yocto environments, CC will be set to
|
||||
# the cross-compiler. The same applies to CFLAGS, which may contain target specific options.
|
||||
# So the hack to solve this is two-fold:
|
||||
# * We look for clang or gcc in PATH - unprefixed those are usually host compilers.
|
||||
# * Through corrosion we know the correct host value of CC_<triplet>.
|
||||
# Finally, we set CC_<host triplet> to clang or gcc and empty CFLAGS_<host triplet>
|
||||
if((SLINT_FEATURE_RENDERER_SKIA OR SLINT_FEATURE_RENDERER_SKIA_OPENGL OR SLINT_FEATURE_RENDERER_SKIA_VULKAN) AND CMAKE_CROSSCOMPILING AND Rust_CARGO_HOST_TARGET)
|
||||
find_program(CLANG clang)
|
||||
if(CLANG)
|
||||
set(host_cc "${CLANG}")
|
||||
else()
|
||||
find_program(GCC gcc)
|
||||
if (GCC)
|
||||
set(host_cc "${GCC}")
|
||||
endif()
|
||||
if(SLINT_FEATURE_RENDERER_SKIA OR SLINT_FEATURE_RENDERER_SKIA_OPENGL OR SLINT_FEATURE_RENDERER_SKIA_VULKAN)
|
||||
find_program(CLANGCC clang)
|
||||
find_program(CLANGCXX clang++)
|
||||
if(CLANGCC AND CLANGCXX)
|
||||
set_property(
|
||||
TARGET slint-cpp
|
||||
APPEND
|
||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||
CLANGCC=${CLANGCC}
|
||||
)
|
||||
set_property(
|
||||
TARGET slint-cpp
|
||||
APPEND
|
||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||
CLANGCXX=${CLANGCXX}
|
||||
)
|
||||
endif()
|
||||
if(host_cc)
|
||||
string(REPLACE "-" "_" cargo_host_target_underscore "${Rust_CARGO_HOST_TARGET}")
|
||||
set_property(
|
||||
TARGET slint-cpp
|
||||
APPEND
|
||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||
CC_${cargo_host_target_underscore}=${host_cc}
|
||||
)
|
||||
set_property(
|
||||
TARGET slint-cpp
|
||||
APPEND
|
||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||
CFLAGS_${cargo_host_target_underscore}=
|
||||
)
|
||||
|
||||
# The Skia cross-build requires a host C compiler (due to some build dependencies of rust-skia),
|
||||
# so cc.rs will first look for CC_<triplet> and then HOST_CC.
|
||||
# When cross-compiling, CMake doesn't really know what the host compiler is. Corrosion will set
|
||||
# HOST_CC to $CC, which is a good bet. Unfortunately in Yocto environments, CC will be set to
|
||||
# the cross-compiler. The same applies to CFLAGS, which may contain target specific options.
|
||||
# So the hack to solve this is two-fold:
|
||||
# * We look for clang or gcc in PATH - unprefixed those are usually host compilers.
|
||||
# * Through corrosion we know the correct host value of CC_<triplet>.
|
||||
# Finally, we set CC_<host triplet> to clang or gcc and empty CFLAGS_<host triplet>
|
||||
if(CMAKE_CROSSCOMPILING AND Rust_CARGO_HOST_TARGET)
|
||||
if(CLANGCC)
|
||||
set(host_cc "${CLANGCC}")
|
||||
else()
|
||||
find_program(GCC gcc)
|
||||
if (GCC)
|
||||
set(host_cc "${GCC}")
|
||||
endif()
|
||||
endif()
|
||||
if(host_cc)
|
||||
string(REPLACE "-" "_" cargo_host_target_underscore "${Rust_CARGO_HOST_TARGET}")
|
||||
set_property(
|
||||
TARGET slint-cpp
|
||||
APPEND
|
||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||
CC_${cargo_host_target_underscore}=${host_cc}
|
||||
)
|
||||
set_property(
|
||||
TARGET slint-cpp
|
||||
APPEND
|
||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||
CFLAGS_${cargo_host_target_underscore}=
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue