You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2021/07/27 17:53:23 UTC

[celix] 01/02: Refactors setting the C++ standard, because osx has issues building with the prev setup.

This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/pubsub-interceptor-fix
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 7ec75a7f31cedd5285a8b8c2d4c3cc9584b28231
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Tue Jul 27 19:50:09 2021 +0200

    Refactors setting the C++ standard, because osx has issues building with the prev setup.
---
 CMakeLists.txt                                                        | 3 ++-
 bundles/cxx_remote_services/admin/CMakeLists.txt                      | 1 -
 bundles/cxx_remote_services/admin/gtest/CMakeLists.txt                | 1 -
 bundles/cxx_remote_services/discovery_configured/CMakeLists.txt       | 1 -
 bundles/cxx_remote_services/discovery_configured/gtest/CMakeLists.txt | 2 --
 bundles/cxx_remote_services/integration/CMakeLists.txt                | 4 ----
 bundles/cxx_remote_services/integration/gtest/CMakeLists.txt          | 1 -
 bundles/cxx_remote_services/rsa_spi/CMakeLists.txt                    | 2 --
 bundles/cxx_remote_services/topology_manager/CMakeLists.txt           | 3 +--
 bundles/pubsub/pubsub_serializer_avrobin/gtest/CMakeLists.txt         | 1 -
 bundles/pubsub/pubsub_serializer_json/gtest/CMakeLists.txt            | 1 -
 bundles/pubsub/pubsub_spi/gtest/CMakeLists.txt                        | 1 -
 bundles/pubsub/pubsub_utils/gtest/CMakeLists.txt                      | 1 -
 bundles/shell/shell/CMakeLists.txt                                    | 1 +
 examples/CMakeLists.txt                                               | 2 +-
 libs/framework/CMakeLists.txt                                         | 2 ++
 libs/promises/CMakeLists.txt                                          | 2 --
 libs/promises/gtest/CMakeLists.txt                                    | 1 -
 18 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5bb18cc..88ec2f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,7 +48,8 @@ set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
 set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}")
 
 # Set C++ specific flags
-set(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_STANDARD 17) #test code and newer C++ bundles can be C++17. The Celix::framework and Celix::CxxShell is still C++11
+set(CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}")
 set(CMAKE_CXX_FLAGS "-Wall -Werror -Wextra -Weffc++ ${CMAKE_CXX_FLAGS}")
 
 if(APPLE)
diff --git a/bundles/cxx_remote_services/admin/CMakeLists.txt b/bundles/cxx_remote_services/admin/CMakeLists.txt
index 24b77ab..4271651 100644
--- a/bundles/cxx_remote_services/admin/CMakeLists.txt
+++ b/bundles/cxx_remote_services/admin/CMakeLists.txt
@@ -30,7 +30,6 @@ target_link_libraries(RemoteServiceAdmin PRIVATE
         Celix::framework
         Celix::log_helper
 )
-target_compile_options(RemoteServiceAdmin PRIVATE -std=c++17)
 
 install_celix_bundle(RemoteServiceAdmin EXPORT celix COMPONENT rsa)
 #Setup target aliases to match external usage
diff --git a/bundles/cxx_remote_services/admin/gtest/CMakeLists.txt b/bundles/cxx_remote_services/admin/gtest/CMakeLists.txt
index 878a555..0fe109d 100644
--- a/bundles/cxx_remote_services/admin/gtest/CMakeLists.txt
+++ b/bundles/cxx_remote_services/admin/gtest/CMakeLists.txt
@@ -19,7 +19,6 @@ add_executable(test_cxx_remote_service_admin
     src/RemoteServiceAdminTestSuite.cc
 )
 target_link_libraries(test_cxx_remote_service_admin PRIVATE Celix::framework GTest::gtest GTest::gtest_main Celix::rsa_spi)
-target_compile_options(test_cxx_remote_service_admin PRIVATE -std=c++17)
 
 add_dependencies(test_cxx_remote_service_admin RemoteServiceAdmin_bundle)
 
diff --git a/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt b/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt
index 49f31dd..7834cce 100644
--- a/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt
+++ b/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt
@@ -41,7 +41,6 @@ target_link_libraries(RsaConfiguredDiscovery PRIVATE
         Celix::log_helper
 )
 target_include_directories(RsaConfiguredDiscovery PRIVATE src)
-target_compile_options(RsaConfiguredDiscovery PRIVATE -std=c++17)
 install_celix_bundle(RsaConfiguredDiscovery EXPORT celix COMPONENT rsa)
 add_library(Celix::RsaConfiguredDiscovery ALIAS RsaConfiguredDiscovery)
 
diff --git a/bundles/cxx_remote_services/discovery_configured/gtest/CMakeLists.txt b/bundles/cxx_remote_services/discovery_configured/gtest/CMakeLists.txt
index 8e197fe..710440b 100644
--- a/bundles/cxx_remote_services/discovery_configured/gtest/CMakeLists.txt
+++ b/bundles/cxx_remote_services/discovery_configured/gtest/CMakeLists.txt
@@ -20,8 +20,6 @@ add_executable(test_cxx_rsa_configured_discovery
 )
 
 target_link_libraries(test_cxx_rsa_configured_discovery PRIVATE Celix::framework GTest::gtest GTest::gtest_main Celix::rsa_spi RsaConfiguredDiscovery_api)
-target_compile_options(test_cxx_rsa_configured_discovery PRIVATE -std=c++17)
-
 
 add_dependencies(test_cxx_rsa_configured_discovery RsaConfiguredDiscovery_bundle)
 celix_get_bundle_file(RsaConfiguredDiscovery RSA_CONFIGURED_DISCOVERY_BUNDLE_LOCATION)
diff --git a/bundles/cxx_remote_services/integration/CMakeLists.txt b/bundles/cxx_remote_services/integration/CMakeLists.txt
index 860a081..8321f00 100644
--- a/bundles/cxx_remote_services/integration/CMakeLists.txt
+++ b/bundles/cxx_remote_services/integration/CMakeLists.txt
@@ -19,7 +19,6 @@ add_celix_bundle(TestExportImportRemoteServiceFactory
         SOURCES src/TestExportImportRemoteServiceFactory.cc
 )
 target_link_libraries(TestExportImportRemoteServiceFactory PRIVATE Celix::rsa_spi Celix::pubsub_api Celix::Promises Celix::log_helper)
-target_compile_options(TestExportImportRemoteServiceFactory PRIVATE -std=c++17) #TODO how can this be improved (bring back -std=c++17 on INTERFACE for promises?
 target_include_directories(TestExportImportRemoteServiceFactory PRIVATE include)
 celix_bundle_files(TestExportImportRemoteServiceFactory
         resources/Calculator$add$Invoke.descriptor
@@ -32,8 +31,6 @@ add_celix_bundle(CalculatorProvider
 )
 target_link_libraries(CalculatorProvider PRIVATE Celix::Promises)
 target_include_directories(CalculatorProvider PRIVATE include)
-target_compile_options(CalculatorProvider PRIVATE -std=c++17) #TODO how can this be improved (bring back -std=c++17 on INTERFACE for promises?
-
 
 add_celix_bundle(CalculatorConsumer
         SOURCES src/CalculatorConsumer.cc
@@ -41,7 +38,6 @@ add_celix_bundle(CalculatorConsumer
 celix_bundle_files(CalculatorConsumer ${CMAKE_CURRENT_SOURCE_DIR}/resources/endpoint_discovery.json DESTINATION "META-INF/discovery") # add configured discovery as resource in the bundle.
 target_link_libraries(CalculatorConsumer PRIVATE Celix::Promises Celix::shell_api Celix::RsaConfiguredDiscovery_api)
 target_include_directories(CalculatorConsumer PRIVATE include)
-target_compile_options(CalculatorConsumer PRIVATE -std=c++17) #TODO how can this be improved (bring back -std=c++17 on INTERFACE for promises?
 
 if (ENABLE_TESTING)
     add_subdirectory(gtest)
diff --git a/bundles/cxx_remote_services/integration/gtest/CMakeLists.txt b/bundles/cxx_remote_services/integration/gtest/CMakeLists.txt
index 81386b9..d6a66e9 100644
--- a/bundles/cxx_remote_services/integration/gtest/CMakeLists.txt
+++ b/bundles/cxx_remote_services/integration/gtest/CMakeLists.txt
@@ -19,7 +19,6 @@ add_executable(test_cxx_remote_services_integration
     src/RemoteServicesIntegrationTestSuite.cc
 )
 target_link_libraries(test_cxx_remote_services_integration PRIVATE Celix::framework Celix::Promises Celix::shell_api ZMQ::lib CZMQ::lib GTest::gtest GTest::gtest_main)
-target_compile_options(test_cxx_remote_services_integration PRIVATE -std=c++17)
 target_include_directories(test_cxx_remote_services_integration PRIVATE ../include) #Add ICalculator
 
 add_celix_bundle_dependencies(test_cxx_remote_services_integration
diff --git a/bundles/cxx_remote_services/rsa_spi/CMakeLists.txt b/bundles/cxx_remote_services/rsa_spi/CMakeLists.txt
index 73e944b..968af6d 100644
--- a/bundles/cxx_remote_services/rsa_spi/CMakeLists.txt
+++ b/bundles/cxx_remote_services/rsa_spi/CMakeLists.txt
@@ -20,8 +20,6 @@ target_include_directories(rsa_spi INTERFACE
     $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
     $<INSTALL_INTERFACE:include/celix/rsa>
 )
-#TODO TBD is it smart to add a c++ std as INTERFACE option?
-#target_compile_options(rsa_spi INTERFACE -std=c++17)
 
 install(TARGETS rsa_spi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT rsa)
 install(DIRECTORY include/ DESTINATION include/celix/rsa COMPONENT rsa)
diff --git a/bundles/cxx_remote_services/topology_manager/CMakeLists.txt b/bundles/cxx_remote_services/topology_manager/CMakeLists.txt
index 6056ad9..7459fa3 100644
--- a/bundles/cxx_remote_services/topology_manager/CMakeLists.txt
+++ b/bundles/cxx_remote_services/topology_manager/CMakeLists.txt
@@ -29,8 +29,7 @@ target_link_libraries(async_topology_manager PRIVATE
         Celix::async_rsa_discovery_configured
         Celix::framework
         Celix::log_helper
-        )
-target_compile_options(async_topology_manager INTERFACE -std=c++17)
+)
 
 #if (ENABLE_TESTING)
 #    add_subdirectory(gtest)
diff --git a/bundles/pubsub/pubsub_serializer_avrobin/gtest/CMakeLists.txt b/bundles/pubsub/pubsub_serializer_avrobin/gtest/CMakeLists.txt
index 59e4ca5..8f764d4 100644
--- a/bundles/pubsub/pubsub_serializer_avrobin/gtest/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_serializer_avrobin/gtest/CMakeLists.txt
@@ -25,7 +25,6 @@ add_executable(test_pubsub_serializer_avrobin
         src/PubSubAvrobinSerializationProviderTestSuite.cc
 )
 target_link_libraries(test_pubsub_serializer_avrobin PRIVATE Celix::framework Celix::dfi Celix::pubsub_utils GTest::gtest GTest::gtest_main Celix::pubsub_spi)
-target_compile_options(test_pubsub_serializer_avrobin PRIVATE -std=c++14) #Note test code is allowed to be C++14
 
 add_dependencies(test_pubsub_serializer_avrobin celix_pubsub_serializer_avrobin_bundle pubsub_avrobin_serialization_descriptor_bundle)
 target_compile_definitions(test_pubsub_serializer_avrobin PRIVATE -DSERIALIZATION_BUNDLE=\"$<TARGET_PROPERTY:celix_pubsub_serializer_avrobin,BUNDLE_FILE>\")
diff --git a/bundles/pubsub/pubsub_serializer_json/gtest/CMakeLists.txt b/bundles/pubsub/pubsub_serializer_json/gtest/CMakeLists.txt
index 9a07c94..60b5626 100644
--- a/bundles/pubsub/pubsub_serializer_json/gtest/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_serializer_json/gtest/CMakeLists.txt
@@ -25,7 +25,6 @@ add_executable(test_pubsub_serializer_json
 		src/PubSubJsonSerializationProviderTestSuite.cc
 )
 target_link_libraries(test_pubsub_serializer_json PRIVATE Celix::framework Celix::dfi Celix::pubsub_utils GTest::gtest GTest::gtest_main Celix::pubsub_spi)
-target_compile_options(test_pubsub_serializer_json PRIVATE -std=c++14) #Note test code is allowed to be C++14
 
 add_dependencies(test_pubsub_serializer_json celix_pubsub_serializer_json_bundle pubsub_json_serialization_descriptor_bundle)
 target_compile_definitions(test_pubsub_serializer_json PRIVATE -DSERIALIZATION_BUNDLE=\"$<TARGET_PROPERTY:celix_pubsub_serializer_json,BUNDLE_FILE>\")
diff --git a/bundles/pubsub/pubsub_spi/gtest/CMakeLists.txt b/bundles/pubsub/pubsub_spi/gtest/CMakeLists.txt
index 5cc80be..4c084bd 100644
--- a/bundles/pubsub/pubsub_spi/gtest/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_spi/gtest/CMakeLists.txt
@@ -19,7 +19,6 @@ add_executable(test_pubsub_spi
 		src/PubSubEndpointUtilsTestSuite.cc
 )
 target_link_libraries(test_pubsub_spi PRIVATE Celix::pubsub_spi GTest::gtest GTest::gtest_main)
-target_compile_options(test_pubsub_spi PRIVATE -std=c++14) #Note test code is allowed to be C++14
 
 #Seems to be an issue with coverage setup, for now disabled
 #setup_target_for_coverage(test_pubsub_spi SCAN_DIR ..)
diff --git a/bundles/pubsub/pubsub_utils/gtest/CMakeLists.txt b/bundles/pubsub/pubsub_utils/gtest/CMakeLists.txt
index a883776..ac8cdb8 100644
--- a/bundles/pubsub/pubsub_utils/gtest/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_utils/gtest/CMakeLists.txt
@@ -52,7 +52,6 @@ add_executable(test_pubsub_utils
 		src/PubSubMatchingTestSuite.cpp
 )
 target_link_libraries(test_pubsub_utils PRIVATE Celix::framework Celix::pubsub_utils GTest::gtest GTest::gtest_main Celix::pubsub_spi)
-target_compile_options(test_pubsub_utils PRIVATE -std=c++14) #Note test code is allowed to be C++14
 add_test(NAME test_pubsub_utils COMMAND test_pubsub_utils)
 setup_target_for_coverage(test_pubsub_utils SCAN_DIR ..)
 
diff --git a/bundles/shell/shell/CMakeLists.txt b/bundles/shell/shell/CMakeLists.txt
index c89e85a..ba62a4c 100644
--- a/bundles/shell/shell/CMakeLists.txt
+++ b/bundles/shell/shell/CMakeLists.txt
@@ -70,6 +70,7 @@ if (SHELL)
 	add_library(Celix::shell ALIAS shell)
 
 	if (CELIX_CXX)
+		set(CMAKE_CXX_STANDARD 11) #Note that the Celix::CxxShell uses C++11 only
 		add_celix_bundle(ShellCxx
 			SYMBOLIC_NAME "apache::celix::CxxShell"
 			VERSION "2.1.0"
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index d26439c..80b88e7 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -30,6 +30,6 @@
 cmake_minimum_required (VERSION 3.4)
 project (CelixUse C CXX)
 set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 ${CMAKE_C_FLAGS}")
-set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_STANDARD 11)
 find_package(Celix REQUIRED)
 add_subdirectory(celix-examples examples)
diff --git a/libs/framework/CMakeLists.txt b/libs/framework/CMakeLists.txt
index c430a4a..cfc1d22 100644
--- a/libs/framework/CMakeLists.txt
+++ b/libs/framework/CMakeLists.txt
@@ -19,6 +19,8 @@ find_package(ZLIB REQUIRED)
 find_package(UUID REQUIRED)
 find_package(CURL REQUIRED)
 
+set(CMAKE_CXX_STANDARD 11) #Note that the Celix framework C++ (header only) library uses C++11 only
+
 set(SOURCES
         src/attribute.c src/bundle.c src/bundle_archive.c src/bundle_cache.c
         src/bundle_context.c src/bundle_revision.c src/capability.c src/celix_errorcodes.c
diff --git a/libs/promises/CMakeLists.txt b/libs/promises/CMakeLists.txt
index 5c212f9..86784e3 100644
--- a/libs/promises/CMakeLists.txt
+++ b/libs/promises/CMakeLists.txt
@@ -28,7 +28,6 @@ if (NOT COMMAND celix_subproject)
 
     include(GNUInstallDirs)
 
-    set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
     set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_CXX_FLAGS_DEBUG}")
 
     set(PROMISES_STANDALONE ON)
@@ -49,7 +48,6 @@ if (PROMISES OR PROMISES_STANDALONE)
     add_library(Celix::Promises ALIAS Promises)
 
     add_executable(PromiseExamples src/PromiseExamples.cc)
-    target_compile_options(PromiseExamples PRIVATE -std=c++17)
     target_link_libraries(PromiseExamples PRIVATE Celix::Promises)
 
     if (ENABLE_TESTING AND NOT PROMISE_STANDALONE)
diff --git a/libs/promises/gtest/CMakeLists.txt b/libs/promises/gtest/CMakeLists.txt
index 38cfa8d..209e40d 100644
--- a/libs/promises/gtest/CMakeLists.txt
+++ b/libs/promises/gtest/CMakeLists.txt
@@ -20,7 +20,6 @@ add_executable(test_celix_promises
         src/PromisesTestSuite.cc
         src/VoidPromisesTestSuite.cc
 )
-target_compile_options(test_celix_promises PRIVATE -std=c++17)
 target_link_libraries(test_celix_promises PRIVATE GTest::gtest GTest::gtest_main Celix::Promises)
 
 add_test(NAME test_celix_promises COMMAND test_celix_promises)