diff --git a/iceoryx_binding_c/CMakeLists.txt b/iceoryx_binding_c/CMakeLists.txt index f30808802f4..976f4dfc16c 100644 --- a/iceoryx_binding_c/CMakeLists.txt +++ b/iceoryx_binding_c/CMakeLists.txt @@ -18,14 +18,11 @@ cmake_minimum_required(VERSION 3.16) set(IOX_VERSION_STRING "2.90.0") - - project(iceoryx_binding_c VERSION ${IOX_VERSION_STRING}) find_package(iceoryx_hoofs REQUIRED) find_package(iceoryx_posh REQUIRED) - include(IceoryxPackageHelper) include(IceoryxPlatform) include(IceoryxPoshDeployment) @@ -70,64 +67,41 @@ set(${PROJECT_NAME}_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake # ########## build building-block library ########## # -add_library(${PROJECT_NAME} - source/c_client.cpp - source/c_config.cpp - source/c_notification_info.cpp - source/c_listener.cpp - source/c_node.cpp - source/c_publisher.cpp - source/c_request_header.cpp - source/c_response_header.cpp - source/c_runtime.cpp - source/c_server.cpp - source/c_subscriber.cpp - source/c_user_trigger.cpp - source/c_wait_set.cpp - source/c_chunk.cpp - source/c2cpp_enum_translation.cpp - source/c_log.cpp - source/cpp2c_enum_translation.cpp - source/cpp2c_publisher.cpp - source/cpp2c_subscriber.cpp - source/cpp2c_service_description_translation.cpp - source/c_service_discovery.cpp - source/error_handling.cpp -) -add_library(${PROJECT_NAMESPACE}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD_REQUIRED ON - CXX_STANDARD ${ICEORYX_CXX_STANDARD} - POSITION_INDEPENDENT_CODE ON +iox_add_library( + TARGET ${PROJECT_NAME} + NAMESPACE ${PROJECT_NAMESPACE} + BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_BINARY_DIR}/generated/iceoryx/include + INSTALL_INTERFACE include/${PREFIX} + PUBLIC_LIBS_LINUX stdc++ pthread + PUBLIC_LIBS_UNIX stdc++ pthread + PUBLIC_LIBS_APPLE stdc++ pthread + PRIVATE_LIBS iceoryx_posh::iceoryx_posh iceoryx_hoofs::iceoryx_hoofs + FILES + source/c_client.cpp + source/c_config.cpp + source/c_notification_info.cpp + source/c_listener.cpp + source/c_node.cpp + source/c_publisher.cpp + source/c_request_header.cpp + source/c_response_header.cpp + source/c_runtime.cpp + source/c_server.cpp + source/c_subscriber.cpp + source/c_user_trigger.cpp + source/c_wait_set.cpp + source/c_chunk.cpp + source/c2cpp_enum_translation.cpp + source/c_log.cpp + source/cpp2c_enum_translation.cpp + source/cpp2c_publisher.cpp + source/cpp2c_subscriber.cpp + source/cpp2c_service_description_translation.cpp + source/c_service_discovery.cpp + source/error_handling.cpp ) -target_include_directories(${PROJECT_NAME} - PUBLIC - $ - $ - $ -) - -if(NOT (WIN32 OR QNX)) - target_link_libraries(${PROJECT_NAME} - PUBLIC - stdc++ - pthread - PRIVATE - iceoryx_posh::iceoryx_posh - iceoryx_hoofs::iceoryx_hoofs - ) -else() - target_link_libraries(${PROJECT_NAME} - PRIVATE - iceoryx_posh::iceoryx_posh - iceoryx_hoofs::iceoryx_hoofs - ) -endif() - -target_compile_options(${PROJECT_NAME} PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) - # ########## build test executables ########## # @@ -145,5 +119,5 @@ setup_install_directories_and_export_package( install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE - DESTINATION share/doc/iceoryx_binding_c + DESTINATION share/doc/${PROJECT_NAME} COMPONENT dev) diff --git a/iceoryx_hoofs/CMakeLists.txt b/iceoryx_hoofs/CMakeLists.txt index 69a453efa22..00bbc0ccf81 100644 --- a/iceoryx_hoofs/CMakeLists.txt +++ b/iceoryx_hoofs/CMakeLists.txt @@ -78,12 +78,13 @@ add_subdirectory(platform) iox_add_library( TARGET iceoryx_hoofs - ALIAS iceoryx_hoofs::iceoryx_hoofs + NAMESPACE iceoryx_hoofs RPATH "${CMAKE_INSTALL_PREFIX}/lib123" - PUBLIC_LINKS iceoryx_hoofs::iceoryx_platform - PRIVATE_LINKS ${ICEORYX_SANITIZER_FLAGS} - PRIVATE_LINKS_LINUX acl atomic ${CODE_COVERAGE_LIBS} - INSTALL_INTERFACE ${PROJECT_SOURCE_DIR}/include + PUBLIC_LIBS iceoryx_hoofs::iceoryx_platform + PRIVATE_LIBS ${ICEORYX_SANITIZER_FLAGS} + PRIVATE_LIBS_LINUX acl atomic ${CODE_COVERAGE_LIBS} + BUILD_INTERFACE ${PROJECT_SOURCE_DIR}/include + INSTALL_INTERFACE include/${PREFIX} FILES source/concurrent/active_object.cpp source/concurrent/loffli.cpp @@ -170,5 +171,5 @@ install( install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE - DESTINATION share/doc/iceoryx_hoofs + DESTINATION share/doc/${PROJECT_NAME} COMPONENT dev) diff --git a/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake b/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake index 3eb63489a42..671bdf752d5 100644 --- a/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake +++ b/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake @@ -173,7 +173,7 @@ Macro(iox_add_executable) target_compile_options(${IOX_TARGET} PRIVATE ${IOX_WARNINGS} ${ICEORYX_SANITIZER}) - if (${IOX_STACK_SIZE}) + if ( IOX_STACK_SIZE ) if(WIN32) target_link_options(single_process BEFORE PRIVATE /STACK:${IOX_STACK_SIZE}) else() @@ -187,14 +187,20 @@ Macro(iox_add_executable) endMacro() Macro(iox_add_library) - set(arguments TARGET RPATH FILES PUBLIC_LINKS PRIVATE_LINKS ALIAS INSTALL_INTERFACE - PUBLIC_LINKS_LINUX PRIVATE_LINKS_LINUX PUBLIC_LINKS_QNX PRIVATE_LINKS_QNX - PUBLIC_LINKS_UNIX PRIVATE_LINKS_UNIX PUBLIC_LINKS_WIN32 PRIVATE_LINKS_WIN32 - PUBLIC_LINKS_APPLE PRIVATE_LINKS_APPLE) - cmake_parse_arguments(IOX "" "" "${arguments}" ${ARGN} ) + set(switches USE_C_LANGUAGE) + set(arguments TARGET NAMESPACE) + set(multiArguments RPATH FILES PUBLIC_LIBS PRIVATE_LIBS BUILD_INTERFACE + INSTALL_INTERFACE + PUBLIC_LIBS_LINUX PRIVATE_LIBS_LINUX PUBLIC_LIBS_QNX PRIVATE_LIBS_QNX + PUBLIC_LIBS_UNIX PRIVATE_LIBS_UNIX PUBLIC_LIBS_WIN32 PRIVATE_LIBS_WIN32 + PUBLIC_LIBS_APPLE PRIVATE_LIBS_APPLE) + cmake_parse_arguments(IOX "${switches}" "${arguments}" "${multiArguments}" ${ARGN} ) add_library( ${IOX_TARGET} ${IOX_FILES} ) - add_library( ${IOX_ALIAS} ALIAS ${IOX_TARGET}) + + if ( IOX_NAMESPACE ) + add_library( ${IOX_NAMESPACE}::${IOX_TARGET} ALIAS ${IOX_TARGET}) + endif() set_target_properties(${IOX_TARGET} PROPERTIES CXX_STANDARD_REQUIRED ON @@ -204,18 +210,18 @@ Macro(iox_add_library) ) target_compile_options(${IOX_TARGET} PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) - target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LINKS} PRIVATE ${IOX_PRIVATE_LINKS}) + target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS} PRIVATE ${IOX_PRIVATE_LIBS}) if ( LINUX ) - target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LINKS_LINUX} PRIVATE ${IOX_PRIVATE_LINKS_LINUX}) + target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS_LINUX} PRIVATE ${IOX_PRIVATE_LIBS_LINUX}) elseif ( QNX ) - target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LINKS_QNX} PRIVATE ${IOX_PRIVATE_LINKS_QNX}) + target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS_QNX} PRIVATE ${IOX_PRIVATE_LIBS_QNX}) elseif ( UNIX ) - target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LINKS_UNIX} PRIVATE ${IOX_PRIVATE_LINKS_UNIX}) + target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS_UNIX} PRIVATE ${IOX_PRIVATE_LIBS_UNIX}) elseif ( WIN32 ) - target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LINKS_WIN32} PRIVATE ${IOX_PRIVATE_LINKS_WIN32}) + target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS_WIN32} PRIVATE ${IOX_PRIVATE_LIBS_WIN32}) elseif ( APPLE ) - target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LINKS_APPLE} PRIVATE ${IOX_PRIVATE_LINKS_APPLE}) + target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS_APPLE} PRIVATE ${IOX_PRIVATE_LIBS_APPLE}) endif ( LINUX ) iox_set_rpath( TARGET ${IOX_TARGET} RPATH ${IOX_RPATH} ) @@ -230,7 +236,9 @@ Macro(iox_add_library) target_include_directories(${IOX_TARGET} PUBLIC - $ - $ + $ + $ ) + + endMacro() diff --git a/iceoryx_hoofs/platform/CMakeLists.txt b/iceoryx_hoofs/platform/CMakeLists.txt index efa30ae9e56..371d5a6bcfd 100644 --- a/iceoryx_hoofs/platform/CMakeLists.txt +++ b/iceoryx_hoofs/platform/CMakeLists.txt @@ -41,7 +41,7 @@ file ( GLOB_RECURSE ICEORYX_PLATFORM_FILES iox_add_library( TARGET iceoryx_platform - ALIAS iceoryx_hoofs::iceoryx_platform + NAMESPACE iceoryx_hoofs INSTALL_INTERFACE ${ICEORYX_PLATFORM}/include PRIVATE_LINKS ${ICEORYX_SANITIZER_FLAGS} PUBLIC_LINKS_LINUX rt pthread