forked from mirrors/gio-qt
Add support for Qt6
This commit is contained in:
parent
779ec19a9d
commit
773d9f1329
5 changed files with 27 additions and 10 deletions
|
@ -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 "")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <QObject>
|
||||
#include <QSharedData>
|
||||
|
||||
#include <climits>
|
||||
|
||||
namespace Gio {
|
||||
class 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)
|
||||
|
|
Loading…
Reference in a new issue