From 730f36c8cbaca0ca2233ee4e154a141c57a860c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Fri, 7 Jun 2024 22:46:49 -0400 Subject: [PATCH 1/5] Fix library potentially being stored in non-framework path 1. Perform the install step after the Framework target property is set 2. Add Framework indicator to the install call --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05a19c5..fb99196 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,9 +9,6 @@ add_library(KDMacTouchBar SHARED kdmactouchbar.mm ${HEADERS}) -install(TARGETS KDMacTouchBar - LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") - target_link_libraries(KDMacTouchBar ${QT_LIBRARIES} "-framework Cocoa") set_target_properties(KDMacTouchBar PROPERTIES @@ -22,3 +19,6 @@ set_target_properties(KDMacTouchBar PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" MACOSX_RPATH TRUE ) + +install(TARGETS KDMacTouchBar + LIBRARY FRAMEWORK DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") From daa43c1d911bb1e36c9f962039de1c49f3263549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Mon, 10 Jun 2024 09:44:42 -0400 Subject: [PATCH 2/5] Increase CMake minimum version This addresses CMake versions < 3 deprecation warning --- .github/workflows/build.yml | 13 +++++++------ CMakeLists.txt | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 556f250..f693bc3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company # # SPDX-License-Identifier: MIT @@ -13,14 +13,17 @@ jobs: fail-fast: true matrix: os: - - macos-12 - - macos-11 + - macos-latest build_type: - Debug - Release qt: - version: "5.15.2" requested: "5.15" + architectures: "x86_64" + - version: "6.4.*" + requested: "6.4" + architectures: "x86_64;arm64" steps: - name: Install Qt with options and default aqtversion @@ -34,9 +37,6 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Create build directory - run: mkdir build - - name: Install ninja-build tool (must be after Qt due PATH changes) uses: turtlesec-no/get-ninja@main @@ -44,6 +44,7 @@ jobs: run: > cmake -S . -B ./build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_OSX_ARCHITECTURES="${{ matrix.qt.architectures }}" - name: Build Project run: cmake --build ./build diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c9d9a7..6015a02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.12) if("${CMAKE_INSTALL_PREFIX}" STREQUAL "") set(USE_DEFAULT_INSTALL_LOCATION True) @@ -17,13 +17,7 @@ set(${PROJECT_NAME}_VERSION_MINOR 0) set(${PROJECT_NAME}_VERSION_PATCH 0) set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}) -if(CMAKE_VERSION VERSION_LESS "3.1") - if(CMAKE_COMPILER_IS_GNUCXX) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif () -else() - set(CMAKE_CXX_STANDARD 11) -endif() +set(CMAKE_CXX_STANDARD 11) if(USE_DEFAULT_INSTALL_LOCATION) set(CMAKE_INSTALL_PREFIX "/usr/local/KDAB/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}" CACHE STRING "" FORCE) @@ -31,12 +25,20 @@ endif() message(STATUS "Building ${PROJECT_NAME} ${${PROJECT_NAME}_VERSION} in ${CMAKE_BUILD_TYPE} mode. Installing to ${CMAKE_INSTALL_PREFIX}") -find_package(Qt5Core REQUIRED) -find_package(Qt5Widgets REQUIRED) +find_package(QT NAMES Qt6 Qt5) +if("${QT_VERSION_MAJOR}" STREQUAL "5") + set(QT_REQUIRED_VERSION "5.15.2") +else() + set(QT_REQUIRED_VERSION "6.4.0") +endif() + +find_package(Qt${QT_VERSION_MAJOR} ${QT_REQUIRED_VERSION} + COMPONENTS Core Widgets + REQUIRED) set(CMAKE_AUTOMOC TRUE) -set(QT_LIBRARIES Qt5::Widgets) -set(QT_USE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Qt5Portability.cmake") +set(QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Widgets) +set(QT_USE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Qt${QT_VERSION_MAJOR}Portability.cmake") install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/KDMacTouchBarConfig.cmake" From d0d3b1adf8d331a0adb3b124224e08c772e89148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Fri, 7 Jun 2024 22:55:49 -0400 Subject: [PATCH 3/5] Add CMakeLists.txt.user and build directories to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 474c123..21f4211 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ lib .qmake.cache .qmake.stash .DS_Store +CMakeLists.txt.user +**/build/** From d303484bf64275d1e84c5dd872bb888bfc569e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Sun, 9 Jun 2024 20:59:20 -0400 Subject: [PATCH 4/5] Fix issues preventing library from building with Qt 6 1. CMake instructions now handle both Qt 6 and Qt 5 2. Pass correct QString-like type to setWindowTitle 3. Remove qAsConst optimization to address deprecation warning --- cmake/Qt6Portability.cmake | 32 +++++++++++++++++++++++++++++ examples/mactouchbar/mainwindow.cpp | 4 ++-- src/kdmactouchbar.mm | 4 ++-- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 cmake/Qt6Portability.cmake diff --git a/cmake/Qt6Portability.cmake b/cmake/Qt6Portability.cmake new file mode 100644 index 0000000..9bd0f48 --- /dev/null +++ b/cmake/Qt6Portability.cmake @@ -0,0 +1,32 @@ + +include_directories(${QtWidgets_INCLUDE_DIRS}) + +if(QT_USE_QTNETWORK) + find_package(QtNetwork REQUIRED) + list(APPEND QT_LIBRARIES Qt::Network) + include_directories(${QtNetwork_INCLUDE_DIRS}) +endif() + +if(QT_USE_QTXML) + find_package(QtXml REQUIRED) + list(APPEND QT_LIBRARIES Qt::Xml) + include_directories(${QtXml_INCLUDE_DIRS}) +endif() + +if(QT_USE_QTTEST) + find_package(QtTest REQUIRED) + list(APPEND QT_LIBRARIES Qt::Test) + include_directories(${QtTest_INCLUDE_DIRS}) +endif() + +macro(qt4_wrap_ui) + qt_wrap_ui(${ARGN}) +endmacro() + +macro(qt4_wrap_cpp) + qt_wrap_cpp(${ARGN}) +endmacro() + +macro(qt4_add_resources) + qt_add_resources(${ARGN}) +endmacro() diff --git a/examples/mactouchbar/mainwindow.cpp b/examples/mactouchbar/mainwindow.cpp index de1c79e..1cbf48e 100644 --- a/examples/mactouchbar/mainwindow.cpp +++ b/examples/mactouchbar/mainwindow.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. +** Copyright (C) 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. ** All rights reserved. ** ** This file is part of the KD MacTouchBar library. @@ -34,7 +34,7 @@ MainWindow::MainWindow() { - setWindowTitle("KDMacTouchBar Example"); + setWindowTitle(tr("KDMacTouchBar Example")); resize(400, 200); // attach a touchbar to this window diff --git a/src/kdmactouchbar.mm b/src/kdmactouchbar.mm index 1f98528..ebfd86e 100644 --- a/src/kdmactouchbar.mm +++ b/src/kdmactouchbar.mm @@ -1,5 +1,5 @@ /**************************************************************************** -** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. +** Copyright (C) 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. ** All rights reserved. ** ** This file is part of the KD MacTouchBar library. @@ -49,7 +49,7 @@ auto nsImage = [[[NSImage alloc] initWithSize:NSZeroSize] autorelease]; - for (const auto& size : qAsConst(sizes)) { + for (const auto& size : sizes) { const QImage qimage = icon.pixmap(size).toImage(); CGImageRef cgImage = qimage.toCGImage(); if (!cgImage) From 70e2a2e1f2abca16ea300e30cf3ce08b9d55e2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Sun, 9 Jun 2024 22:21:49 -0400 Subject: [PATCH 5/5] Bump version number since these changes finish adding Qt 6 support --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6015a02..e48dcdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ if(NOT CMAKE_BUILD_TYPE) endif() set(${PROJECT_NAME}_VERSION_MAJOR 1) -set(${PROJECT_NAME}_VERSION_MINOR 0) +set(${PROJECT_NAME}_VERSION_MINOR 1) set(${PROJECT_NAME}_VERSION_PATCH 0) set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})