From be20c3d38962083edfcd028344fcb1256e589013 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 5 Apr 2024 00:09:49 +0800 Subject: [PATCH] chore: use Qt 6 by default --- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- CMakeLists.txt | 26 +++++++++++--------------- appveyor.yml | 4 ++-- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index cb2d12b..533bd5d 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -15,5 +15,5 @@ jobs: version: '5.15.2' - name: Run a qt project run: | - cmake ./ + cmake ./ -DPREFER_QT_5=ON make diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d9423f3..ff997ed 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -17,7 +17,7 @@ jobs: run: | mkdir build cd build - cmake ../ + cmake ../ -DPREFER_QT_5=ON make cpack -G DEB - name: Try install it diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e2a11f..1c7ad42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,18 @@ -# SPDX-FileCopyrightText: 2022 - 2023 Gary Wang +# SPDX-FileCopyrightText: 2022 - 2024 Gary Wang # # SPDX-License-Identifier: MIT -project (pineapple-pictures) - cmake_minimum_required (VERSION 3.9.5) +project (pineapple-pictures) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) include (GNUInstallDirs) include (FeatureSummary) option (EXIV2_METADATA_SUPPORT "Better image metadata support via libexiv2" ON) -option (PREFER_QT_5 "Prefer to use Qt 5 even if we have Qt 6" ON) +option (PREFER_QT_5 "Prefer to use Qt 5" OFF) set (CMAKE_CXX_STANDARD 17) set (CMAKE_CXX_STANDARD_REQUIRED ON) @@ -22,7 +22,7 @@ set (CMAKE_AUTORCC ON) if (PREFER_QT_5) find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core) else () - find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) + find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core) endif () if (${QT_VERSION_MAJOR} EQUAL "5") @@ -104,20 +104,21 @@ set (EXE_NAME ppic) file (GLOB PPIC_TS_FILES app/translations/*.ts) set (PPIC_CPP_FILES_FOR_I18N ${PPIC_CPP_FILES}) -qt_create_translation(PPIC_QM_FILES ${PPIC_CPP_FILES_FOR_I18N} ${PPIC_TS_FILES}) - if (WIN32) list(APPEND PPIC_RC_FILES assets/pineapple-pictures.rc) endif () -add_executable (${EXE_NAME} +add_executable (${EXE_NAME} WIN32 ${PPIC_HEADER_FILES} ${PPIC_CPP_FILES} ${PPIC_QRC_FILES} ${PPIC_RC_FILES} - ${PPIC_QM_FILES} ) +qt_create_translation(PPIC_QM_FILES ${PPIC_CPP_FILES_FOR_I18N} ${PPIC_TS_FILES}) + +target_sources(${EXE_NAME} PRIVATE ${PPIC_QM_FILES}) + target_link_libraries (${EXE_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg) if (${QT_VERSION_MAJOR} EQUAL "6") target_link_libraries (${EXE_NAME} Qt::SvgWidgets) @@ -137,7 +138,7 @@ if (LibExiv2_FOUND) ) endif () -if (Qt5DBus_FOUND OR Qt6DBus_FOUND) +if (TARGET Qt5::DBus OR TARGET Qt6::DBus) target_link_libraries (${EXE_NAME} Qt${QT_VERSION_MAJOR}::DBus ) @@ -148,11 +149,6 @@ endif() # Extra build settings if (WIN32) - set_property ( - TARGET ${EXE_NAME} - PROPERTY WIN32_EXECUTABLE true - ) - target_compile_definitions(${EXE_NAME} PRIVATE FLAG_PORTABLE_MODE_SUPPORT=1 ) diff --git a/appveyor.yml b/appveyor.yml index c067dea..3da2876 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,7 @@ environment: KF_BRANCH: kf5 EXIV2_VERSION: "0.27.7" EXIV2_CMAKE_OPTIONS: "-DEXIV2_BUILD_SAMPLES=OFF -DEXIV2_ENABLE_WIN_UNICODE=ON -DEXIV2_BUILD_EXIV2_COMMAND=OFF" - PPIC_CMAKE_OPTIONS: "" + PPIC_CMAKE_OPTIONS: "-DPREFER_QT_5=ON" WINDEPLOYQT_ARGS: "--verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-angle --no-system-d3d-compiler" install: @@ -132,7 +132,7 @@ build_script: # finally... - mkdir build - cd build - - cmake .. -G "Unix Makefiles" %PPIC_CMAKE_OPTIONS% -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=mingw32-make -DCMAKE_INSTALL_PREFIX='%cd%' + - cmake .. -G "Ninja" %PPIC_CMAKE_OPTIONS% -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX='%cd%' - cmake --build . --config Release - cmake --build . --config Release --target install/strip # fixme: I don't know how to NOT make the binary installed to the ./bin/ folder...