Skip to content

Commit

Permalink
Merge pull request #1357 from ApexAI/iox-#1287-setting-rpath-for-all-…
Browse files Browse the repository at this point in the history
…iceoryx-targets

iox-#1287 setting rpath for all iceoryx targets
  • Loading branch information
elfenpiff authored May 31, 2022
2 parents 6a31326 + 9bf4446 commit 0852dd2
Show file tree
Hide file tree
Showing 43 changed files with 1,358 additions and 1,824 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
fail: true
args: --verbose --no-progress './**/*.md'

cmake-lint-check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- run: ./tools/ci/cmake-linter.sh

build-test-ubuntu:
runs-on: ubuntu-20.04
needs: pre-flight-check
Expand Down
62 changes: 17 additions & 45 deletions doc/aspice_swe3_4/example/iceoryx_component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,18 @@ include(IceoryxPlatform)
#
########## lib ##########
#
add_library(iceoryx_component
source/example_module/example_base_class.cpp
iox_add_library(
TARGET iceoryx_component
NAMESPACE iceoryx_component
PRIVATE_INCLUDES source/example_module
BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/generated/iceoryx/include
INSTALL_INTERFACE include/${PREFIX}
PRIVATE_LIBS ${CMAKE_THREAD_LIBS_INIT}
FILES
source/example_module/example_base_class.cpp
)

add_library(iceoryx_component::iceoryx_component ALIAS iceoryx_component)

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

target_include_directories(iceoryx_component
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated/iceoryx/include>
$<INSTALL_INTERFACE:include/${PREFIX}>
PRIVATE
source/example_module
)
target_link_libraries(iceoryx_component
PRIVATE
${ICEORYX_SANITIZER_FLAGS}
${CMAKE_THREAD_LIBS_INIT}
)

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


#
########## test ##########
#
Expand All @@ -66,27 +48,17 @@ set(PROJECT_PREFIX "iceoryx_component")

file(GLOB_RECURSE MODULETESTS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/test/moduletests/*.cpp")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_PREFIX}/test)

set(TEST_LINK_LIBS
GTest::gtest
GTest::gmock
iceoryx_component::iceoryx_component
)

if(LINUX)
set(TEST_LINK_LIBS ${TEST_LINK_LIBS} dl )
endif()

# unittests
add_executable(${PROJECT_PREFIX}_moduletests ${MODULETESTS_SRC})
target_include_directories(${PROJECT_PREFIX}_moduletests PRIVATE . source/example_module)
# TODO: fix conversion warnings
target_compile_options(${PROJECT_PREFIX}_moduletests PRIVATE ${TEST_CXX_FLAGS})
target_link_libraries(${PROJECT_PREFIX}_moduletests ${TEST_LINK_LIBS})
set_target_properties(${PROJECT_PREFIX}_moduletests PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD ${ICEORYX_CXX_STANDARD}
POSITION_INDEPENDENT_CODE ON
iox_add_executable(
TARGET ${PROJECT_PREFIX}_moduletests
INCLUDE_DIRECTORIES .
source/example_module
FILES ${MODULETESTS_SRC}
LIBS ${TEST_LINK_LIBS}
LIBS_LINUX dl
)

12 changes: 12 additions & 0 deletions doc/website/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Either `VS Code` or `Developer Command Prompt` can be used to build iceoryx with

Alternatively, `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat` can be executed in any shell to setup all the paths for compilation.

!!! attention
A Windows SDK Version of at least `10.0.18362.0` is required.

## Build with CMake

!!! note
Expand Down Expand Up @@ -122,6 +125,15 @@ The `CMakeLists.txt` from `iceoryx_meta` can be used to easily develop iceoryx w
cmake --build build
```

If the compilation fails, it is possible that the compilation failure originates
inside the Windows SDK and is not caused by iceoryx, see
[Windows vcpkg-issue \#15035](https://github.com/microsoft/vcpkg/issues/15035#issuecomment-742427969.)
In this case try to rebuild the cmake files with:
```bash
cmake -Bbuild -Hiceoryx_meta -DCMAKE_SYSTEM_VERSION=10.0.18362.0
```
and restart the build command `cmake --build build`.

!!! tip
You can speed up the build by appending `-j 4` where 4 stands for the number of parallel build processes.
You can choose more or less depending on your available CPU cores on your machine.
Expand Down
1 change: 1 addition & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- FreeBSD CI build is broken [\#1338](https://github.com/eclipse-iceoryx/iceoryx/issues/1338)
- High CPU load in blocked publisher is reduced by introducing smart busy loop waiting (adaptive_wait) [\#1347](https://github.com/eclipse-iceoryx/iceoryx/issues/1347)
- Compile Error : iceoryx_dds/Mempool.hpp: No such file or directory [\#1364](https://github.com/eclipse-iceoryx/iceoryx/issues/1364)
- RPATH is correctly set up for all libraries and binaries. [\#1287](https://github.com/eclipse-iceoryx/iceoryx/issues/1287)

**Refactoring:**

Expand Down
139 changes: 35 additions & 104 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 All @@ -34,116 +31,50 @@ if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin)
option(BUILD_SHARED_LIBS "Create shared libraries by default" ON)
endif()

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()

#
########## set variables for export ##########
#
setup_package_name_and_create_files(
NAME ${PROJECT_NAME}
NAMESPACE iceoryx_binding_c
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
)
iox_make_unique_includedir()

#
########## 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
iox_add_library(
TARGET ${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}
PROJECT_PREFIX ${PREFIX}
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
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
)
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
)

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 ##########
#
if(BUILD_TEST)
add_subdirectory(test)
endif()

#
########## export library ##########
#
setup_install_directories_and_export_package(
TARGETS ${PROJECT_NAME}
INCLUDE_DIRECTORY include/
)

install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE
DESTINATION share/doc/iceoryx_binding_c
COMPONENT dev)
29 changes: 14 additions & 15 deletions iceoryx_binding_c/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
# Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
# Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,25 +39,24 @@ set(TEST_LINK_LIBS
iceoryx_posh_testing::iceoryx_posh_testing
)

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} -Wno-unused -Wno-pedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-unused -Wno-pedantic)
endif()
iox_add_executable( TARGET ${PROJECT_PREFIX}_moduletests
INCLUDE_DIRECTORIES .
FILES ${MODULETESTS_SRC}
LIBS ${TEST_LINK_LIBS}
LIBS_APPLE dl
LIBS_LINUX acl dl pthread rt
)

## TODO: iox-#1287 remove those compiler warning exceptions
if(LINUX)
set(TEST_LINK_LIBS ${TEST_LINK_LIBS} dl)
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion) # -Wpedantic results in errors at the time mocks
elseif(QNX)
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion)
elseif(APPLE)
set(TEST_LINK_LIBS ${TEST_LINK_LIBS} dl)
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion)
elseif(WIN32)
set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} /bigobj)
endif()

# unittests
add_executable(${PROJECT_PREFIX}_moduletests ${MODULETESTS_SRC})
set_property(TARGET ${PROJECT_PREFIX}_moduletests PROPERTY CXX_STANDARD ${ICEORYX_CXX_STANDARD})
target_include_directories(${PROJECT_PREFIX}_moduletests PRIVATE .)
target_compile_options(${PROJECT_PREFIX}_moduletests PRIVATE ${TEST_CXX_FLAGS})
target_link_libraries(${PROJECT_PREFIX}_moduletests ${TEST_LINK_LIBS})
## TODO: END iox-#1287 remove those compiler warning exceptions
2 changes: 1 addition & 1 deletion iceoryx_binding_c/test/moduletests/test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ constexpr const char iox_client_test::EVENT[];
TEST_F(iox_client_test, notInitializedOptionsAreUninitialized)
{
::testing::Test::RecordProperty("TEST_ID", "347f3a6d-8659-4ac3-81be-720e8a444d5e");
iox_client_options_t uninitializedOptions;
#if !defined(__clang__)
iox_client_options_t uninitializedOptions;
// ignore the warning since we would like to test the behavior of an uninitialized option
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
Expand Down
3 changes: 1 addition & 2 deletions iceoryx_binding_c/test/moduletests/test_runtime.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -84,7 +84,6 @@ TEST_F(BindingC_Runtime_test, GetInstanceNameIsNullptr)
constexpr char EXPECTED_RUNTIME_NAME[iox::MAX_RUNTIME_NAME_LENGTH + 1] = "chucky";
iox_runtime_init(EXPECTED_RUNTIME_NAME);

char actualRuntimeName[iox::MAX_RUNTIME_NAME_LENGTH + 1];
auto nameLength = iox_runtime_get_instance_name(nullptr, iox::MAX_RUNTIME_NAME_LENGTH + 1);

ASSERT_THAT(nameLength, Eq(0U));
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_binding_c/test/moduletests/test_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ constexpr const char iox_server_test::EVENT[];
TEST_F(iox_server_test, notInitializedOptionsAreUninitialized)
{
::testing::Test::RecordProperty("TEST_ID", "e227f280-3725-44e4-ba08-c9d2a43d5a1b");
iox_server_options_t uninitializedOptions;
#if !defined(__clang__)
iox_server_options_t uninitializedOptions;
// ignore the warning since we would like to test the behavior of an uninitialized option
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
Expand Down
Loading

0 comments on commit 0852dd2

Please sign in to comment.