Compare commits

...

2 Commits

Author SHA1 Message Date
678456bacc add nix tooling 2024-04-09 14:05:59 +02:00
tuxmaster5000
d7012df2ce Add support for Qt6 2024-04-09 19:52:34 +08:00
9 changed files with 120 additions and 15 deletions

6
.gitignore vendored
View File

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

View File

@ -5,10 +5,11 @@ cmake_minimum_required(VERSION 3.12.4)
option(BUILD_TESTS "Build tests" OFF) option(BUILD_TESTS "Build tests" OFF)
option(BUILD_UTILS "Build utilities" ON) option(BUILD_UTILS "Build utilities" ON)
option(BUILD_DOCS "Build documentation" ON) option(BUILD_DOCS "Build documentation" ON)
option(FORCE_QT5 "Ignore Qt6 when found." OFF)
# Version # Version
if (NOT PROJECT_VERSION) if (NOT PROJECT_VERSION)
set(PROJECT_VERSION "0.0.1") set(PROJECT_VERSION "0.1.0")
endif() endif()
if (NOT PROJECT_VERSION_MAJOR) if (NOT PROJECT_VERSION_MAJOR)
@ -20,7 +21,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed # Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_FLAGS "-g -Wall") set(CMAKE_CXX_FLAGS "-g -Wall")
set(QT_MINIMUM_VERSION "5.6.3") set(QT5_MINIMUM_VERSION "5.15.0")
# Install settings # Install settings
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
@ -29,8 +30,22 @@ endif ()
include(GNUInstallDirs) include(GNUInstallDirs)
# Find the QtWidgets library # Find the Qt library
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Core) 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(PkgConfig REQUIRED)
find_package(Doxygen) find_package(Doxygen)
@ -39,7 +54,7 @@ pkg_check_modules(GIOMM giomm-2.4) # look into FindPkgConfig.cmake
add_subdirectory (gio-qt) add_subdirectory (gio-qt)
if (BUILD_TESTS) 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) add_subdirectory(test)
endif () endif ()
@ -69,7 +84,7 @@ if (BUILD_DOCS)
COMMENT "Generate documentation via Doxygen" 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 () else ()
message (STATUS "") 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 ${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 target_compile_definitions(gio-qt PRIVATE
QT_NO_KEYWORDS QT_NO_KEYWORDS

View File

@ -6,7 +6,7 @@ includedir=${prefix}/include
Name: gio-qt Name: gio-qt
Description: Qt wrapper library for GIO. Description: Qt wrapper library for GIO.
Version: @PROJECT_VERSION@ Version: @PROJECT_VERSION@
Requires: glibmm-2.4, Qt5Core Requires: glibmm-2.4, Qt@QT5_MINIMUM_VERSION@Core
Libs: -L${libdir} -lgio-qt 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 <QObject>
#include <QSharedData> #include <QSharedData>
#include <climits>
namespace Gio { namespace Gio {
class File; 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} ${_input_file_name}
) )
add_test (NAME ${_generated_target_name} COMMAND ${_generated_target_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) if (_use_giomm)
target_include_directories(${_generated_target_name} PRIVATE ${GIOMM_INCLUDE_DIRS}) target_include_directories(${_generated_target_name} PRIVATE ${GIOMM_INCLUDE_DIRS})
target_compile_definitions(${_generated_target_name} PRIVATE QT_NO_KEYWORDS) target_compile_definitions(${_generated_target_name} PRIVATE QT_NO_KEYWORDS)