Skip to content

Commit

Permalink
Adding support for full build (#20)
Browse files Browse the repository at this point in the history
various fixes and improvements to the build system
  • Loading branch information
MelamudMichael committed Mar 13, 2024
1 parent 4ad9759 commit a4dada1
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 89 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
run: |
git clone https://github.com/eclipse-uprotocol/up-cpp.git
cd up-cpp
git clone -b uprotocol-core-api-1.5.6 https://github.com/eclipse-uprotocol/up-core-api.git
git submodule update --init --recursive
conan create . --build=missing
Expand All @@ -50,9 +49,10 @@ jobs:
- name: Build && install up-client-zenoh-cpp
shell: bash
run: |
conan install conaninfo/ --output-folder=.
cd build/Release
cmake ../../ -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local
mkdir build
cd build
conan install ../ -o build_unbundled=True -o zenoh_package=False
cmake ../ -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local
cmake --build . --target install --config Release -- -j
Expand All @@ -69,4 +69,4 @@ jobs:
if: always()
steps:
- name: Check whether all jobs pass
run: echo '${{ toJson(needs) }}' | jq -e 'all(.result == "success")'
run: echo '${{ toJson(needs) }}' | jq -e 'all(.result == "success")'
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 General Motors GTO LLC
# Copyright (c) 2024 General Motors GTO LLC
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
Expand Down Expand Up @@ -36,6 +36,7 @@ endif()

add_subdirectory(lib)

if(BUILD_SAMPLES)
add_subdirectory(samples)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ This module contains the implementation for pub-sub and RPC API`s defined in the
$ git clone https://github.com/eclipse-uprotocol/up-client-zenoh-cpp.git
```
## How to Use the Library
To add up-cpp to your conan build dependencies, simply add the following to your conanfile.txt:
To add up-client-zenoh-cpp to your conan build dependencies, simply add the following to your conanfile.txt:
```
[requires]
up-cpp/0.1
up-cpp-client-zenoh/0.1
protobuf/3.21.12
Expand All @@ -43,10 +42,11 @@ cmake_layout
### Building locally
```
$ cd up-cpp-client-zenoh
$ conan install conaninfo/ --output-folder=.
$ cd build/Release
$ cmake ../../ -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
$ make -j
$ mkdir build
$ cd build
$ conan install ../
$ cmake ../ -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
$ cmake --build . --config Release -- -j
```

#### Creating conan package locally
Expand Down
29 changes: 15 additions & 14 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,40 @@ class UpClientZenoh(ConanFile):
options = {"shared": [True, False], "fPIC": [True, False]}
conan_version = None
generators = "CMakeDeps"
version = "0.1"
exports_sources = "CMakeLists.txt", "lib/*"
version = "0.1.2-dev"
exports_sources = "CMakeLists.txt", "lib/*", "test/*"

options = {
"shared": [True, False],
"fPIC": [True, False],
"build_testing": [True, False],
"build_unbundled": [True, False],
"zenoh_package": [True, False],
"build_cross_compiling": [True, False],
}

default_options = {
"shared": False,
"fPIC": False,
"build_testing": False,
"build_unbundled": False,
"build_unbundled": True,
"zenoh_package": False,
"build_cross_compiling": False,
}

# def configure(self):
# self.options["up-cpp"].shared = True

def requirements(self):
if self.options.build_unbundled:
self.requires("up-cpp/0.1.5.0-dev")
self.requires("zenohc/cci.20240213")
self.requires("protobuf/3.21.12" + ("@cross/cross" if self.options.build_cross_compiling else ""))
else:
self.requires("up-cpp/0.1")
self.requires("spdlog/1.13.0")
self.requires("protobuf/3.21.12")
self.requires("protobuf/3.21.12" + ("@cross/cross" if self.options.build_cross_compiling else ""))
self.requires("spdlog/1.13.0")
if self.options.build_testing:
self.requires("gtest/1.14.0")
if self.options.build_unbundled: #each componenet is built independently
self.requires("up-cpp/0.1.1-dev")
if self.options.zenoh_package:
self.requires("zenohc/cci.20240213")

def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_TESTING"] = self.options.build_testing
tc.generate()

def build(self):
Expand All @@ -63,3 +63,4 @@ def package(self):

def package_info(self):
self.cpp_info.libs = ["up-client-zenoh-cpp"]

11 changes: 0 additions & 11 deletions conaninfo/conanfile.txt

This file was deleted.

43 changes: 21 additions & 22 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 General Motors GTO LLC
# Copyright (c) 2024 General Motors GTO LLC
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
Expand All @@ -19,14 +19,15 @@
cmake_minimum_required(VERSION 3.20)
project(up-client-zenoh-cpp VERSION 0.1.0 LANGUAGES CXX)

find_package(Protobuf REQUIRED)
find_package(spdlog REQUIRED)

if(BUILD_UNBUNDLED)
find_package(up-cpp REQUIRED)
find_package(zenohc REQUIRED)
else()
find_library(ZENOH_LIB zenohc)
find_package(up-cpp REQUIRED)
find_package(Protobuf REQUIRED)
find_package(spdlog REQUIRED)
find_package(up-cpp QUIET)
endif()

# Support pulling headers outside of /usr/local
Expand All @@ -39,32 +40,30 @@ set(SRC_FILES
src/zenohRpcClient.cpp
src/zenohSessionManager.cpp
src/messageBuilder.cpp
src/messageParser.cpp
)
src/messageParser.cpp)

add_library(${PROJECT_NAME} ${SRC_FILES})
add_library(up-client-zenoh-cpp::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$ENV{CMAKE_ZENOH_INCLUDE_PATH}
${HOME}/include
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src)

if(BUILD_UNBUNDLED)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
PUBLIC
up-cpp::up-cpp
zenohc::lib
)
zenohc::lib)
else()
target_include_directories(${PROJECT_NAME}
PRIVATE
${up-cpp_INCLUDE_DIR}
include
)
target_link_libraries(${PROJECT_NAME} PRIVATE up-cpp::up-cpp ${ZENOH_LIB})
target_link_libraries(${PROJECT_NAME}
PUBLIC
up-cpp::up-cpp
${ZENOH_LIB})
endif()

INSTALL(TARGETS ${PROJECT_NAME})
Expand Down
4 changes: 2 additions & 2 deletions lib/include/up-client-zenoh-cpp/message/messageBuilder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/include/up-client-zenoh-cpp/message/messageCommon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/include/up-client-zenoh-cpp/message/messageParser.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/include/up-client-zenoh-cpp/rpc/zenohRpcClient.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/include/up-client-zenoh-cpp/session/zenohSessionManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/include/up-client-zenoh-cpp/transport/zenohUTransport.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/src/messageBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/src/messageParser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
* Copyright (c) 2024 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-FileCopyrightText: 2024 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
Loading

0 comments on commit a4dada1

Please sign in to comment.