From 01f04e56969da8e01f4fb5125c0f4ffffcc03d85 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 22 Jan 2024 15:34:21 +0100 Subject: [PATCH] fix: set system definition in package file --- PackageConfig.cmake.in | 21 +++++++++++++++++++++ examples/CMakeLists.txt | 2 -- 2 files changed, 21 insertions(+), 2 deletions(-) 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 39f603d1c..05e76b29b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,7 +19,6 @@ function(add_example name) endfunction() if(UNIX) - add_definitions(-DZENOH_LINUX) if(CMAKE_C_STANDARD MATCHES "99") add_example(z_put unix/c99/z_put.c) add_example(z_pub unix/c99/z_pub.c) @@ -50,7 +49,6 @@ if(UNIX) add_example(z_sub_thr unix/c11/z_sub_thr.c) endif() elseif(MSVC) - add_definitions(-DZENOH_WINDOWS) add_example(z_put windows/z_put.c) add_example(z_pub windows/z_pub.c) add_example(z_pub_st windows/z_pub_st.c)