From 16928eb24b35d358debe6bfc2d658ce4fdb607a0 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Wed, 25 Jan 2023 11:13:05 +0100 Subject: [PATCH] Require Windows static build only if SHM enabled This addresses CMake Error at src/CMakeLists.txt:50 (message): CycloneDDS with enabled shared memory support can only be built as a static library on Windows on Windows when ENABLE_SHM=AUTO is in effect. Signed-off-by: Erik Boasson --- src/CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce4b67a4cf..a37bb97e4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,11 +45,6 @@ set(ENABLE_SHM "AUTO" CACHE STRING "Enable shared memory support") set_property(CACHE ENABLE_SHM PROPERTY STRINGS ON OFF AUTO) if(ENABLE_SHM) - if(WIN32) - if (BUILD_SHARED_LIBS OR NOT DEFINED BUILD_SHARED_LIBS) - message(FATAL_ERROR "CycloneDDS with enabled shared memory support can only be built as a static library on Windows") - endif() - endif() if(NOT ENABLE_SHM STREQUAL "AUTO") set(iceoryx_required REQUIRED) else() @@ -57,9 +52,16 @@ if(ENABLE_SHM) endif() find_package(iceoryx_binding_c ${iceoryx_required}) set(ENABLE_SHM ${iceoryx_binding_c_FOUND} CACHE STRING "" FORCE) - if(ENABLE_SHM AND APPLE) +endif() +# now ENABLE_SHM is no longer AUTO +if(ENABLE_SHM) + if(APPLE) get_filename_component(iceoryx_libdir "${ICEORYX_LIB}" DIRECTORY) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${iceoryx_libdir}") + elseif(WIN32) + if (BUILD_SHARED_LIBS OR NOT DEFINED BUILD_SHARED_LIBS) + message(FATAL_ERROR "CycloneDDS with enabled shared memory support can only be built as a static library on Windows") + endif() endif() endif()