Skip to content

Commit

Permalink
fix linking to static installed KDDW
Browse files Browse the repository at this point in the history
fixes issue #557
  • Loading branch information
iamsergio committed Dec 24, 2024
1 parent f2b7be2 commit cd924b5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- examples/flutter/**
- tests/reference-images/**
- .github/workflows/create_release.yml

- .github/workflows/examples.yml
branches:
- main
pull_request:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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
Expand All @@ -48,13 +51,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: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/flutter-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- main
paths-ignore:
- .github/workflows/create_release.yml
- .github/workflows/examples.yml
pull_request:
branches:
- main
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions src/kdbindings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
# Contact KDAB at <info@kdab.com> 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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/3rdparty>)
# 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()
18 changes: 11 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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})
Expand Down

0 comments on commit cd924b5

Please sign in to comment.