slint/api/cpp/cmake/SlintConfig.cmake.in
Simon Hausmann 13975d9def Fix locating the slint-compiler.exe on cmake cross-compiled packages
When cross-compiling CMAKE_EXECUTABLE_SUFFIX may not be set to .exe even
though the host is Windows, because this variable always refers to the
target. This is a missing feature in cmake, so work around it for now.
See also https://gitlab.kitware.com/cmake/cmake/-/issues/17553 I made a
similar workaround in Corrosion long time ago with commit
b8a6b26a0f2d526e0492df9fd88c0495b0b8a64f

The target prop line is duplicated in favor of introducing a variable,
that would otherwise be at risk of being visible in the user scope.
2024-08-23 18:10:11 +02:00

38 lines
1.7 KiB
CMake

# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
@PACKAGE_INIT@
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
add_library(@slint_cpp_impl@ @cmake_lib_type@ IMPORTED)
set_target_properties(@slint_cpp_impl@ PROPERTIES @SLINT_LIB_PROPERTIES@)
set(SLINT_COMPILER @SLINT_COMPILER@ CACHE FILEPATH "Path to the slint-compiler executable")
if (SLINT_COMPILER)
set(SLINT_STYLE @_SLINT_STYLE@ CACHE STRING "The Slint widget style")
add_executable(Slint::slint-compiler IMPORTED GLOBAL)
set_target_properties(Slint::slint-compiler PROPERTIES IMPORTED_LOCATION ${SLINT_COMPILER})
include("${CMAKE_CURRENT_LIST_DIR}/SlintMacro.cmake")
elseif (@SLINT_FEATURE_COMPILER@)
add_executable(Slint::slint-compiler IMPORTED GLOBAL)
if(CMAKE_HOST_WIN32)
set_target_properties(Slint::slint-compiler PROPERTIES IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_BINDIR@/slint-compiler.exe")
else()
set_target_properties(Slint::slint-compiler PROPERTIES IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_BINDIR@/slint-compiler")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/SlintMacro.cmake")
endif()
set(_IMPORT_PREFIX)
include("${CMAKE_CURRENT_LIST_DIR}/SlintTargets.cmake")
set(SLINT_STYLE @_SLINT_STYLE@ CACHE STRING "The Slint widget style")
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE})