Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1287 Add introspection to new iox_add_executable …
Browse files Browse the repository at this point in the history
…wrappers

Signed-off-by: Christian Eltzschig <me@elchris.org>
  • Loading branch information
elfenpiff committed May 11, 2022
1 parent ce24063 commit 401d3bb
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 132 deletions.
4 changes: 2 additions & 2 deletions iceoryx_examples/icediscovery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ iox_add_executable(
TARGET iox-cpp-wait-for-service
FILES ./iox_wait_for_service.cpp ./src/discovery_blocking.cpp
LIBS iceoryx_posh::iceoryx_posh
INCLUDE_DIRECTORY include
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include
)

iox_add_executable(
TARGET iox-cpp-discovery-monitor
FILES ./iox_discovery_monitor.cpp ./src/discovery_monitor.cpp
LIBS iceoryx_posh::iceoryx_posh
INCLUDE_DIRECTORY include
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include
)
23 changes: 17 additions & 6 deletions iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,23 @@ endMacro()
Macro(iox_add_executable)
set(switches USE_C_LANGUAGE)
set(arguments TARGET STACK_SIZE)
set(multiArguments FILES LIBS INCLUDE_DIRECTORY LIBS_QNX)
set(multiArguments FILES LIBS INCLUDE_DIRECTORIES LIBS_QNX LIBS_LINUX LIBS_UNIX LIBS_WIN32 LIBS_APPLE)
cmake_parse_arguments(IOX "${switches}" "${arguments}" "${multiArguments}" ${ARGN} )

add_executable(${IOX_TARGET} ${IOX_FILES})
target_include_directories(${IOX_TARGET} PRIVATE ${IOX_INCLUDE_DIRECTORY})
target_link_libraries(${IOX_TARGET} PRIVATE ${IOX_LIBS})
target_include_directories(${IOX_TARGET} PRIVATE ${IOX_INCLUDE_DIRECTORIES})
target_link_libraries(${IOX_TARGET} ${IOX_LIBS})

if ( QNX )
target_link_libraries(${IOX_TARGET} PRIVATE ${IOX_LIBS_QNX})
target_link_libraries(${IOX_TARGET} ${IOX_LIBS_QNX})
elseif ( LINUX )
target_link_libraries(${IOX_TARGET} ${IOX_LIBS_LINUX})
elseif ( APPLE )
target_link_libraries(${IOX_TARGET} ${IOX_LIBS_APPLE})
elseif ( WIN32 )
target_link_libraries(${IOX_TARGET} ${IOX_LIBS_WIN32})
elseif ( UNIX )
target_link_libraries(${IOX_TARGET} ${IOX_LIBS_UNIX})
endif()

set(IOX_WARNINGS ${ICEORYX_WARNINGS})
Expand All @@ -202,7 +210,7 @@ Macro(iox_add_executable)
endif()
endif()

target_compile_options(${IOX_TARGET} PRIVATE ${IOX_WARNINGS} ${ICEORYX_SANITIZER})
target_compile_options(${IOX_TARGET} ${IOX_WARNINGS} ${ICEORYX_SANITIZER})

if ( IOX_STACK_SIZE )
if(WIN32)
Expand All @@ -220,8 +228,9 @@ endMacro()
Macro(iox_add_library)
set(switches USE_C_LANGUAGE NO_EXPORT NO_PACKAGE_SETUP NO_FIND_PACKAGE_SUPPORT)
set(arguments TARGET NAMESPACE PROJECT_PREFIX)
set(multiArguments RPATH FILES PUBLIC_LIBS PRIVATE_LIBS BUILD_INTERFACE
set(multiArguments FILES PUBLIC_LIBS PRIVATE_LIBS BUILD_INTERFACE
INSTALL_INTERFACE ADDITIONAL_EXPORT_TARGETS
PUBLIC_INCLUDES PRIVATE_INCLUDES
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)
Expand Down Expand Up @@ -262,8 +271,10 @@ Macro(iox_add_library)
endif()
endif()

set_target_properties(${IOX_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
target_compile_options(${IOX_TARGET} PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})
target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS} PRIVATE ${IOX_PRIVATE_LIBS})
target_include_directories(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_INCLUDES} PRIVATE ${IOX_PRIVATE_INCLUDES})

if ( LINUX )
target_link_libraries(${IOX_TARGET} PUBLIC ${IOX_PUBLIC_LIBS_LINUX} PRIVATE ${IOX_PRIVATE_LIBS_LINUX})
Expand Down
55 changes: 36 additions & 19 deletions iceoryx_hoofs/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,37 @@ set(TEST_LINK_LIBS
iceoryx_hoofs_testing::iceoryx_hoofs_testing
)

iox_add_executable( TARGET ${PROJECT_PREFIX}_moduletests
INCLUDE_DIRECTORIES .
LIBS ${TEST_LINK_LIBS}
LIBS_LINUX acl dl pthread rt
FILES ${MODULETESTS_SRC}
)

iox_add_executable( TARGET ${PROJECT_PREFIX}_mocktests
INCLUDE_DIRECTORIES .
LIBS ${TEST_LINK_LIBS}
LIBS_LINUX acl dl pthread rt
FILES ${MOCKTESTS_SRC}
)

iox_add_executable( TARGET ${PROJECT_PREFIX}_integrationtests
INCLUDE_DIRECTORIES .
LIBS ${TEST_LINK_LIBS}
LIBS_LINUX acl dl pthread rt
FILES ${INTEGRATIONTESTS_SRC}
)

iox_add_executable( TARGET test_stress_sofi
INCLUDE_DIRECTORIES .
LIBS ${TEST_LINK_LIBS}
LIBS_LINUX acl dl pthread rt
FILES stresstests/test_stress_sofi.cpp
)

add_subdirectory(stresstests/benchmark_optional_and_expected)

## TODO: iox-#1287 remove those compiler warning exceptions
if(LINUX)
set(TEST_LINK_LIBS ${TEST_LINK_LIBS} acl dl pthread rt)
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion) # -Wpedantic results in errors at the time mocks
Expand All @@ -49,24 +80,10 @@ elseif(WIN32)
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} /bigobj)
endif()

iox_add_executable( TARGET ${PROJECT_PREFIX}_moduletests
FILES ${MODULETESTS_SRC}
FLAGS ${TEST_CXX_FLAGS}
LIBS ${TEST_LINK_LIBS})
target_compile_options(${PROJECT_PREFIX}_moduletests PRIVATE ${TEST_CXX_FLAGS})
target_compile_options(${PROJECT_PREFIX}_mocktests PRIVATE ${TEST_CXX_FLAGS})
target_compile_options(${PROJECT_PREFIX}_integrationtests PRIVATE ${TEST_CXX_FLAGS})
target_compile_options(test_stress_sofi PRIVATE ${TEST_CXX_FLAGS})
## TODO: END iox-#1287 remove those compiler warning exceptions

iox_add_executable( TARGET ${PROJECT_PREFIX}_mocktests
FILES ${MOCKTESTS_SRC}
FLAGS ${TEST_CXX_FLAGS}
LIBS ${TEST_LINK_LIBS})

iox_add_executable( TARGET ${PROJECT_PREFIX}_integrationtests
FILES ${INTEGRATIONTESTS_SRC}
FLAGS ${TEST_CXX_FLAGS}
LIBS ${TEST_LINK_LIBS})

iox_add_executable( TARGET test_stress_sofi
FILES stresstests/test_stress_sofi.cpp
FLAGS ${TEST_CXX_FLAGS}
LIBS ${TEST_LINK_LIBS})

add_subdirectory(stresstests/benchmark_optional_and_expected)
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,8 @@ if ( NOT ICEORYX_CXX_STANDARD )
include(IceoryxPlatform)
endif ( NOT ICEORYX_CXX_STANDARD )

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(TEST_CXX_FLAGS ${ICEORYX_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})
endif()

iox_add_executable(
TARGET iox-bm-optional-and-expected
TARGET iox-bm-optional-and-expected
FILES ./benchmark_optional_and_expected.cpp
LIBS iceoryx_hoofs::iceoryx_hoofs Threads::Threads
FLAGS ${TEST_CXX_FLAGS}
)
117 changes: 22 additions & 95 deletions tools/introspection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,7 @@ find_package(iceoryx_posh REQUIRED)
include(IceoryxPackageHelper)
include(IceoryxPlatform)

option(MAKE_UNIQUE_INCLUDEDIR
"When ON headers are installed to a path ending with folders called \
iceoryx/vX.Y.Z/ . This avoids include directory search order issues when \
overriding this package from a merged catkin, ament, or colcon workspace."
ON)

if(MAKE_UNIQUE_INCLUDEDIR)
set(_unique_dir "iceoryx/v${IOX_VERSION_STRING}")
if(PREFIX STREQUAL "")
set(PREFIX "${_unique_dir}")
else()
set(PREFIX "${PREFIX}/${_unique_dir}")
endif()
endif()
iox_make_unique_includedir()

# cmake doesn't find ncurses under QNX; let the compiler complain if the header is missing
if(NOT QNX)
Expand All @@ -51,85 +38,25 @@ if(NOT QNX)
endif(${CURSES_HAVE_NCURSES_H} MATCHES ".*-NOTFOUND")
endif()

#
########## set variables for library export ##########
#
setup_package_name_and_create_files(
NAME ${PROJECT_NAME}
NAMESPACE iceoryx_introspection
PROJECT_PREFIX ${PREFIX}
)

#
########## find_package in source tree ##########
#
set(${PROJECT_NAME}_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake
CACHE FILEPATH
"${PROJECT_NAME}Config.cmake to make find_package(${PROJECT_NAME}) work in source tree!"
FORCE
)

add_library(iceoryx_introspection
source/iceoryx_introspection_app.cpp
source/introspection_app.cpp
)

add_library(${PROJECT_NAMESPACE}::iceoryx_introspection ALIAS iceoryx_introspection)

set_target_properties(iceoryx_introspection PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD ${ICEORYX_CXX_STANDARD}
POSITION_INDEPENDENT_CODE ON
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)

target_include_directories(iceoryx_introspection
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PREFIX}>
PRIVATE
${CURSES_INCLUDE_DIR}
)

target_link_libraries(iceoryx_introspection
iceoryx_hoofs::iceoryx_hoofs
iceoryx_posh::iceoryx_posh
ncurses
)

target_compile_options(iceoryx_introspection PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

if(LINUX)
set(LIB_TINFO tinfo)
elseif(WIN32)
message(WARNING "Introspection not supported for windows." )
else()
set(LIB_TINFO "")
endif()

target_link_libraries(iceoryx_introspection ${LIB_TINFO})

add_executable(iox-introspection-client source/introspection_main.cpp)

set_target_properties(iox-introspection-client PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD ${ICEORYX_CXX_STANDARD}
POSITION_INDEPENDENT_CODE ON
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
iox_add_library(
TARGET iceoryx_introspection
NAMESPACE iceoryx_introspection
PROJECT_PREFIX ${PREFIX}
PUBLIC_LIBS iceoryx_hoofs::iceoryx_hoofs
iceoryx_posh::iceoryx_posh
ncurses
PUBLIC_LIBS_LINUX tinfo
BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include
INSTALL_INTERFACE include/${PREFIX}
PRIVATE_INCLUDES ${CURSES_INCLUDE_DIR}
FILES
source/iceoryx_introspection_app.cpp
source/introspection_app.cpp
)

iox_add_executable(
TARGET iox-introspection-client
LIBS iceoryx_introspection::iceoryx_introspection
FILES
source/introspection_main.cpp
)

target_link_libraries(iox-introspection-client
PRIVATE
${PROJECT_NAMESPACE}::iceoryx_introspection
)

target_compile_options(iox-introspection-client PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

#
########## exporting library ##########
#
setup_install_directories_and_export_package(
TARGETS iceoryx_introspection iox-introspection-client
INCLUDE_DIRECTORY include/
)

0 comments on commit 401d3bb

Please sign in to comment.