Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1287 Adjust iox_add_executable to handle even mor…
Browse files Browse the repository at this point in the history
…e tasks

Signed-off-by: Christian Eltzschig <me@elchris.org>
  • Loading branch information
elfenpiff committed May 11, 2022
1 parent 4a8a903 commit 1488a7f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 82 deletions.
94 changes: 34 additions & 60 deletions iceoryx_binding_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated/iceoryx/include>
$<INSTALL_INTERFACE:include/${PREFIX}>
)

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 ##########
#
Expand All @@ -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)
13 changes: 7 additions & 6 deletions iceoryx_hoofs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -170,5 +171,5 @@ install(

install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE
DESTINATION share/doc/iceoryx_hoofs
DESTINATION share/doc/${PROJECT_NAME}
COMPONENT dev)
38 changes: 23 additions & 15 deletions iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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} )
Expand All @@ -230,7 +236,9 @@ Macro(iox_add_library)

target_include_directories(${IOX_TARGET}
PUBLIC
$<BUILD_INTERFACE:${IOX_INSTALL_INTERFACE}>
$<INSTALL_INTERFACE:include/${PREFIX}>
$<BUILD_INTERFACE:${IOX_BUILD_INTERFACE}>
$<INSTALL_INTERFACE:${IOX_INSTALL_INTERFACE}>
)


endMacro()
2 changes: 1 addition & 1 deletion iceoryx_hoofs/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1488a7f

Please sign in to comment.