Skip to content

Commit

Permalink
- Change Continental.eCAL.Protobuf.Person -> Continental.eCAL.Protobu…
Browse files Browse the repository at this point in the history
…f.Person.Samples.Datatypes

- Calculate C# protobuf version from available protoc.
  • Loading branch information
KerstinKeller committed May 28, 2024
1 parent 13dc444 commit 9785758
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 17 deletions.
36 changes: 33 additions & 3 deletions lang/csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2024 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 =================================

# C# build, can be executed standalone against an eCAL installation
project(ecal_csharp)

set(CMAKE_DOTNET_SDK "")
set(ECAL_CSHARP_PROTOBUF_VERSION "3.26.1" CACHE STRING "Protobuf Version for C# build")
# Macro to determine the matching protobuf C# version compatible with protoc found.
# We should do this differently, but then we need to install protoc via nuget or similar...
# Because the Prototbuf Version used for C# bindings is independent from the one we get from the submodules / conan
macro(get_csharp_protobuf_version)
find_package(Protobuf REQUIRED)
if (${Protobuf_VERSION_MAJOR} GREATER 3)
set(ECAL_CSHARP_PROTOBUF_VERSION "3.${Protobuf_VERSION_MAJOR}.${Protobuf_VERSION_MINOR}")
else ()
set(ECAL_CSHARP_PROTOBUF_VERSION "${Protobuf_VERSION}")
endif ()
endmacro()

option(ECAL_CSHARP_BUILD_SAMPLES "BUILD eCAL C# samples" ON)
option(ECAL_CSHARP_BUILD_TESTS "BUILD eCAL C# unittests" ON)

get_csharp_protobuf_version()
message(STATUS "Using ECAL_CSHARP_PROTOBUF_VERSION: ${ECAL_CSHARP_PROTOBUF_VERSION}")

add_subdirectory(Continental.eCAL.Core)
add_subdirectory(Continental.eCAL.Protobuf)
if (ECAL_CSHARP_BUILD_TESTS)
Expand All @@ -21,5 +51,5 @@ endif ()

if (ECAL_CSHARP_BUILD_SAMPLES OR ECAL_CSHARP_BUILD_TESTS)
#Contains the person.proto which are being compiled to cs files
add_subdirectory(Continental.eCAL.Protobuf.Person)
add_subdirectory(Continental.eCAL.Protobuf.Samples.Datatypes)
endif()
9 changes: 1 addition & 8 deletions lang/csharp/Continental.eCAL.Core.Samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2019 Continental Corporation
# Copyright (C) 2016 - 2024 Continental Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,6 @@ project(Continental.eCAL.Core.Samples LANGUAGES CSharp)

find_package(eCAL REQUIRED)


macro(ecal_add_csharp_core_sample sample_name)
ecal_add_sample(${sample_name} ${sample_name}.cs)
target_link_libraries(${sample_name} Continental.eCAL.Core)
Expand All @@ -34,9 +33,3 @@ ecal_add_csharp_core_sample(pubsub_minimal_snd)

ecal_add_csharp_core_sample(service_minimal_client)
ecal_add_csharp_core_sample(service_minimal_server)






Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ include(CSharpUtilities)
find_package(Protobuf REQUIRED)
include(protobuf_csharp_helper.cmake)

project(Continental.eCAL.Protobuf.Person LANGUAGES CSharp)
project(Continental.eCAL.Protobuf.Samples.Datatypes LANGUAGES CSharp)

add_library(Continental.eCAL.Protobuf.Person SHARED)
add_library(${PROJECT_NAME} SHARED)

PROTOBUF_TARGET_CSHARP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/animal.proto
Expand All @@ -39,7 +39,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
VS_DOTNET_REFERENCES "System"
)


set_property(TARGET ${PROJECT_NAME} PROPERTY
VS_PACKAGE_REFERENCES "Google.Protobuf_${ECAL_CSHARP_PROTOBUF_VERSION}"
)
Expand Down
4 changes: 2 additions & 2 deletions lang/csharp/Continental.eCAL.Protobuf.Samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2019 Continental Corporation
# Copyright (C) 2016 - 2024 Continental Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@ find_package(eCAL REQUIRED)

macro(ecal_add_csharp_protobuf_sample sample_name)
ecal_add_sample(${sample_name} ${sample_name}.cs)
target_link_libraries(${sample_name} Continental.eCAL.Protobuf Continental.eCAL.Protobuf.Person)
target_link_libraries(${sample_name} Continental.eCAL.Protobuf Continental.eCAL.Protobuf.Samples.Datatypes)
set_property(TARGET ${sample_name} PROPERTY FOLDER samples/csharp/protobuf)

set_target_properties(${sample_name} PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion lang/csharp/Continental.eCAL.Protobuf.Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_sources(${PROJECT_NAME}
test.cs
)

target_link_libraries(${PROJECT_NAME} Continental.eCAL.Protobuf Continental.eCAL.Protobuf.Person)
target_link_libraries(${PROJECT_NAME} Continental.eCAL.Protobuf Continental.eCAL.Protobuf.Samples.Datatypes)

set_target_properties(${PROJECT_NAME} PROPERTIES
VS_GLOBAL_ROOTNAMESPACE ${PROJECT_NAME}
Expand Down

0 comments on commit 9785758

Please sign in to comment.