diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3792fda..9b46c7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,3 +89,33 @@ jobs: - name: Test run: ctest --test-dir build --output-on-failure + + build-with-parent-event-hub: + name: build-with-parent-event-hub-${{ matrix.platform }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - platform: linux + os: ubuntu-22.04 + - platform: windows + os: windows-latest + - platform: macos + os: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Configure parent-provided event hub fixture + run: > + cmake -S tests/cmake/parent_event_hub -B build-parent-event-hub -G Ninja + + - name: Build parent-provided event hub fixture + run: cmake --build build-parent-event-hub --parallel + + - name: Test parent-provided event hub fixture + run: ctest --test-dir build-parent-event-hub --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 222e099..1e740c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,14 +66,16 @@ if(CONSOLIX_USE_CXXOPTS) endif() if(CONSOLIX_USE_EVENT_HUB) - set(EVENT_HUB_CPP_BUILD_EXAMPLES OFF CACHE BOOL "Build event-hub-cpp examples" FORCE) - set(EVENT_HUB_CPP_BUILD_TESTS OFF CACHE BOOL "Build event-hub-cpp tests" FORCE) - set(EVENT_HUB_CPP_USE_TIME_SHIELD OFF CACHE BOOL "Enable optional time-shield-cpp integration" FORCE) - - add_subdirectory( - ${CMAKE_CURRENT_SOURCE_DIR}/external/event-hub-cpp - ${CMAKE_CURRENT_BINARY_DIR}/external/event-hub-cpp - ) + if(NOT TARGET event_hub::event_hub) + set(EVENT_HUB_CPP_BUILD_EXAMPLES OFF CACHE BOOL "Build event-hub-cpp examples" FORCE) + set(EVENT_HUB_CPP_BUILD_TESTS OFF CACHE BOOL "Build event-hub-cpp tests" FORCE) + set(EVENT_HUB_CPP_USE_TIME_SHIELD OFF CACHE BOOL "Enable optional time-shield-cpp integration" FORCE) + + add_subdirectory( + ${CMAKE_CURRENT_SOURCE_DIR}/external/event-hub-cpp + ${CMAKE_CURRENT_BINARY_DIR}/external/event-hub-cpp + ) + endif() target_link_libraries(Consolix INTERFACE event_hub::event_hub) endif() diff --git a/tests/cmake/parent_event_hub/CMakeLists.txt b/tests/cmake/parent_event_hub/CMakeLists.txt new file mode 100644 index 0000000..39f4fd1 --- /dev/null +++ b/tests/cmake/parent_event_hub/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.14) + +project(consolix_parent_event_hub LANGUAGES CXX) + +add_library(event_hub_cpp INTERFACE) +add_library(event_hub::event_hub ALIAS event_hub_cpp) + +set(CONSOLIX_CXX_STANDARD 17 CACHE STRING "" FORCE) +set(CONSOLIX_USE_LOGIT OFF CACHE BOOL "" FORCE) +set(CONSOLIX_USE_JSON OFF CACHE BOOL "" FORCE) +set(CONSOLIX_USE_CXXOPTS OFF CACHE BOOL "" FORCE) +set(CONSOLIX_USE_EVENT_HUB ON CACHE BOOL "" FORCE) +set(CONSOLIX_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) +set(CONSOLIX_BUILD_TESTS OFF CACHE BOOL "" FORCE) +add_subdirectory( + "${CMAKE_CURRENT_LIST_DIR}/../../.." + "${CMAKE_CURRENT_BINARY_DIR}/consolix" +) + +get_target_property(consolix_link_libraries Consolix INTERFACE_LINK_LIBRARIES) +if(NOT "event_hub::event_hub" IN_LIST consolix_link_libraries) + message(FATAL_ERROR "Consolix must link the parent-provided event hub target") +endif() + +add_custom_target(parent_event_hub_target_smoke ALL) + +enable_testing() +add_test( + NAME parent_event_hub_target_smoke + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target parent_event_hub_target_smoke +)