Skip to content

Commit b58cbd1

Browse files
committed
Bring back the "external dependencies" build
For now we only test with external dependencies on macOS. mio and whereami are not available in brew so we'll still fetch them with CMake. Doctest needed to be added to brew deps.
1 parent ab90859 commit b58cbd1

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

.github/workflows/build-external.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ jobs:
3737
# We remove the pinned CMake if it's installed so commands below can succeed
3838
# TODO: remove when not needed anymore
3939
brew tap KDAB/tap
40-
brew install fmt spdlog KDBindings mosquitto
40+
brew install doctest fmt spdlog KDBindings mosquitto
4141
4242
- name: Configure project
4343
run: >
4444
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -G Ninja
4545
-DKDUTILS_BUILD_TESTS=ON
46+
-DKDUTILS_USE_EXTERNAL_DEPENDENCIES=ON
4647
-DBUILD_SHARED_LIBS=${{ matrix.shared }}
4748
4849
- name: Check if external dependencies were used

CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010

1111
cmake_minimum_required(VERSION 3.16)
1212

13+
option(KDUTILS_USE_EXTERNAL_DEPENDENCIES
14+
"Assume all project dependencies are available on the system. Don't fetch through vcpkg." OFF
15+
)
16+
1317
# vcpkg manifest mode
14-
include(cmake/KDUtilsFunctions.cmake)
15-
kdutils_check_submodule_exists(vcpkg vcpkg)
16-
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
17-
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
18+
if(NOT KDUTILS_USE_EXTERNAL_DEPENDENCIES)
19+
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
20+
include(cmake/KDUtilsFunctions.cmake)
21+
kdutils_check_submodule_exists(vcpkg vcpkg)
22+
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
23+
endif()
1824
endif()
1925

2026
option(KDUTILS_BUILD_EXAMPLES "Build examples" ON)

cmake/dependencies.cmake

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,37 @@
88
# Contact KDAB at <info@kdab.com> for commercial licensing options.
99
#
1010

11+
include(FetchContent)
12+
1113
message(STATUS "Looking for KDUtils dependencies")
1214

1315
find_package(spdlog REQUIRED)
1416
find_package(KDBindings REQUIRED)
15-
find_package(whereami REQUIRED)
16-
find_package(mio REQUIRED)
17+
18+
# Following two packages are still acquired via fetchcontent because they aren't
19+
# available in brew on macOS so the non-vcpkg build would be hard to set up there
20+
21+
# whereami library
22+
find_package(whereami QUIET)
23+
if(NOT TARGET whereami::whereami)
24+
fetchcontent_declare(
25+
whereami
26+
GIT_REPOSITORY https://github.com/gpakosz/whereami
27+
GIT_TAG e4b7ba1be0e9fd60728acbdd418bc7195cdd37e7 # master at 5/July/2021
28+
)
29+
fetchcontent_makeavailable(whereami)
30+
endif()
31+
32+
# mio header-only lib (provides memory mapping for files)
33+
find_package(mio QUIET)
34+
if(NOT TARGET mio::mio)
35+
fetchcontent_declare(
36+
mio
37+
GIT_REPOSITORY https://github.com/mandreyel/mio.git
38+
GIT_TAG 8b6b7d878c89e81614d05edca7936de41ccdd2da # March 3rd 2023
39+
)
40+
fetchcontent_makeavailable(mio)
41+
endif()
1742

1843
if(KDUTILS_BUILD_MQTT_SUPPORT)
1944
find_package(mosquitto REQUIRED)

src/KDUtils/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ add_library(
4747
target_link_libraries(
4848
KDUtils
4949
PUBLIC spdlog::spdlog
50-
PRIVATE mio::mio whereami::whereami
50+
PRIVATE mio::mio
5151
)
5252

5353
if(ANDROID)
@@ -59,6 +59,13 @@ target_include_directories(
5959
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<INSTALL_INTERFACE:include/>
6060
)
6161

62+
if(NOT TARGET whereami::whereami)
63+
target_include_directories(KDUtils PRIVATE ${whereami_SOURCE_DIR}/src)
64+
target_sources(KDUtils PRIVATE ${whereami_SOURCE_DIR}/src/whereami.c)
65+
else()
66+
target_link_libraries(KDUtils PRIVATE whereami::whereami)
67+
endif()
68+
6269
set_target_properties(
6370
KDUtils
6471
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"

0 commit comments

Comments
 (0)