updates to build system

This commit is contained in:
Chris Cochrun 2022-12-08 15:21:08 -06:00
parent b5911d6ed4
commit 02c3e84cb6
8 changed files with 97 additions and 36 deletions

3
.envrc
View file

@ -1 +1,2 @@
use flake export NIXPKGS_ALLOW_INSECURE=1
use flake . --impure

View file

@ -1,10 +1,13 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(presenter) project(presenter)
set(APP_NAME ${PROJECT_NAME})
include(FeatureSummary) include(FeatureSummary)
set(QT5_MIN_VERSION 5.15) set(QT5_MIN_VERSION 5.15)
set(KF5_MIN_VERSION 5.83) set(KF5_MIN_VERSION 5.83)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
@ -26,7 +29,7 @@ include(ECMPoQmTools)
kde_enable_exceptions() kde_enable_exceptions()
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Widgets Sql X11Extras) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Widgets Sql X11Extras QmlImportScanner)
find_package(KF5 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 I18n Archive CoreAddons) find_package(KF5 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 I18n Archive CoreAddons)
find_package(Libmpv) find_package(Libmpv)
@ -51,12 +54,68 @@ INCLUDE_DIRECTORIES(
${LIBPODOFO_CONFIG_H} ${LIBPODOFO_CONFIG_H}
) )
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # 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) add_subdirectory(src)
set(CRATE qml-minimal)
# Corrosion creates a CMake target with the same name as the crate.
corrosion_import_crate(MANIFEST_PATH src/rust/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}"
)
# 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(${CRATE} 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(${CRATE} INTERFACE
Qt5::Quick
Qt5::Qml
Qt5::Gui
Qt5::QuickControls2
Qt5::Widgets
Qt5::Sql
Qt5::X11Extras
KF5::Kirigami2
KF5::I18n
KF5::Archive
podofo
mpv
)
# Link to the Rust library
target_link_libraries(${APP_NAME} PRIVATE ${CRATE})
# 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) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
find_program(XDG-DESKTOP-MENU_EXECUTABLE xdg-desktop-menu)
execute_process(COMMAND ${XDG-DESKTOP-MENU_EXECUTABLE} install --novender librepresenter.desktop)

12
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1667395993,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,11 +17,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1666282307, "lastModified": 1670332253,
"narHash": "sha256-O1T2HGLARLKDLfdOmjPBfn3eC4cSIaQD71wUN4I/6/s=", "narHash": "sha256-O5SmhlIUt1s+vK4NXeGYqwcBIMwbBPAEZ3GHE3XT28c=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b7d8c687782c8f9a1d425a7e486eb989654f6468", "rev": "1c9ffcf70786f0966982ce0fc76ec05df2e1dec2",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -7,7 +7,6 @@ mkShell rec {
gcc gcc
gnumake gnumake
clang clang
clang-tools
qtcreator qtcreator
cmake cmake
extra-cmake-modules extra-cmake-modules
@ -19,7 +18,7 @@ mkShell rec {
buildInputs = [ buildInputs = [
clang-tools clang-tools
# clang-format # clang-format
qt5.full qt5.qtbase
qt5.qttools qt5.qttools
qt5.qtquickcontrols2 qt5.qtquickcontrols2
qt5.qtx11extras qt5.qtx11extras
@ -35,17 +34,22 @@ mkShell rec {
libsForQt5.kcoreaddons libsForQt5.kcoreaddons
libsForQt5.kguiaddons libsForQt5.kguiaddons
# This is only here because apparently it doesn't pick up the icon theme from the base system
# papirus-icon-theme
lightly-qt
podofo podofo
mpv mpv
# libsForQt5.kconfig # libsForQt5.kconfig
# ffmpeg-full # ffmpeg-full
# yt-dlp # yt-dlp
# Rust tools
clippy
rustc
cargo
rustfmt
rust-analyzer
corrosion
]; ];
RUST_BACKTRACE = 1;
# This creates the proper qt env so that plugins are found right. # This creates the proper qt env so that plugins are found right.
shellHook = '' shellHook = ''
setQtEnvironment=$(mktemp --suffix .setQtEnvironment.sh) setQtEnvironment=$(mktemp --suffix .setQtEnvironment.sh)

View file

@ -1,4 +1,5 @@
add_executable(presenter)
add_executable(presenter main.cpp resources.qrc)
target_sources(presenter target_sources(presenter
PRIVATE PRIVATE
@ -15,20 +16,4 @@ target_sources(presenter
mpv/qthelper.hpp mpv/mpvhelpers.h mpv/qthelper.hpp mpv/mpvhelpers.h
) )
target_link_libraries(presenter
Qt5::Quick
Qt5::Qml
Qt5::Gui
Qt5::QuickControls2
Qt5::Widgets
Qt5::Sql
Qt5::X11Extras
KF5::Kirigami2
KF5::CoreAddons
KF5::I18n
KF5::Archive
podofo
mpv
)
target_compile_options (presenter PUBLIC -fexceptions) target_compile_options (presenter PUBLIC -fexceptions)

View file

@ -43,6 +43,9 @@
#include "filemanager.h" #include "filemanager.h"
#include "slide.h" #include "slide.h"
// RUST
#include "cxx-qt-gen/my_object.cxxqt.h"
static void connectToDatabase() { static void connectToDatabase() {
// let's setup our sql database // let's setup our sql database
QSqlDatabase db = QSqlDatabase::database(); QSqlDatabase db = QSqlDatabase::database();
@ -128,6 +131,7 @@ int main(int argc, char *argv[])
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel"); qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");
qmlRegisterType<PresentationSqlModel>("org.presenter", 1, 0, "PresentationSqlModel"); qmlRegisterType<PresentationSqlModel>("org.presenter", 1, 0, "PresentationSqlModel");
qmlRegisterType<ServiceItemModel>("org.presenter", 1, 0, "ServiceItemModel"); qmlRegisterType<ServiceItemModel>("org.presenter", 1, 0, "ServiceItemModel");
qmlRegisterType<MyObject>("org.presenter", 1, 0, "MyObject");
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slide.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slide.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get());

View file

@ -180,6 +180,12 @@ Kirigami.ApplicationWindow {
/* print(loaded[0].audio); */ /* print(loaded[0].audio); */
} }
MyObject {
id: myObject
number: 7
string: "HI from rust in my proj: " + myObject.number
}
Component.onCompleted: { Component.onCompleted: {
/* showPassiveNotification(Kirigami.Settings.style); */ /* showPassiveNotification(Kirigami.Settings.style); */
/* Kirigami.Settings.style = "Plasma"; */ /* Kirigami.Settings.style = "Plasma"; */

View file

@ -50,11 +50,13 @@ FocusScope {
text: "Grid" text: "Grid"
icon.name: "view-app-grid-symbolic" icon.name: "view-app-grid-symbolic"
hoverEnabled: true hoverEnabled: true
onClicked: myObject.sayHi(myObject.string, myObject.number);
} }
Controls.ToolButton { Controls.ToolButton {
text: "Details" text: "Details"
icon.name: "view-list-details" icon.name: "view-list-details"
hoverEnabled: true hoverEnabled: true
onClicked: showPassiveNotification(myObject.string);
} }
Controls.ToolSeparator {} Controls.ToolSeparator {}
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }