cmake: add flags to only build the compiler

... and to use an external compiler

For example, this is how one only build the compiler:

```
cmake .. -DSLINT_BUILD_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX=/tmp/slint_compiler
make install
```

And this only build the runtime
```
cmake .. -DSLINT_FEATURE_COMPILER=OFF -DCMAKE_INSTALL_PREFIX=/tmp/install_runtime
make install
```

And then this can be used in a project like so:
```
cmake .. -DCMAKE_PREFIX_PATH=/tmp/install_runtime/ -DSLINT_COMPILER=/tmp/install_compiler/bin/slint-compiler
```
This commit is contained in:
Olivier Goffart 2023-09-15 14:42:52 +02:00 committed by GitHub
parent d299f0bf3e
commit 14f7fe4ba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 265 additions and 243 deletions

View file

@ -20,63 +20,13 @@ find_package(Rust 1.70 REQUIRED MODULE)
option(BUILD_SHARED_LIBS "Build Slint as shared library" ON)
option(SLINT_FEATURE_COMPILER "Enable support for compiling .slint files to C++ ahead of time" ON)
add_feature_info(SLINT_FEATURE_COMPILER SLINT_FEATURE_COMPILER "Enable support for compiling .slint files to C++ ahead of time")
option(SLINT_BUILD_RUNTIME "Actually build the Slint runtime libraries (Disable that to only build the compiler)" ON)
add_feature_info(SLINT_BUILD_RUNTIME SLINT_BUILD_RUNTIME "Actually build the Slint runtime libraries (Disable that to only build the compiler)")
if(SLINT_FEATURE_COMPILER)
set(slint_compiler_crate "slint-compiler")
endif()
if(BUILD_SHARED_LIBS)
set(rustc_lib_type "cdylib")
set(slint_cpp_impl "slint-cpp-shared")
set(cmake_lib_type "SHARED")
else()
set(rustc_lib_type "staticlib")
set(slint_cpp_impl "slint-cpp-static")
set(cmake_lib_type "STATIC")
endif()
corrosion_import_crate(MANIFEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../Cargo.toml"
CRATES slint-cpp ${slint_compiler_crate} CRATE_TYPES bin ${rustc_lib_type})
set(SLINT_COMPILER "" CACHE STRING "Path to the slint-compiler executable. When unset, it the compiler will be build as part of the build process")
set(SLINT_LIBRARY_CARGO_FLAGS "" CACHE STRING
"Flags to pass to cargo when building the Slint runtime library")
if(SLINT_LIBRARY_CARGO_FLAGS)
corrosion_set_cargo_flags(slint-cpp ${SLINT_LIBRARY_CARGO_FLAGS})
endif()
# When doing "make install" package builds, set install_name to rpath, so that the installed
# binaries don't have a load-command pointing back to their build directory.
# Don't do this when Slint is used via FetchContent. While we could set CMAKE_BUILD_RPATH to
# include the binary dir and thus our examples would have the correct rpath set, binaries
# outside (i.e. applications using Slint via FetchContent) would not and the BUILD_RPATH
# target property doesn't propagate :(
if (APPLE AND SLINT_IS_TOPLEVEL_BUILD AND BUILD_SHARED_LIBS)
# corrosion could provide the Cargo.toml package version as a CMake target property.
corrosion_add_target_local_rustflags(slint-cpp -Clink-arg=-Wl,-install_name,@rpath/libslint_cpp.dylib,-current_version,${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR},-compatibility_version,${PROJECT_VERSION_MAJOR}.0)
# Set this one to false again explicitely because Corrosion will starting setting this property to true by default.
set_target_properties(slint-cpp-shared PROPERTIES IMPORTED_NO_SONAME 0)
set_target_properties(slint-cpp-shared PROPERTIES IMPORTED_SONAME libslint_cpp.dylib)
endif()
set_property(
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
"SLINT_GENERATED_INCLUDE_DIR=${CMAKE_CURRENT_BINARY_DIR}/generated_include/"
)
if(SLINT_FEATURE_COMPILER)
corrosion_set_hostbuild(slint-compiler)
endif()
add_library(Slint INTERFACE)
add_library(Slint::Slint ALIAS Slint)
target_link_libraries(Slint INTERFACE slint-cpp)
target_compile_features(Slint INTERFACE cxx_std_20)
if (MSVC)
target_compile_options(Slint INTERFACE /bigobj)
endif()
function(define_cargo_feature cargo-feature description default)
# turn foo-bar into SLINT_FEATURE_FOO_BAR
@ -148,256 +98,319 @@ define_cargo_dependent_feature(backend-linuxkms "Enable support for the backend
define_cargo_dependent_feature(gettext "Enable support of translations using gettext" OFF "NOT SLINT_FEATURE_FREESTANDING")
define_cargo_dependent_feature(accessibility "Enable integration with operating system provided accessibility APIs" ON "NOT SLINT_FEATURE_FREESTANDING")
if (SLINT_FEATURE_FREESTANDING)
if (ESP_PLATFORM)
list(APPEND features "esp-backtrace/${IDF_TARGET}")
if (SLINT_BUILD_RUNTIME)
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
set(slint_compiler_crate "slint-compiler")
endif()
else (SLINT_FEATURE_FREESTANDING)
list(APPEND features std)
if(BUILD_SHARED_LIBS)
set(rustc_lib_type "cdylib")
set(slint_cpp_impl "slint-cpp-shared")
set(cmake_lib_type "SHARED")
else()
set(rustc_lib_type "staticlib")
set(slint_cpp_impl "slint-cpp-static")
set(cmake_lib_type "STATIC")
endif()
corrosion_import_crate(MANIFEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../Cargo.toml"
CRATES slint-cpp ${slint_compiler_crate} CRATE_TYPES bin ${rustc_lib_type})
elseif(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
corrosion_import_crate(MANIFEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../Cargo.toml"
CRATES slint-compiler CRATE_TYPES bin)
endif()
set_property(
TARGET slint-cpp
PROPERTY CORROSION_FEATURES
${features}
)
set_property(
TARGET slint-cpp
PROPERTY CORROSION_NO_DEFAULT_FEATURES
ON
)
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
corrosion_set_hostbuild(slint-compiler)
endif()
if(SLINT_FEATURE_BACKEND_QT)
# For the CMake build don't rely on qmake being in PATH but use CMake to locate Qt. This
# means usually CMAKE_PREFIX_PATH is set.
find_package(Qt6 6.2 QUIET COMPONENTS Core Widgets)
if (SLINT_BUILD_RUNTIME)
if(NOT TARGET Qt::qmake)
find_package(Qt5 5.15 QUIET COMPONENTS Core Widgets)
# When doing "make install" package builds, set install_name to rpath, so that the installed
# binaries don't have a load-command pointing back to their build directory.
# Don't do this when Slint is used via FetchContent. While we could set CMAKE_BUILD_RPATH to
# include the binary dir and thus our examples would have the correct rpath set, binaries
# outside (i.e. applications using Slint via FetchContent) would not and the BUILD_RPATH
# target property doesn't propagate :(
if (APPLE AND SLINT_IS_TOPLEVEL_BUILD AND BUILD_SHARED_LIBS)
# corrosion could provide the Cargo.toml package version as a CMake target property.
corrosion_add_target_local_rustflags(slint-cpp -Clink-arg=-Wl,-install_name,@rpath/libslint_cpp.dylib,-current_version,${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR},-compatibility_version,${PROJECT_VERSION_MAJOR}.0)
# Set this one to false again explicitely because Corrosion will starting setting this property to true by default.
set_target_properties(slint-cpp-shared PROPERTIES IMPORTED_NO_SONAME 0)
set_target_properties(slint-cpp-shared PROPERTIES IMPORTED_SONAME libslint_cpp.dylib)
endif()
endif(SLINT_FEATURE_BACKEND_QT)
if(TARGET Qt::qmake)
add_library(Slint INTERFACE)
add_library(Slint::Slint ALIAS Slint)
target_link_libraries(Slint INTERFACE slint-cpp)
target_compile_features(Slint INTERFACE cxx_std_20)
if (MSVC)
target_compile_options(Slint INTERFACE /bigobj)
endif()
if (SLINT_FEATURE_FREESTANDING)
if (ESP_PLATFORM)
list(APPEND features "esp-backtrace/${IDF_TARGET}")
endif()
else (SLINT_FEATURE_FREESTANDING)
list(APPEND features std)
endif()
set_property(
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
QMAKE=$<TARGET_PROPERTY:Qt::qmake,LOCATION>
"SLINT_GENERATED_INCLUDE_DIR=${CMAKE_CURRENT_BINARY_DIR}/generated_include/"
)
set(SLINT_STYLE_DEFAULT "native")
else()
set_property(
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
SLINT_NO_QT=1
PROPERTY CORROSION_FEATURES
${features}
)
set_property(
TARGET slint-cpp
PROPERTY CORROSION_NO_DEFAULT_FEATURES
ON
)
set(SLINT_STYLE_DEFAULT "fluent")
endif()
set(SLINT_STYLE "" CACHE STRING "The Slint Widget Style")
if(SLINT_LIBRARY_CARGO_FLAGS)
corrosion_set_cargo_flags(slint-cpp ${SLINT_LIBRARY_CARGO_FLAGS})
endif()
if(SLINT_STYLE)
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE})
else(SLINT_STYLE)
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE_DEFAULT})
endif(SLINT_STYLE)
if(SLINT_FEATURE_BACKEND_QT)
# For the CMake build don't rely on qmake being in PATH but use CMake to locate Qt. This
# means usually CMAKE_PREFIX_PATH is set.
find_package(Qt6 6.2 QUIET COMPONENTS Core Widgets)
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)
if(NOT TARGET Qt::qmake)
find_package(Qt5 5.15 QUIET COMPONENTS Core Widgets)
endif()
endif(SLINT_FEATURE_BACKEND_QT)
if(TARGET Qt::qmake)
set_property(
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
CLANGCC=${CLANGCC}
QMAKE=$<TARGET_PROPERTY:Qt::qmake,LOCATION>
)
set(SLINT_STYLE_DEFAULT "native")
else()
set_property(
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
CLANGCXX=${CLANGCXX}
)
SLINT_NO_QT=1
)
set(SLINT_STYLE_DEFAULT "fluent")
endif()
# 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}")
set(SLINT_STYLE "" CACHE STRING "The Slint Widget Style")
if(SLINT_STYLE)
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE})
else(SLINT_STYLE)
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE_DEFAULT})
endif(SLINT_STYLE)
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()
# 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()
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()
file(GLOB api_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB api_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
foreach(header IN LISTS api_headers)
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER include/${header})
endforeach()
foreach(header IN LISTS api_headers)
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER include/${header})
endforeach()
set(generated_headers
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_enums_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_enums.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_builtin_structs_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_builtin_structs.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_string_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_brush_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_sharedvector_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_properties_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_image_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_color_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_pathdata_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_qt_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_platform_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_generated_public.h
)
if(SLINT_FEATURE_INTERPRETER)
list(APPEND generated_headers
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_generated_public.h
set(generated_headers
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_enums_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_enums.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_builtin_structs_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_builtin_structs.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_string_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_brush_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_sharedvector_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_properties_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_image_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_color_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_pathdata_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_qt_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_platform_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_generated_public.h
)
endif()
if(SLINT_FEATURE_INTERPRETER)
list(APPEND generated_headers
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_generated_public.h
)
endif()
foreach(header IN LISTS generated_headers)
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER ${header})
endforeach()
foreach(header IN LISTS generated_headers)
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER ${header})
endforeach()
target_include_directories(Slint INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/slint>
)
target_include_directories(Slint INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/slint>
)
if(SLINT_FEATURE_COMPILER)
add_executable(Slint::slint-compiler ALIAS slint-compiler)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake)
endif()
export(TARGETS Slint slint-cpp
NAMESPACE Slint:: FILE "${CMAKE_BINARY_DIR}/lib/cmake/Slint/SlintTargets.cmake")
install(EXPORT SlintTargets NAMESPACE Slint:: DESTINATION lib/cmake/Slint)
install(TARGETS Slint slint-cpp
EXPORT SlintTargets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/slint)
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
add_executable(Slint::slint-compiler ALIAS slint-compiler)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake)
endif()
export(TARGETS Slint slint-cpp
NAMESPACE Slint:: FILE "${CMAKE_BINARY_DIR}/lib/cmake/Slint/SlintTargets.cmake")
install(EXPORT SlintTargets NAMESPACE Slint:: DESTINATION lib/cmake/Slint)
install(TARGETS Slint slint-cpp
EXPORT SlintTargets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/slint)
install(FILES $<TARGET_FILE:${slint_cpp_impl}> TYPE LIB)
if(WIN32)
install(FILES $<TARGET_LINKER_FILE:${slint_cpp_impl}> TYPE LIB)
endif()
endif(SLINT_BUILD_RUNTIME)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
install(FILES $<TARGET_FILE:${slint_cpp_impl}> TYPE LIB)
if(WIN32)
install(FILES $<TARGET_LINKER_FILE:${slint_cpp_impl}> TYPE LIB)
endif()
if(SLINT_FEATURE_COMPILER)
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
install(PROGRAMS $<TARGET_FILE:slint-compiler> TYPE BIN)
endif()
# Corrosion sets the `IMPORTED` locations late to allow us to set OUTPUT_DIRECTORY
# target properties. This function must be deferred until after Corrosion set the
# locations. Since we are writing to a config file Generator expressions are not
# an option.
function(_slint_write_configure_file)
foreach(prop
IMPORTED_LOCATION IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_RELEASE
IMPORTED_LOCATION_RELWITHDEBINFO IMPORTED_LOCATION_MINSIZEREL
IMPORTED_IMPLIB IMPORTED_IMPLIB_DEBUG IMPORTED_IMPLIB_RELEASE
IMPORTED_IMPLIB_RELWITHDEBINFO IMPORTED_IMPLIB_MINSIZEREL)
get_target_property(value ${slint_cpp_impl} ${prop})
if(SLINT_BUILD_RUNTIME)
if(value)
get_filename_component(value ${value} NAME)
list(APPEND SLINT_LIB_PROPERTIES ${prop} "\${_IMPORT_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${value}")
endif()
endforeach()
# Corrosion sets the `IMPORTED` locations late to allow us to set OUTPUT_DIRECTORY
# target properties. This function must be deferred until after Corrosion set the
# locations. Since we are writing to a config file Generator expressions are not
# an option.
function(_slint_write_configure_file)
foreach(prop
IMPORTED_LOCATION IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_RELEASE
IMPORTED_LOCATION_RELWITHDEBINFO IMPORTED_LOCATION_MINSIZEREL
IMPORTED_IMPLIB IMPORTED_IMPLIB_DEBUG IMPORTED_IMPLIB_RELEASE
IMPORTED_IMPLIB_RELWITHDEBINFO IMPORTED_IMPLIB_MINSIZEREL)
get_target_property(value ${slint_cpp_impl} ${prop})
get_property(_SLINT_STYLE GLOBAL PROPERTY SLINT_STYLE)
configure_package_config_file("cmake/SlintConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake" INSTALL_DESTINATION lib/cmake/Slint)
endfunction()
if(value)
get_filename_component(value ${value} NAME)
list(APPEND SLINT_LIB_PROPERTIES ${prop} "\${_IMPORT_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${value}")
endif()
endforeach()
cmake_language(DEFER CALL _slint_write_configure_file)
get_property(_SLINT_STYLE GLOBAL PROPERTY SLINT_STYLE)
configure_package_config_file("cmake/SlintConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake" INSTALL_DESTINATION lib/cmake/Slint)
endfunction()
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake
VERSION 1.3.0
COMPATIBILITY SameMinorVersion
)
cmake_language(DEFER CALL _slint_write_configure_file)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake"
DESTINATION lib/cmake/Slint
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake
VERSION 1.3.0
COMPATIBILITY SameMinorVersion
)
if(SLINT_FEATURE_COMPILER)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake"
DESTINATION lib/cmake/Slint
)
endif()
option(SLINT_PACKAGE_BUNDLE_QT "Internal setting to install Qt binary in the packages" OFF)
option(SLINT_PACKAGE_BUNDLE_QT "Internal setting to install Qt binary in the packages" OFF)
if(SLINT_PACKAGE_BUNDLE_QT)
if(WIN32)
find_package(Qt6 6.0 COMPONENTS Core Gui Widgets Svg)
install(
FILES
$<TARGET_FILE:Qt6::Core>
$<TARGET_FILE:Qt6::Gui>
$<TARGET_FILE:Qt6::Widgets>
$<TARGET_FILE:Qt6::Svg>
TYPE LIB)
if(SLINT_PACKAGE_BUNDLE_QT)
if(WIN32)
find_package(Qt6 6.0 COMPONENTS Core Gui Widgets Svg)
install(
FILES
$<TARGET_FILE:Qt6::Core>
$<TARGET_FILE:Qt6::Gui>
$<TARGET_FILE:Qt6::Widgets>
$<TARGET_FILE:Qt6::Svg>
TYPE LIB)
install(
FILES ${Qt6_DIR}/../../../plugins/platforms/qwindows.dll
DESTINATION plugins/platforms)
install(
FILES ${Qt6_DIR}/../../../plugins/styles/qwindowsvistastyle.dll
DESTINATION plugins/styles)
install(
FILES ${Qt6_DIR}/../../../plugins/imageformats/qsvg.dll
DESTINATION plugins/imageformats)
install(
FILES ${Qt6_DIR}/../../../plugins/platforms/qwindows.dll
DESTINATION plugins/platforms)
install(
FILES ${Qt6_DIR}/../../../plugins/styles/qwindowsvistastyle.dll
DESTINATION plugins/styles)
install(
FILES ${Qt6_DIR}/../../../plugins/imageformats/qsvg.dll
DESTINATION plugins/imageformats)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../licenses/ DESTINATION LICENSES)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../licenses/ DESTINATION LICENSES)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} TYPE LIB)
endif()
endif(SLINT_PACKAGE_BUNDLE_QT)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} TYPE LIB)
endif()
endif(SLINT_PACKAGE_BUNDLE_QT)
endif(SLINT_BUILD_RUNTIME)
set(CPACK_PACKAGE_NAME "Slint-cpp")
set(CPACK_PACKAGE_VENDOR "Slint")

View file

@ -14,7 +14,13 @@ endif()
add_library(@slint_cpp_impl@ @cmake_lib_type@ IMPORTED)
set_target_properties(@slint_cpp_impl@ PROPERTIES @SLINT_LIB_PROPERTIES@)
if (@SLINT_FEATURE_COMPILER@)
set(SLINT_COMPILER @SLINT_COMPILER@ CACHE STRING "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)
set_target_properties(Slint::slint-compiler PROPERTIES IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_BINDIR@/slint-compiler${CMAKE_EXECUTABLE_SUFFIX}")
include("${CMAKE_CURRENT_LIST_DIR}/SlintMacro.cmake")

View file

@ -45,7 +45,9 @@ if(NOT SLINT_FEATURE_FREESTANDING)
endif()
slint_test(models)
add_subdirectory(multiple-includes)
if(SLINT_FEATURE_COMPILER OR SLINT_COMPILER)
add_subdirectory(multiple-includes)
endif()
slint_test(platform_eventloop)
target_link_libraries(test_platform_eventloop PRIVATE Threads::Threads)