From d7269a9c16a1f3372e26926e739eff9adebb862c Mon Sep 17 00:00:00 2001 From: Jean-Roland Gosse Date: Fri, 26 Jan 2024 10:40:38 +0100 Subject: [PATCH] Fix build examples using find_package (#324) * fix: build examples using find_package * fix: set system definition in package file --- PackageConfig.cmake.in | 21 +++++++++++++++++++++ examples/CMakeLists.txt | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/PackageConfig.cmake.in b/PackageConfig.cmake.in index 7ac56c378..800ceff6c 100644 --- a/PackageConfig.cmake.in +++ b/PackageConfig.cmake.in @@ -26,3 +26,24 @@ if(NOT ("@IMPLIB@" STREQUAL "")) set_property(TARGET __zenohpico_lib PROPERTY IMPORTED_IMPLIB "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@IMPLIB@") endif() target_include_directories(__zenohpico_lib INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + add_compile_definitions(ZENOH_LINUX) +elseif(POSIX_COMPATIBLE) + add_compile_definitions(ZENOH_LINUX) +elseif(CMAKE_SYSTEM_NAME MATCHES "BSD") + add_compile_definitions(ZENOH_BSD) +elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") + add_compile_definitions(ZENOH_MACOS) +elseif(CMAKE_SYSTEM_NAME MATCHES "Emscripten") + add_compile_definitions(EMSCRIPTEN) +elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") + add_compile_definitions(ZENOH_WINDOWS) +elseif(CMAKE_SYSTEM_NAME MATCHES "Generic") + if(WITH_ZEPHYR) + add_compile_definitions(ZENOH_ZEPHYR) + elseif(WITH_FREERTOS_PLUS_TCP) + add_compile_definitions(ZENOH_FREERTOS_PLUS_TCP) + endif() +endif() + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index fb780510d..05e76b29b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,7 +4,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) project(zenohpico_examples LANGUAGES C) include(../cmake/helpers.cmake) set_default_build_type(Release) - configure_include_project(ZENOHPICO zenohpico zenohpico ".." zenohc "https://github.com/eclipse-zenoh/zenoh-pico" "") + configure_include_project(ZENOHPICO zenohpico zenohpico::static ".." zenohpico "https://github.com/eclipse-zenoh/zenoh-pico" "") add_custom_target(examples ALL) else() message(STATUS "zenoh-pico examples")