mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 21:03:00 +00:00
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:
parent
d299f0bf3e
commit
14f7fe4ba2
5 changed files with 265 additions and 243 deletions
|
|
@ -23,6 +23,7 @@ All notable changes to this project are documented in this file.
|
||||||
### C++
|
### C++
|
||||||
|
|
||||||
- Removed the need for C++ exceptions in generated code.
|
- Removed the need for C++ exceptions in generated code.
|
||||||
|
- Added ability to only build the Slint compiler or use an external compiler.
|
||||||
|
|
||||||
### LSP
|
### LSP
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ add_feature_info(SLINT_BUILD_EXAMPLES SLINT_BUILD_EXAMPLES "configure whether to
|
||||||
if(SLINT_BUILD_EXAMPLES)
|
if(SLINT_BUILD_EXAMPLES)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
if(SLINT_BUILD_TESTING)
|
if(SLINT_BUILD_TESTING AND (SLINT_FEATURE_COMPILER OR SLINT_COMPILER))
|
||||||
add_subdirectory(docs/tutorial/cpp/src/)
|
add_subdirectory(docs/tutorial/cpp/src/)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,63 +20,13 @@ find_package(Rust 1.70 REQUIRED MODULE)
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build Slint as shared library" ON)
|
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)
|
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 "" CACHE STRING "Path to the slint-compiler executable. When unset, it the compiler will be build as part of the build process")
|
||||||
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_LIBRARY_CARGO_FLAGS "" CACHE STRING
|
set(SLINT_LIBRARY_CARGO_FLAGS "" CACHE STRING
|
||||||
"Flags to pass to cargo when building the Slint runtime library")
|
"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)
|
function(define_cargo_feature cargo-feature description default)
|
||||||
# turn foo-bar into SLINT_FEATURE_FOO_BAR
|
# 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(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")
|
define_cargo_dependent_feature(accessibility "Enable integration with operating system provided accessibility APIs" ON "NOT SLINT_FEATURE_FREESTANDING")
|
||||||
|
|
||||||
if (SLINT_FEATURE_FREESTANDING)
|
if (SLINT_BUILD_RUNTIME)
|
||||||
|
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
|
||||||
if (ESP_PLATFORM)
|
set(slint_compiler_crate "slint-compiler")
|
||||||
list(APPEND features "esp-backtrace/${IDF_TARGET}")
|
|
||||||
endif()
|
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()
|
endif()
|
||||||
|
|
||||||
set_property(
|
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
|
||||||
TARGET slint-cpp
|
corrosion_set_hostbuild(slint-compiler)
|
||||||
PROPERTY CORROSION_FEATURES
|
endif()
|
||||||
${features}
|
|
||||||
)
|
|
||||||
set_property(
|
|
||||||
TARGET slint-cpp
|
|
||||||
PROPERTY CORROSION_NO_DEFAULT_FEATURES
|
|
||||||
ON
|
|
||||||
)
|
|
||||||
|
|
||||||
if(SLINT_FEATURE_BACKEND_QT)
|
if (SLINT_BUILD_RUNTIME)
|
||||||
# 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(NOT TARGET Qt::qmake)
|
# When doing "make install" package builds, set install_name to rpath, so that the installed
|
||||||
find_package(Qt5 5.15 QUIET COMPONENTS Core Widgets)
|
# 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()
|
||||||
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(
|
set_property(
|
||||||
TARGET slint-cpp
|
TARGET slint-cpp
|
||||||
APPEND
|
APPEND
|
||||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
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(
|
set_property(
|
||||||
TARGET slint-cpp
|
TARGET slint-cpp
|
||||||
APPEND
|
PROPERTY CORROSION_FEATURES
|
||||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
${features}
|
||||||
SLINT_NO_QT=1
|
)
|
||||||
|
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)
|
if(SLINT_FEATURE_BACKEND_QT)
|
||||||
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE})
|
# For the CMake build don't rely on qmake being in PATH but use CMake to locate Qt. This
|
||||||
else(SLINT_STYLE)
|
# means usually CMAKE_PREFIX_PATH is set.
|
||||||
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE_DEFAULT})
|
find_package(Qt6 6.2 QUIET COMPONENTS Core Widgets)
|
||||||
endif(SLINT_STYLE)
|
|
||||||
|
|
||||||
if(SLINT_FEATURE_RENDERER_SKIA OR SLINT_FEATURE_RENDERER_SKIA_OPENGL OR SLINT_FEATURE_RENDERER_SKIA_VULKAN)
|
if(NOT TARGET Qt::qmake)
|
||||||
find_program(CLANGCC clang)
|
find_package(Qt5 5.15 QUIET COMPONENTS Core Widgets)
|
||||||
find_program(CLANGCXX clang++)
|
endif()
|
||||||
if(CLANGCC AND CLANGCXX)
|
endif(SLINT_FEATURE_BACKEND_QT)
|
||||||
|
|
||||||
|
if(TARGET Qt::qmake)
|
||||||
set_property(
|
set_property(
|
||||||
TARGET slint-cpp
|
TARGET slint-cpp
|
||||||
APPEND
|
APPEND
|
||||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||||
CLANGCC=${CLANGCC}
|
QMAKE=$<TARGET_PROPERTY:Qt::qmake,LOCATION>
|
||||||
)
|
)
|
||||||
|
set(SLINT_STYLE_DEFAULT "native")
|
||||||
|
else()
|
||||||
set_property(
|
set_property(
|
||||||
TARGET slint-cpp
|
TARGET slint-cpp
|
||||||
APPEND
|
APPEND
|
||||||
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
|
||||||
CLANGCXX=${CLANGCXX}
|
SLINT_NO_QT=1
|
||||||
)
|
)
|
||||||
|
set(SLINT_STYLE_DEFAULT "fluent")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The Skia cross-build requires a host C compiler (due to some build dependencies of rust-skia),
|
set(SLINT_STYLE "" CACHE STRING "The Slint Widget Style")
|
||||||
# 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
|
if(SLINT_STYLE)
|
||||||
# HOST_CC to $CC, which is a good bet. Unfortunately in Yocto environments, CC will be set to
|
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE})
|
||||||
# the cross-compiler. The same applies to CFLAGS, which may contain target specific options.
|
else(SLINT_STYLE)
|
||||||
# So the hack to solve this is two-fold:
|
set_property(GLOBAL PROPERTY SLINT_STYLE ${SLINT_STYLE_DEFAULT})
|
||||||
# * We look for clang or gcc in PATH - unprefixed those are usually host compilers.
|
endif(SLINT_STYLE)
|
||||||
# * 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)
|
||||||
if(CMAKE_CROSSCOMPILING AND Rust_CARGO_HOST_TARGET)
|
find_program(CLANGCC clang)
|
||||||
if(CLANGCC)
|
find_program(CLANGCXX clang++)
|
||||||
set(host_cc "${CLANGCC}")
|
if(CLANGCC AND CLANGCXX)
|
||||||
else()
|
set_property(
|
||||||
find_program(GCC gcc)
|
TARGET slint-cpp
|
||||||
if (GCC)
|
APPEND
|
||||||
set(host_cc "${GCC}")
|
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()
|
||||||
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()
|
||||||
endif()
|
|
||||||
|
|
||||||
file(GLOB api_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include/"
|
file(GLOB api_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include/"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
|
||||||
|
|
||||||
foreach(header IN LISTS api_headers)
|
foreach(header IN LISTS api_headers)
|
||||||
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER include/${header})
|
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER include/${header})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(generated_headers
|
set(generated_headers
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_internal.h
|
${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_internal.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_enums.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_internal.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_builtin_structs.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_string_internal.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_brush_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_sharedvector_internal.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_properties_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_image_internal.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_color_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_pathdata_internal.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_qt_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_platform_internal.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_generated_public.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
|
|
||||||
)
|
)
|
||||||
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)
|
foreach(header IN LISTS generated_headers)
|
||||||
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER ${header})
|
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER ${header})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
target_include_directories(Slint INTERFACE
|
target_include_directories(Slint INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_include>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include/slint>
|
$<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
|
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
|
||||||
NAMESPACE Slint:: FILE "${CMAKE_BINARY_DIR}/lib/cmake/Slint/SlintTargets.cmake")
|
add_executable(Slint::slint-compiler ALIAS slint-compiler)
|
||||||
install(EXPORT SlintTargets NAMESPACE Slint:: DESTINATION lib/cmake/Slint)
|
include(${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake)
|
||||||
install(TARGETS Slint slint-cpp
|
endif()
|
||||||
EXPORT SlintTargets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/slint)
|
|
||||||
|
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(CMakePackageConfigHelpers)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
install(FILES $<TARGET_FILE:${slint_cpp_impl}> TYPE LIB)
|
|
||||||
|
|
||||||
if(WIN32)
|
if(SLINT_FEATURE_COMPILER AND NOT SLINT_COMPILER)
|
||||||
install(FILES $<TARGET_LINKER_FILE:${slint_cpp_impl}> TYPE LIB)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SLINT_FEATURE_COMPILER)
|
|
||||||
install(PROGRAMS $<TARGET_FILE:slint-compiler> TYPE BIN)
|
install(PROGRAMS $<TARGET_FILE:slint-compiler> TYPE BIN)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Corrosion sets the `IMPORTED` locations late to allow us to set OUTPUT_DIRECTORY
|
if(SLINT_BUILD_RUNTIME)
|
||||||
# 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(value)
|
# Corrosion sets the `IMPORTED` locations late to allow us to set OUTPUT_DIRECTORY
|
||||||
get_filename_component(value ${value} NAME)
|
# target properties. This function must be deferred until after Corrosion set the
|
||||||
list(APPEND SLINT_LIB_PROPERTIES ${prop} "\${_IMPORT_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${value}")
|
# locations. Since we are writing to a config file Generator expressions are not
|
||||||
endif()
|
# an option.
|
||||||
endforeach()
|
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)
|
if(value)
|
||||||
configure_package_config_file("cmake/SlintConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake" INSTALL_DESTINATION lib/cmake/Slint)
|
get_filename_component(value ${value} NAME)
|
||||||
endfunction()
|
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_language(DEFER CALL _slint_write_configure_file)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake
|
|
||||||
VERSION 1.3.0
|
|
||||||
COMPATIBILITY SameMinorVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
write_basic_package_version_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake"
|
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake"
|
VERSION 1.3.0
|
||||||
DESTINATION lib/cmake/Slint
|
COMPATIBILITY SameMinorVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
if(SLINT_FEATURE_COMPILER)
|
|
||||||
install(FILES
|
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"
|
"${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake"
|
||||||
DESTINATION lib/cmake/Slint
|
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(SLINT_PACKAGE_BUNDLE_QT)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_package(Qt6 6.0 COMPONENTS Core Gui Widgets Svg)
|
find_package(Qt6 6.0 COMPONENTS Core Gui Widgets Svg)
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
$<TARGET_FILE:Qt6::Core>
|
$<TARGET_FILE:Qt6::Core>
|
||||||
$<TARGET_FILE:Qt6::Gui>
|
$<TARGET_FILE:Qt6::Gui>
|
||||||
$<TARGET_FILE:Qt6::Widgets>
|
$<TARGET_FILE:Qt6::Widgets>
|
||||||
$<TARGET_FILE:Qt6::Svg>
|
$<TARGET_FILE:Qt6::Svg>
|
||||||
TYPE LIB)
|
TYPE LIB)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES ${Qt6_DIR}/../../../plugins/platforms/qwindows.dll
|
FILES ${Qt6_DIR}/../../../plugins/platforms/qwindows.dll
|
||||||
DESTINATION plugins/platforms)
|
DESTINATION plugins/platforms)
|
||||||
install(
|
install(
|
||||||
FILES ${Qt6_DIR}/../../../plugins/styles/qwindowsvistastyle.dll
|
FILES ${Qt6_DIR}/../../../plugins/styles/qwindowsvistastyle.dll
|
||||||
DESTINATION plugins/styles)
|
DESTINATION plugins/styles)
|
||||||
install(
|
install(
|
||||||
FILES ${Qt6_DIR}/../../../plugins/imageformats/qsvg.dll
|
FILES ${Qt6_DIR}/../../../plugins/imageformats/qsvg.dll
|
||||||
DESTINATION plugins/imageformats)
|
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)
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
||||||
include(InstallRequiredSystemLibraries)
|
include(InstallRequiredSystemLibraries)
|
||||||
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} TYPE LIB)
|
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} TYPE LIB)
|
||||||
endif()
|
endif()
|
||||||
endif(SLINT_PACKAGE_BUNDLE_QT)
|
endif(SLINT_PACKAGE_BUNDLE_QT)
|
||||||
|
|
||||||
|
endif(SLINT_BUILD_RUNTIME)
|
||||||
|
|
||||||
set(CPACK_PACKAGE_NAME "Slint-cpp")
|
set(CPACK_PACKAGE_NAME "Slint-cpp")
|
||||||
set(CPACK_PACKAGE_VENDOR "Slint")
|
set(CPACK_PACKAGE_VENDOR "Slint")
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,13 @@ endif()
|
||||||
add_library(@slint_cpp_impl@ @cmake_lib_type@ IMPORTED)
|
add_library(@slint_cpp_impl@ @cmake_lib_type@ IMPORTED)
|
||||||
set_target_properties(@slint_cpp_impl@ PROPERTIES @SLINT_LIB_PROPERTIES@)
|
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)
|
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}")
|
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")
|
include("${CMAKE_CURRENT_LIST_DIR}/SlintMacro.cmake")
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@ if(NOT SLINT_FEATURE_FREESTANDING)
|
||||||
endif()
|
endif()
|
||||||
slint_test(models)
|
slint_test(models)
|
||||||
|
|
||||||
add_subdirectory(multiple-includes)
|
if(SLINT_FEATURE_COMPILER OR SLINT_COMPILER)
|
||||||
|
add_subdirectory(multiple-includes)
|
||||||
|
endif()
|
||||||
|
|
||||||
slint_test(platform_eventloop)
|
slint_test(platform_eventloop)
|
||||||
target_link_libraries(test_platform_eventloop PRIVATE Threads::Threads)
|
target_link_libraries(test_platform_eventloop PRIVATE Threads::Threads)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue