forked from eclipse-iceoryx/iceoryx2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse-iceoryx#264] Create infrastructure for C++ bindings
- Loading branch information
1 parent
a83c2ec
commit ec98785
Showing
27 changed files
with
658 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
cmake_minimum_required(VERSION 3.22) | ||
project(examples_cxx LANGUAGES CXX) | ||
|
||
add_subdirectory(publish_subscribe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Instructions | ||
|
||
## Build | ||
|
||
In the repository root folder, execute this steps. | ||
|
||
```bash | ||
cmake -S . -B target/ffi/build -DBUILD_EXAMPLES=ON | ||
cmake --build target/ffi/build | ||
``` | ||
|
||
## Run Examples | ||
|
||
### Publish-Subscribe | ||
|
||
Run in two separate terminals. Note, currently the examples run for 10 seconds. | ||
|
||
<!-- TODO --> | ||
```bash | ||
target/ffi/build/examples/cxx/publish_subscribe/example_cxx_publisher | ||
``` | ||
|
||
<!-- TODO --> | ||
```bash | ||
target/ffi/build/examples/cxx/publish_subscribe/example_cxx_subscriber | ||
``` | ||
|
||
### Discovery | ||
|
||
<!-- TODO --> | ||
```bash | ||
target/ffi/build/examples/cxx/discovery/example_cxx_discovery | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
cmake_minimum_required(VERSION 3.22) | ||
project(example_cxx_publish_subscribe LANGUAGES CXX) | ||
|
||
find_package(iceoryx2-cxx REQUIRED) | ||
|
||
add_executable(example_cxx_publisher src/publisher.cpp) | ||
target_link_libraries(example_cxx_publisher iceoryx2-cxx::static-lib-cxx) | ||
|
||
add_executable(example_cxx_subscriber src/subscriber.cpp) | ||
target_link_libraries(example_cxx_subscriber iceoryx2-cxx::static-lib-cxx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
#include "iox2/node.hpp" | ||
|
||
int main() { | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
#include "iox2/node.hpp" | ||
|
||
int main() { | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
## Build instructions | ||
|
||
```console | ||
cmake -B target/lang-c | ||
cmake --build target/lang-c | ||
``` | ||
|
||
# Helpful iceoryx dev crates | ||
In the repository root folder, execute this steps. | ||
|
||
- https://github.com/corrosion-rs/corrosion | ||
```bash | ||
cmake -S . -B target/ffi/build | ||
cmake --build target/ffi/build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
#include "iox2/iceoryx2.h" | ||
|
||
#include "test.hpp" | ||
|
||
namespace { | ||
|
||
TEST(Node, CreatingNodeWorks) { | ||
ASSERT_THAT(true, Eq(true)); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
cmake_minimum_required(VERSION 3.22) | ||
|
||
# TODO use this in fetch-iceoryx-hoofs.cmake | ||
set(ICEORYX_HOOFS_VERSION 2.90.0) | ||
include(cmake/fetch-iceoryx-hoofs.cmake) | ||
|
||
project(iceoryx2-cxx VERSION ${IOX2_VERSION_STRING} LANGUAGES CXX) | ||
|
||
set(PREFIX iceoryx2/v${CMAKE_PROJECT_VERSION}) | ||
|
||
find_package(iceoryx_hoofs REQUIRED) | ||
find_package(iceoryx2-c REQUIRED) | ||
|
||
# include only lib -> includes are installed only once despite being used in static lib as well as shared lib | ||
|
||
add_library(includes-only-cxx INTERFACE) | ||
add_library(iceoryx2-cxx::includes-only-cxx ALIAS includes-only-cxx) | ||
|
||
target_include_directories(includes-only-cxx | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include/${PREFIX}> | ||
) | ||
|
||
# object lib | ||
|
||
add_library(iceoryx2-cxx-object-lib OBJECT | ||
src/dummy.cpp | ||
) | ||
|
||
set_target_properties(iceoryx2-cxx-object-lib | ||
PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON | ||
POSITION_INDEPENDENT_CODE ON | ||
) | ||
|
||
target_link_libraries(iceoryx2-cxx-object-lib | ||
PUBLIC | ||
iceoryx_hoofs::iceoryx_hoofs | ||
iceoryx2-c::includes-only | ||
iceoryx2-cxx::includes-only-cxx | ||
) | ||
|
||
# static lib | ||
|
||
add_library(static-lib-cxx STATIC $<TARGET_OBJECTS:iceoryx2-cxx-object-lib>) | ||
add_library(iceoryx2-cxx::static-lib-cxx ALIAS static-lib-cxx) | ||
|
||
set_target_properties(static-lib-cxx | ||
PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON | ||
POSITION_INDEPENDENT_CODE ON | ||
OUTPUT_NAME "iceoryx2_cxx" | ||
) | ||
|
||
target_link_libraries(static-lib-cxx | ||
PUBLIC | ||
iceoryx_hoofs::iceoryx_hoofs | ||
iceoryx2-c::shared-lib | ||
iceoryx2-cxx::includes-only-cxx | ||
) | ||
|
||
# shared lib | ||
|
||
add_library(shared-lib-cxx SHARED $<TARGET_OBJECTS:iceoryx2-cxx-object-lib>) | ||
add_library(iceoryx2-cxx::shared-lib-cxx ALIAS shared-lib-cxx) | ||
|
||
set_target_properties(shared-lib-cxx | ||
PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON | ||
POSITION_INDEPENDENT_CODE ON | ||
OUTPUT_NAME "iceoryx2_cxx" | ||
) | ||
|
||
target_link_libraries(shared-lib-cxx | ||
PUBLIC | ||
iceoryx_hoofs::iceoryx_hoofs | ||
iceoryx2-c::shared-lib | ||
iceoryx2-cxx::includes-only-cxx | ||
) | ||
|
||
# include install setup | ||
|
||
include(cmake/install.cmake) | ||
|
||
# add tests | ||
|
||
if(${BUILD_TESTING}) | ||
add_subdirectory(tests) | ||
endif() | ||
|
Oops, something went wrong.