lumina/CMakeLists.txt
Chris Cochrun 61aef5c48f Moving to QT6: Read more
QT6 Apparently means a lot of changes, these are the changes I've
found to make at least CPP build. The problem is we just got rid of a
lot of CPP and I don't know if the application will work. On the other
hand, the QML isn't finished yet either, but this is the start of
updating the application for QT6 and using MpvQt which is being built
and maintained by KDE. This will be better as they'll keep the library
updated for future QT updates so long as I still track with Kirigami.
2024-09-15 06:05:56 -05:00

115 lines
3.6 KiB
CMake

cmake_minimum_required(VERSION 3.16)
project(lumina)
set(APP_NAME ${PROJECT_NAME})
include(FeatureSummary)
set(QT_MIN_VERSION 6.6.0)
set(KF_MIN_VERSION 6.00)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
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)
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami CoreAddons I18n)
find_package(FFmpeg)
set_package_properties(FFmpeg PROPERTIES TYPE REQUIRED)
find_package(Libmpv)
set_package_properties(Libmpv PROPERTIES TYPE REQUIRED)
find_package(MpvQt)
set_package_properties(MpvQt PROPERTIES TYPE REQUIRED
URL "https://invent.kde.org/libraries/mpvqt")
find_package(YouTubeDl)
set_package_properties(YouTubeDl PROPERTIES TYPE RUNTIME)
find_package(Ytdlp)
set_package_properties(Ytdlp PROPERTIES TYPE RUNTIME)
# find_program(XDG-DESKTOP-MENU_EXECUTABLE xdg-desktop-menu)
# 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)
include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.3.0
)
FetchContent_MakeAvailable(Corrosion)
endif()
add_subdirectory(src)
set(CRATE liblumina)
# Corrosion creates a CMake target with the same name as the 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}"
)
add_library(${APP_NAME}_lib INTERFACE)
# 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}")
# 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
"$<LINK_LIBRARY:WHOLE_ARCHIVE,${CRATE}-static>"
Qt6::Quick
Qt6::Qml
Qt6::Gui
Qt6::QuickControls2
Qt6::Widgets
Qt6::Sql
Qt6::WebEngineQuick
KF6::Kirigami
KF6::I18n
KF6::CoreAddons
MpvQt::MpvQt
mpv
ssl
crypto
)
# Link to the Rust library
target_link_libraries(${APP_NAME} PRIVATE ${APP_NAME}_lib)
# If we are using a statically linked Qt then we need to import any qml plugins
qt_import_qml_plugins(${APP_NAME})
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)