From bef16ef3b8919577bd83b6e05d3d4a44a1e1a876 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Tue, 29 Oct 2024 13:17:40 +0100 Subject: [PATCH] use only find_package when building examples as a root project --- .github/workflows/ci.yml | 10 +--------- README.md | 22 ++-------------------- examples/CMakeLists.txt | 3 +-- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 336498474..98ade7358 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,19 +88,11 @@ jobs: cd build cmake --build . --target examples - - name: Build examples with zenoh-c as subbroject and static library and in debug mode and in separate directory - shell: bash - run: | - mkdir -p ../build_examples - cmake -S examples -B ../build_examples -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF - cmake --build ../build_examples --config Debug - rm -rf ../build_examples - - name: Build examples with zenoh-c as installed package shell: bash run: | mkdir -p build_examples && cd build_examples - cmake ../examples -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_SOURCE=PACKAGE + cmake ../examples -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local cmake --build . --config Release cd .. && rm -rf build_examples diff --git a/README.md b/README.md index 8994b999b..98ae67f99 100644 --- a/README.md +++ b/README.md @@ -130,36 +130,18 @@ cmake ../zenoh-c/examples cmake --build . ``` -In this case, the examples executables will be built in the current directory. - -As a root project the `examples` project links `zenoh-c` with CMake's [add_subdirectory] command by default. There are also other ways to link `zenoh-c` - with [find_package] or [FetchContent]: - -[add_subdirectory]: https://cmake.org/cmake/help/latest/command/add_subdirectory.html -[find_package]: https://cmake.org/cmake/help/latest/command/find_package.html -[FetchContent]: https://cmake.org/cmake/help/latest/module/FetchContent.html - Link with `zenoh-c` installed into default location in the system (with [find_package]): ```bash -cmake ../zenoh-c/examples -DZENOHC_SOURCE=PACKAGE +cmake ../zenoh-c/examples ``` Link with `zenoh-c` installed in `~/.local` directory: ```bash -cmake ../zenoh-c/examples -DZENOHC_SOURCE=PACKAGE -DCMAKE_INSTALL_PREFIX=~/.local -``` - -Download specific `zenoh-c` version from git with [FetchContent]: - -```bash -cmake ../zenoh-c/examples -DZENOHC_SOURCE=GIT_URL -DZENOHC_GIT_TAG=0.11.0-rc +cmake ../zenoh-c/examples -DCMAKE_INSTALL_PREFIX=~/.local ``` -See also `configure_include_project` function in [helpers.cmake] for more information - -[helpers.cmake]: cmake/helpers.cmake - ## Running the Examples ### Basic Pub/Sub Example diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3674203fc..db8f3a714 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,8 +4,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) project(zenohc_examples LANGUAGES C) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake" ${CMAKE_MODULE_PATH}) include(helpers) - set_default_build_type(Release) - configure_include_project(ZENOHC zenohc zenohc::lib ".." zenohc "https://github.com/eclipse-zenoh/zenoh-c" "") + find_package(zenohc REQUIRED) add_custom_target(examples ALL) else() message(STATUS "zenoh-c examples")