Skip to content

Commit

Permalink
Merge pull request #29 from eclipse-ecal/integrate-core-pb
Browse files Browse the repository at this point in the history
removed all ecal internal proto files duplicates
  • Loading branch information
rex-schilasky authored Feb 19, 2024
2 parents 4a23183 + 8f082a3 commit a79fc2f
Show file tree
Hide file tree
Showing 35 changed files with 98 additions and 1,160 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ endif()
# --------------------------------------------------------
add_subdirectory(ecal/core)

if(ECAL_CORE_BUILD_SAMPLES_PROTOBUF)
add_subdirectory(ecal/core_pb)
endif()

# --------------------------------------------------------
# core config
# --------------------------------------------------------
Expand Down
78 changes: 78 additions & 0 deletions ecal/core_pb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2019 Continental Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ========================= eCAL LICENSE =================================

project(core_pb)

find_package(Protobuf REQUIRED)

set(ProtoFiles
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/ecal.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/host.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/layer.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/logging.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/monitoring.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/process.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/service.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/topic.proto
)

# Compile statically on Windows and shared for all other systems.
#
# We compile shared on Linux etc., as we must only load the proto descriptors
# once; otherwise, protobuf would throw an exception on runtime. A shared object
# achieves that, as it is only loaded into memory once, even when being linked
# against from different libraries.
# We don't have to do that on Windows, as we compile against protobuf statically
# and therefore each .dll has it's own descriptor pool. Having a static lib here
# also has the advantage that we need to export the symbols, which is default
# disabled on Windows.
#
# TODO: Having code like that probably isn't the best solution ever. We should
# maybe always link against protobuf statically. Currently the reason why we
# don't do that is, that the default Ubuntu libprotobuf.a doesn't contain
# position independent code and can therefore not be statically compiled into a
# shared object library.
if (WIN32)
ecal_add_static_library(${PROJECT_NAME} src/core_pb.cpp)
else()
ecal_add_shared_library(${PROJECT_NAME} src/core_pb.cpp)
endif()

add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

protobuf_target_cpp(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src INSTALL_FOLDER include ${ProtoFiles})

target_compile_options(${PROJECT_NAME}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/wd4505 /wd4592 /wd4189>
$<$<CXX_COMPILER_ID:GNU>:-Wno-unused-parameter>)

set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)

target_link_libraries(${PROJECT_NAME} protobuf::libprotobuf)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

ecal_install_library(${PROJECT_NAME})

if(BUILD_PY_BINDING)
protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles})
target_sources(${PROJECT_NAME} PRIVATE ${python_sources})
set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
endif()

set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER core)
1 change: 1 addition & 0 deletions ecal/core_pb/src/core_pb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// dummy file to force VS to create a library
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

syntax = "proto3";

import "host.proto";
import "process.proto";
import "service.proto";
import "topic.proto";
import "ecal/core/pb/host.proto";
import "ecal/core/pb/process.proto";
import "ecal/core/pb/service.proto";
import "ecal/core/pb/topic.proto";

package eCAL.pb;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

syntax = "proto3";

import "host.proto";
import "process.proto";
import "service.proto";
import "topic.proto";
import "ecal/core/pb/host.proto";
import "ecal/core/pb/process.proto";
import "ecal/core/pb/service.proto";
import "ecal/core/pb/topic.proto";

package eCAL.pb;

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

syntax = "proto3";

import "layer.proto";
import "ecal/core/pb/layer.proto";

package eCAL.pb;

Expand Down
36 changes: 0 additions & 36 deletions ecal/protobuf/monitoring.proto

This file was deleted.

61 changes: 0 additions & 61 deletions ecal/protobuf/topic.proto

This file was deleted.

10 changes: 1 addition & 9 deletions samples/cpp/monitoring/monitoring_performance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,11 @@ set(monitoring_performance_src
src/monitoring_performance.cpp
)

set(monitoring_rec_proto
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/host.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/layer.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/monitoring.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/process.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/service.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/topic.proto
)
ecal_add_sample(${PROJECT_NAME} ${monitoring_performance_src})
PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${monitoring_rec_proto})

target_link_libraries(${PROJECT_NAME}
eCAL::core
eCAL::core_pb
protobuf::libprotobuf
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <monitoring.pb.h>
#include <ecal/core/pb/monitoring.pb.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a79fc2f

Please sign in to comment.