This commit is contained in:
Chris Cochrun 2025-07-25 15:19:21 -05:00
parent 92f2b18a20
commit 504b4bc944
24 changed files with 289 additions and 175 deletions

View file

@ -30,7 +30,10 @@ include(ECMPoQmTools)
kde_enable_exceptions()
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Core5Compat Quick Test Gui Qml QuickControls2 Widgets Sql QmlImportScanner WebEngineQuick)
set(CXXQT_QTCOMPONENTS Core Gui Qml QuickControls2 QuickTest Test)
set(CXXQT_QTCOMPONENTS ${CXXQT_QTCOMPONENTS} QmlImportScanner)
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Core5Compat Quick Test Gui Qml QuickControls2 Widgets Sql QmlImportScanner WebEngineQuick Multimedia)
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami CoreAddons I18n)
# find_package(KF6FileMetaData ${KF6_MIN_VERSION})
@ -57,45 +60,70 @@ set_package_properties(Ytdlp PROPERTIES TYPE RUNTIME)
# execute_process(COMMAND ${XDG-DESKTOP-MENU_EXECUTABLE} install --novender librepresenter.desktop)
get_target_property(QMAKE Qt::qmake IMPORTED_LOCATION)
find_package(Corrosion QUIET)
if(NOT Corrosion_FOUND)
find_package(CxxQt QUIET)
if(NOT CxxQt_FOUND)
include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.3.0
CxxQt
GIT_REPOSITORY https://github.com/kdab/cxx-qt-cmake.git
GIT_TAG v0.7.0
)
FetchContent_MakeAvailable(Corrosion)
FetchContent_MakeAvailable(CxxQt)
endif()
add_subdirectory(src)
# find_package(Corrosion QUIET)
# if(NOT Corrosion_FOUND)
# include(FetchContent)
# FetchContent_Declare(
# Corrosion
# GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
# GIT_TAG v0.3.0
# )
# FetchContent_MakeAvailable(Corrosion)
# endif()
set(CRATE liblumina)
# CXX-Qt (using Corrosion) creates a CMake target with the same name as the crate.
cxx_qt_import_crate(
MANIFEST_PATH Cargo.toml
CRATES liblumina
QT_MODULES Qt::Core Qt::Gui Qt::Qml Qt::QuickControls2 Qt::WebEngineQuick)
cxx_qt_import_qml_module(liblumina_qml_module
URI "org.presenter"
SOURCE_CRATE liblumina)
# Corrosion creates a CMake target with the same name as the crate.
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES ${CRATE})
# corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES ${CRATE})
# The Rust library's build script needs to be told where to output the
# generated headers so CMake can find them. To do this, tell Corrosion
# to set the CXXQT_EXPORT_DIR environment variable when calling `cargo build`.
# Also, set the QMAKE environment variable to ensure the Rust library uses
# the same installation of Qt as CMake.
set(CXXQT_EXPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/cxxqt")
corrosion_set_env_vars(${CRATE}
"CXXQT_EXPORT_DIR=${CXXQT_EXPORT_DIR}"
"QMAKE=${QMAKE}"
)
# set(CXXQT_EXPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/cxxqt")
# corrosion_set_env_vars(${CRATE}
# "CXXQT_EXPORT_DIR=${CXXQT_EXPORT_DIR}"
# "QMAKE=${QMAKE}"
# )
add_library(${APP_NAME}_lib INTERFACE)
add_subdirectory(src)
# Include the headers generated by the Rust library's build script. Each
# crate gets its own subdirectory under CXXQT_EXPORT_DIR. This allows you
# to include headers generated by multiple crates without risk of one crate
# overwriting another's files.
target_include_directories(${APP_NAME}_lib INTERFACE "${CXXQT_EXPORT_DIR}/${CRATE}")
target_include_directories(liblumina INTERFACE "${CXXQT_EXPORT_DIR}/${CRATE}")
# Link the Rust INTERFACE library target to Qt. Do this on the library target
# rather than the main executable. This way, CMake targets besides the main
# executable which link the Rust library, for example tests, will also link Qt.
target_link_libraries(${APP_NAME}_lib INTERFACE
target_link_libraries(liblumina INTERFACE
"$<LINK_LIBRARY:WHOLE_ARCHIVE,${CRATE}-static>"
Qt6::Quick
Qt6::Qml
@ -104,6 +132,7 @@ target_link_libraries(${APP_NAME}_lib INTERFACE
Qt6::Widgets
Qt6::Sql
Qt6::WebEngineQuick
Qt6::Multimedia
KF6::Kirigami
KF6::I18n
KF6::CoreAddons
@ -114,8 +143,9 @@ target_link_libraries(${APP_NAME}_lib INTERFACE
crypto
)
# Link to the Rust library
target_link_libraries(${APP_NAME} PRIVATE ${APP_NAME}_lib)
target_link_libraries(${APP_NAME} PRIVATE liblumina)
# If we are using a statically linked Qt then we need to import any qml plugins
qt_import_qml_plugins(${APP_NAME})