Compare commits

...

2 commits

Author SHA1 Message Date
a5669dab71 add nix tooling 2024-04-09 13:59:35 +02:00
tuxmaster5000
773d9f1329 Add support for Qt6 2024-04-09 13:59:35 +02:00
9 changed files with 120 additions and 15 deletions

6
.gitignore vendored
View file

@ -1,5 +1 @@
# User
*.user
# Build directory
build/
result

View file

@ -5,10 +5,11 @@ cmake_minimum_required(VERSION 3.12.4)
option(BUILD_TESTS "Build tests" OFF)
option(BUILD_UTILS "Build utilities" ON)
option(BUILD_DOCS "Build documentation" ON)
option(FORCE_QT5 "Ignore Qt6 when found." OFF)
# Version
if (NOT PROJECT_VERSION)
set(PROJECT_VERSION "0.0.1")
set(PROJECT_VERSION "0.1.0")
endif()
if (NOT PROJECT_VERSION_MAJOR)
@ -20,7 +21,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_FLAGS "-g -Wall")
set(QT_MINIMUM_VERSION "5.6.3")
set(QT5_MINIMUM_VERSION "5.15.0")
# Install settings
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
@ -29,8 +30,22 @@ endif ()
include(GNUInstallDirs)
# Find the QtWidgets library
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Core)
# Find the Qt library
if (NOT FORCE_QT5)
find_package(Qt6 COMPONENTS Core)
endif()
if(Qt6_FOUND)
message(STATUS "Using Qt6")
else()
find_package(Qt5 ${QT5_MINIMUM_VERSION} COMPONENTS Core)
if(Qt5_FOUND)
message(STATUS "Using Qt5")
endif()
endif()
if(NOT Qt${QT_DEFAULT_MAJOR_VERSION}_FOUND)
message(FATAL_ERROR "Qt6 or Qt5 >= ${QT5_MINIMUM_VERSION} are required.")
endif()
find_package(PkgConfig REQUIRED)
find_package(Doxygen)
@ -39,7 +54,7 @@ pkg_check_modules(GIOMM giomm-2.4) # look into FindPkgConfig.cmake
add_subdirectory (gio-qt)
if (BUILD_TESTS)
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Test)
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Test REQUIRED)
add_subdirectory(test)
endif ()
@ -69,7 +84,7 @@ if (BUILD_DOCS)
COMMENT "Generate documentation via Doxygen"
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/docs/gio-qt.qch DESTINATION share/qt5/doc)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/docs/gio-qt.qch DESTINATION share/qt${QT_DEFAULT_MAJOR_VERSION}/doc)
else ()
message (STATUS "")

26
flake.lock Normal file
View file

@ -0,0 +1,26 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1712604496,
"narHash": "sha256-Ye1R+k60uo0B3mn5xwsgb0PzceSg9y0E2OMYQnizLD0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ed6db4c403cc2fc4924d24e1a2a2f148c6152620",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixpkgs-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

27
flake.nix Normal file
View file

@ -0,0 +1,27 @@
{
description = "Gio wrapper for Qt6 applications";
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
outputs = {
nixpkgs,
self,
...
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
in {
packages = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
gio-qt6-pkg = (pkgs.qt6Packages.callPackage ./nix/package.nix {});
in {
gio-qt6 = gio-qt6-pkg;
default = gio-qt6-pkg;
});
};
}

View file

@ -55,7 +55,7 @@ PUBLIC
${CMAKE_CURRENT_LIST_DIR}/include
)
target_link_libraries (gio-qt Qt5::Core ${GIOMM_LIBRARIES})
target_link_libraries (gio-qt Qt::Core ${GIOMM_LIBRARIES})
target_compile_definitions(gio-qt PRIVATE
QT_NO_KEYWORDS

View file

@ -6,7 +6,7 @@ includedir=${prefix}/include
Name: gio-qt
Description: Qt wrapper library for GIO.
Version: @PROJECT_VERSION@
Requires: glibmm-2.4, Qt5Core
Requires: glibmm-2.4, Qt@QT5_MINIMUM_VERSION@Core
Libs: -L${libdir} -lgio-qt
Cflags: -I${includedir} -I${includedir}/gio-qt
Cflags: -I${includedir} -I${includedir}/gio-qt

View file

@ -8,6 +8,8 @@
#include <QObject>
#include <QSharedData>
#include <climits>
namespace Gio {
class File;
}

39
nix/package.nix Normal file
View file

@ -0,0 +1,39 @@
{ stdenv
, lib
, fetchFromGitHub
, cmake
, pkg-config
, glibmm
, doxygen
, qt6
, buildDocs ? true
}:
stdenv.mkDerivation rec {
pname = "gio-qt6";
version = "0.1.0";
src = lib.cleanSource ../.;
nativeBuildInputs = [
cmake
pkg-config
qt6.wrapQtAppsHook
] ++ lib.optionals buildDocs [ doxygen qt6.qttools.dev ];
cmakeFlags = [
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DPROJECT_VERSION=${version}"
"-DBUILD_DOCS=OFF"
] ++ lib.optionals (!buildDocs) [ "-DBUILD_DOCS=OFF" ];
propagatedBuildInputs = [ glibmm ];
meta = with lib; {
description = "Gio wrapper for Qt6 applications";
homepage = "https://git.grimmauld.de/Grimmauld/gio-qt";
license = licenses.lgpl3Plus;
platforms = platforms.linux;
maintainers = with maintainers; [grimmauld];
};
}

View file

@ -10,7 +10,7 @@ function(DGIO_CREATE_TEST _generated_target_name _input_file_name _use_giomm)
${_input_file_name}
)
add_test (NAME ${_generated_target_name} COMMAND ${_generated_target_name} )
target_link_libraries (${_generated_target_name} gio-qt Qt5::Test ${extra_libraries})
target_link_libraries (${_generated_target_name} gio-qt Qt::Test ${extra_libraries})
if (_use_giomm)
target_include_directories(${_generated_target_name} PRIVATE ${GIOMM_INCLUDE_DIRS})
target_compile_definitions(${_generated_target_name} PRIVATE QT_NO_KEYWORDS)