diff --git a/lang/csharp/CMakeLists.txt b/lang/csharp/CMakeLists.txt index dd77ddb81b..8586a75ad9 100644 --- a/lang/csharp/CMakeLists.txt +++ b/lang/csharp/CMakeLists.txt @@ -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) @@ -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() diff --git a/lang/csharp/Continental.eCAL.Core.Samples/CMakeLists.txt b/lang/csharp/Continental.eCAL.Core.Samples/CMakeLists.txt index cd5f8bd016..0f7d461548 100644 --- a/lang/csharp/Continental.eCAL.Core.Samples/CMakeLists.txt +++ b/lang/csharp/Continental.eCAL.Core.Samples/CMakeLists.txt @@ -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. @@ -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) @@ -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) - - - - - - diff --git a/lang/csharp/Continental.eCAL.Protobuf.Person/CMakeLists.txt b/lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/CMakeLists.txt similarity index 93% rename from lang/csharp/Continental.eCAL.Protobuf.Person/CMakeLists.txt rename to lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/CMakeLists.txt index 6d077fb7b3..f3417b21d5 100644 --- a/lang/csharp/Continental.eCAL.Protobuf.Person/CMakeLists.txt +++ b/lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/CMakeLists.txt @@ -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 @@ -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}" ) diff --git a/lang/csharp/Continental.eCAL.Protobuf.Person/animal.proto b/lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/animal.proto similarity index 100% rename from lang/csharp/Continental.eCAL.Protobuf.Person/animal.proto rename to lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/animal.proto diff --git a/lang/csharp/Continental.eCAL.Protobuf.Person/house.proto b/lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/house.proto similarity index 100% rename from lang/csharp/Continental.eCAL.Protobuf.Person/house.proto rename to lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/house.proto diff --git a/lang/csharp/Continental.eCAL.Protobuf.Person/person.proto b/lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/person.proto similarity index 100% rename from lang/csharp/Continental.eCAL.Protobuf.Person/person.proto rename to lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/person.proto diff --git a/lang/csharp/Continental.eCAL.Protobuf.Person/protobuf_csharp_helper.cmake b/lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/protobuf_csharp_helper.cmake similarity index 100% rename from lang/csharp/Continental.eCAL.Protobuf.Person/protobuf_csharp_helper.cmake rename to lang/csharp/Continental.eCAL.Protobuf.Samples.Datatypes/protobuf_csharp_helper.cmake diff --git a/lang/csharp/Continental.eCAL.Protobuf.Samples/CMakeLists.txt b/lang/csharp/Continental.eCAL.Protobuf.Samples/CMakeLists.txt index 446a5b134c..2f5ea16b2c 100644 --- a/lang/csharp/Continental.eCAL.Protobuf.Samples/CMakeLists.txt +++ b/lang/csharp/Continental.eCAL.Protobuf.Samples/CMakeLists.txt @@ -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. @@ -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 diff --git a/lang/csharp/Continental.eCAL.Protobuf.Test/CMakeLists.txt b/lang/csharp/Continental.eCAL.Protobuf.Test/CMakeLists.txt index f30be22ed0..7c6f89d4d1 100644 --- a/lang/csharp/Continental.eCAL.Protobuf.Test/CMakeLists.txt +++ b/lang/csharp/Continental.eCAL.Protobuf.Test/CMakeLists.txt @@ -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}