From 6a4c04c4b941693486a88a94d3c11bd31763608c Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Mon, 23 Dec 2024 14:14:23 +0000 Subject: [PATCH] fix linking to static installed KDDW fixes issue #557 (cherry picked from commit a1e2279b5411081d8babfcc64a7582521c83c928) --- .github/workflows/build.yml | 2 +- .github/workflows/examples.yml | 9 ++++++--- .github/workflows/flutter-dev.yml | 1 + CMakeLists.txt | 4 +--- src/CMakeLists.txt | 2 +- src/kdbindings.cmake | 14 +++++++++----- tests/CMakeLists.txt | 18 +++++++++++------- 7 files changed, 30 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 88f47bcda..6c34053ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ on: - examples/flutter/** - tests/reference-images/** - .github/workflows/create_release.yml - + - .github/workflows/examples.yml branches: - main - 2.2 diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 208a2988c..b04a7432b 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -26,6 +26,9 @@ jobs: - ubuntu-22.04 - windows-2022 - macos-13 + preset: + - release + - ci-release-static-qt5 steps: - name: Install Qt 5.15 with options and default aqtversion uses: jurplel/install-qt-action@v3 @@ -50,13 +53,13 @@ jobs: uses: turtlesec-no/get-ninja@main - name: Configure - run: cmake --preset=release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/installed/ -DKDDockWidgets_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug + run: cmake --preset=${{ matrix.preset }} -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/installed/ -DKDDockWidgets_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug - name: Build - run: cmake --build build-release --parallel + run: cmake --build build-${{ matrix.preset }} --parallel - name: Install - run: cmake --install build-release + run: cmake --install build-${{ matrix.preset }} - name: Build examples run: | diff --git a/.github/workflows/flutter-dev.yml b/.github/workflows/flutter-dev.yml index bfc9a5186..d0b556de2 100644 --- a/.github/workflows/flutter-dev.yml +++ b/.github/workflows/flutter-dev.yml @@ -13,6 +13,7 @@ on: - 2.2 paths-ignore: - .github/workflows/create_release.yml + - .github/workflows/examples.yml pull_request: branches: - main diff --git a/CMakeLists.txt b/CMakeLists.txt index 70b417cbc..a8aa4dee8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -482,9 +482,7 @@ endif() set(KKDockWidgets_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) find_package(KDBindings QUIET) -if(NOT TARGET KDAB::KDBindings) - include(src/kdbindings.cmake) -endif() +include(src/kdbindings.cmake) if(KDDockWidgets_TESTS) enable_testing() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf2503f48..a37e34350 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -408,7 +408,7 @@ if(KDDockWidgets_CODE_COVERAGE) target_link_libraries(kddockwidgets PUBLIC kddw_coverage_options) endif() -target_link_libraries(kddockwidgets PRIVATE KDAB::KDBindings) +kddw_link_to_kdbindings(kddockwidgets) if(KDDockWidgets_HAS_SPDLOG) target_link_libraries(kddockwidgets PRIVATE spdlog::spdlog) diff --git a/src/kdbindings.cmake b/src/kdbindings.cmake index f47220d4e..e8af8acc1 100644 --- a/src/kdbindings.cmake +++ b/src/kdbindings.cmake @@ -8,9 +8,13 @@ # Contact KDAB at for commercial licensing options. # -# Use a separate target for our kdbindings/signal.h header as it doesn't compile -# with -Wweak-vtables +set(KDDW_3DPARTY_DIR "${CMAKE_CURRENT_LIST_DIR}/3rdparty") -add_library(KDBindings INTERFACE IMPORTED) -add_library(KDAB::KDBindings ALIAS KDBindings) -target_include_directories(KDBindings SYSTEM INTERFACE $) +# links a target to KDBindings +function(kddw_link_to_kdbindings target) + if(TARGET KDAB::KDBindings) + target_link_libraries(${target} PRIVATE KDAB::KDBindings) + else() + target_include_directories(${target} SYSTEM PRIVATE ${KDDW_3DPARTY_DIR}) + endif() +endfunction() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 72955cf8c..b087dd9a2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,7 +36,7 @@ find_package(kdbindings QUIET) # Function to link to nlohmann function(kddw_add_nlohmann test) if(nlohmann_json_FOUND) - target_link_libraries(${test} nlohmann_json::nlohmann_json) + target_link_libraries(${test} PRIVATE nlohmann_json::nlohmann_json) else() target_include_directories(${test} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src/3rdparty/nlohmann) endif() @@ -57,9 +57,11 @@ if(KDDW_FRONTEND_QTWIDGETS) add_executable( tst_qtwidgets qtwidgets/tst_qtwidgets.cpp qtwidgets/mainwindow.ui ${TESTING_SRCS} ${TESTING_RESOURCES} ) - target_link_libraries(tst_qtwidgets KDAB::KDBindings kddockwidgets Qt${QT_VERSION_MAJOR}::Test) + target_link_libraries(tst_qtwidgets PRIVATE kddockwidgets Qt${QT_VERSION_MAJOR}::Test) + kddw_link_to_kdbindings(tst_qtwidgets) + if(KDDockWidgets_HAS_SPDLOG) - target_link_libraries(tst_qtwidgets spdlog::spdlog) + target_link_libraries(tst_qtwidgets PRIVATE spdlog::spdlog) endif() kddw_add_nlohmann(tst_qtwidgets) set_compiler_flags(tst_qtwidgets) @@ -71,9 +73,10 @@ endif() # tst_qtquick if(KDDW_FRONTEND_QTQUICK) add_executable(tst_qtquick qtquick/tst_qtquick.cpp ${TESTING_SRCS} ${TESTING_RESOURCES}) - target_link_libraries(tst_qtquick kddockwidgets KDAB::KDBindings Qt${QT_VERSION_MAJOR}::Test) + target_link_libraries(tst_qtquick PRIVATE kddockwidgets Qt${QT_VERSION_MAJOR}::Test) + kddw_link_to_kdbindings(tst_qtquick) if(KDDockWidgets_HAS_SPDLOG) - target_link_libraries(tst_qtquick spdlog::spdlog) + target_link_libraries(tst_qtquick PRIVATE spdlog::spdlog) endif() kddw_add_nlohmann(tst_qtquick) set_compiler_flags(tst_qtquick) @@ -87,10 +90,11 @@ if(KDDW_FRONTEND_QT) # Function to add a test function(add_kddw_test test srcs) add_executable(${test} ${srcs} ${TESTING_RESOURCES} ${TESTING_SRCS}) - target_link_libraries(${test} kddockwidgets KDAB::KDBindings) + target_link_libraries(${test} PRIVATE kddockwidgets) + kddw_link_to_kdbindings(${test}) target_include_directories(${test} PRIVATE ${CMAKE_BINARY_DIR}) if(KDDockWidgets_HAS_SPDLOG) - target_link_libraries(${test} spdlog::spdlog) + target_link_libraries(${test} PRIVATE spdlog::spdlog) endif() kddw_add_nlohmann(${test})