From e2ecae5e93bbd30d2b417e7430f80fc8523ba61c Mon Sep 17 00:00:00 2001 From: DownerCase Date: Mon, 27 Jan 2025 12:36:07 +0000 Subject: [PATCH 01/11] Use ecal_add_library where appropriate --- app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt | 2 +- app/play/play_core/CMakeLists.txt | 2 +- app/rec/rec_client_core/CMakeLists.txt | 2 +- app/rec/rec_server_core/CMakeLists.txt | 2 +- app/sys/sys_client_core/CMakeLists.txt | 2 +- app/sys/sys_core/CMakeLists.txt | 2 +- contrib/measurement/hdf5/CMakeLists.txt | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt b/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt index 2e86602c2c..14737e4e87 100644 --- a/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt +++ b/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt @@ -37,7 +37,7 @@ set(source_files set(CMAKE_AUTOMOC ON) -add_library(${PROJECT_NAME} ${source_files}) +ecal_add_library(${PROJECT_NAME} ${source_files}) add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PUBLIC src) diff --git a/app/play/play_core/CMakeLists.txt b/app/play/play_core/CMakeLists.txt index b978dcca9c..ff1116394c 100644 --- a/app/play/play_core/CMakeLists.txt +++ b/app/play/play_core/CMakeLists.txt @@ -43,7 +43,7 @@ set(source_files src/measurement_container.h ) -add_library(${PROJECT_NAME} ${source_files}) +ecal_add_library(${PROJECT_NAME} ${source_files}) add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) diff --git a/app/rec/rec_client_core/CMakeLists.txt b/app/rec/rec_client_core/CMakeLists.txt index e6b2aaf07d..2f7dadb560 100644 --- a/app/rec/rec_client_core/CMakeLists.txt +++ b/app/rec/rec_client_core/CMakeLists.txt @@ -78,7 +78,7 @@ if (ECAL_USE_CURL) ) endif() -add_library (${PROJECT_NAME} ${source_files}) +ecal_add_library (${PROJECT_NAME} ${source_files}) add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) diff --git a/app/rec/rec_server_core/CMakeLists.txt b/app/rec/rec_server_core/CMakeLists.txt index 8092dc0a1e..8d31390ca5 100644 --- a/app/rec/rec_server_core/CMakeLists.txt +++ b/app/rec/rec_server_core/CMakeLists.txt @@ -56,7 +56,7 @@ set(source_files src/recorder/remote_recorder.h ) -add_library (${PROJECT_NAME} ${source_files}) +ecal_add_library (${PROJECT_NAME} ${source_files}) add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) diff --git a/app/sys/sys_client_core/CMakeLists.txt b/app/sys/sys_client_core/CMakeLists.txt index 47d703ef44..93ee57bc30 100644 --- a/app/sys/sys_client_core/CMakeLists.txt +++ b/app/sys/sys_client_core/CMakeLists.txt @@ -34,7 +34,7 @@ set(source_files src/task.cpp ) -add_library (${PROJECT_NAME} ${source_files}) +ecal_add_library (${PROJECT_NAME} ${source_files}) add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) diff --git a/app/sys/sys_core/CMakeLists.txt b/app/sys/sys_core/CMakeLists.txt index 7f36ab17f5..e4b187a5fa 100644 --- a/app/sys/sys_core/CMakeLists.txt +++ b/app/sys/sys_core/CMakeLists.txt @@ -74,7 +74,7 @@ set(ecalsyscore_src src/task/task_group.cpp ) -add_library(${PROJECT_NAME} ${ecalsyscore_src}) +ecal_add_library(${PROJECT_NAME} ${ecalsyscore_src}) add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} diff --git a/contrib/measurement/hdf5/CMakeLists.txt b/contrib/measurement/hdf5/CMakeLists.txt index 209d68daaa..efcabb3be1 100644 --- a/contrib/measurement/hdf5/CMakeLists.txt +++ b/contrib/measurement/hdf5/CMakeLists.txt @@ -18,7 +18,7 @@ project(measurement_hdf5) -add_library(${PROJECT_NAME} +ecal_add_library(${PROJECT_NAME} include/ecal/measurement/hdf5/reader.h include/ecal/measurement/hdf5/writer.h src/reader.cpp From 1dd2862f7a6c0632dbb91c2afe82b3e38894e73e Mon Sep 17 00:00:00 2001 From: DownerCase Date: Mon, 27 Jan 2025 12:49:45 +0000 Subject: [PATCH 02/11] Extract library ALIASing to helper function --- app/app_pb/CMakeLists.txt | 2 -- app/apps/CMakeLists.txt | 1 - app/mon/mon_plugin_lib/CMakeLists.txt | 1 - app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt | 3 +-- app/play/play_core/CMakeLists.txt | 1 - app/rec/rec_addon_core/CMakeLists.txt | 1 - app/rec/rec_client_core/CMakeLists.txt | 1 - app/rec/rec_server_core/CMakeLists.txt | 1 - app/sys/sys_cli/CMakeLists.txt | 1 + app/sys/sys_client_core/CMakeLists.txt | 1 - app/sys/sys_core/CMakeLists.txt | 12 +++++++----- app/sys/sys_gui/CMakeLists.txt | 1 + cmake/helper_functions/ecal_add_functions.cmake | 2 ++ contrib/ecalhdf5/CMakeLists.txt | 1 - contrib/ecaltime/ecaltime_pb/CMakeLists.txt | 2 -- contrib/measurement/hdf5/CMakeLists.txt | 2 -- ecal/core/CMakeLists.txt | 2 -- ecal/core_pb/CMakeLists.txt | 2 -- lang/c/core/CMakeLists.txt | 2 -- lib/ecal_utils/CMakeLists.txt | 2 -- serialization/protobuf/protobuf/CMakeLists.txt | 1 - 21 files changed, 12 insertions(+), 30 deletions(-) diff --git a/app/app_pb/CMakeLists.txt b/app/app_pb/CMakeLists.txt index aba4a91ae4..959431a20f 100644 --- a/app/app_pb/CMakeLists.txt +++ b/app/app_pb/CMakeLists.txt @@ -57,8 +57,6 @@ else() ecal_add_shared_library(${PROJECT_NAME} src/app_pb.cpp) endif() -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - protobuf_target_cpp(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src INSTALL_FOLDER "${eCAL_install_include_dir}" ${ProtoFiles} diff --git a/app/apps/CMakeLists.txt b/app/apps/CMakeLists.txt index 2e4c3d616b..e0843a47c4 100644 --- a/app/apps/CMakeLists.txt +++ b/app/apps/CMakeLists.txt @@ -23,7 +23,6 @@ set(ecal_apps_header ) ecal_add_interface_library(${PROJECT_NAME} ${ecal_apps_header}) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} INTERFACE $ # $ diff --git a/app/mon/mon_plugin_lib/CMakeLists.txt b/app/mon/mon_plugin_lib/CMakeLists.txt index f7a6f4b708..fc0590419f 100644 --- a/app/mon/mon_plugin_lib/CMakeLists.txt +++ b/app/mon/mon_plugin_lib/CMakeLists.txt @@ -36,7 +36,6 @@ set(ecalmonpluginlib_header ) ecal_add_library(${PROJECT_NAME} ${ecalmonpluginlib_src} ${ecalmonpluginlib_header}) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PUBLIC $ diff --git a/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt b/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt index 14737e4e87..eb6e202eac 100644 --- a/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt +++ b/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt @@ -38,11 +38,10 @@ set(source_files set(CMAKE_AUTOMOC ON) ecal_add_library(${PROJECT_NAME} ${source_files}) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PUBLIC src) -target_link_libraries(${PROJECT_NAME} +target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets CustomQt diff --git a/app/play/play_core/CMakeLists.txt b/app/play/play_core/CMakeLists.txt index ff1116394c..b39b3de150 100644 --- a/app/play/play_core/CMakeLists.txt +++ b/app/play/play_core/CMakeLists.txt @@ -44,7 +44,6 @@ set(source_files ) ecal_add_library(${PROJECT_NAME} ${source_files}) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/rec/rec_addon_core/CMakeLists.txt b/app/rec/rec_addon_core/CMakeLists.txt index cb86af603f..31c0f1ac1c 100644 --- a/app/rec/rec_addon_core/CMakeLists.txt +++ b/app/rec/rec_addon_core/CMakeLists.txt @@ -39,7 +39,6 @@ set(source_files ) ecal_add_library (${PROJECT_NAME} ${source_files}) -add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE diff --git a/app/rec/rec_client_core/CMakeLists.txt b/app/rec/rec_client_core/CMakeLists.txt index 2f7dadb560..f25b6340d6 100644 --- a/app/rec/rec_client_core/CMakeLists.txt +++ b/app/rec/rec_client_core/CMakeLists.txt @@ -79,7 +79,6 @@ if (ECAL_USE_CURL) endif() ecal_add_library (${PROJECT_NAME} ${source_files}) -add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/rec/rec_server_core/CMakeLists.txt b/app/rec/rec_server_core/CMakeLists.txt index 8d31390ca5..0547e10073 100644 --- a/app/rec/rec_server_core/CMakeLists.txt +++ b/app/rec/rec_server_core/CMakeLists.txt @@ -57,7 +57,6 @@ set(source_files ) ecal_add_library (${PROJECT_NAME} ${source_files}) -add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/sys/sys_cli/CMakeLists.txt b/app/sys/sys_cli/CMakeLists.txt index bdc1929246..405f585986 100644 --- a/app/sys/sys_cli/CMakeLists.txt +++ b/app/sys/sys_cli/CMakeLists.txt @@ -77,6 +77,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE protobuf::libprotobuf CustomTclap eCAL::core_pb + eCAL::protobuf_core ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/app/sys/sys_client_core/CMakeLists.txt b/app/sys/sys_client_core/CMakeLists.txt index 93ee57bc30..4a181d4437 100644 --- a/app/sys/sys_client_core/CMakeLists.txt +++ b/app/sys/sys_client_core/CMakeLists.txt @@ -35,7 +35,6 @@ set(source_files ) ecal_add_library (${PROJECT_NAME} ${source_files}) -add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/sys/sys_core/CMakeLists.txt b/app/sys/sys_core/CMakeLists.txt index e4b187a5fa..98604319a4 100644 --- a/app/sys/sys_core/CMakeLists.txt +++ b/app/sys/sys_core/CMakeLists.txt @@ -75,7 +75,6 @@ set(ecalsyscore_src ) ecal_add_library(${PROJECT_NAME} ${ecalsyscore_src}) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE $ @@ -87,15 +86,18 @@ target_compile_definitions(${PROJECT_NAME} create_targets_protobuf() target_link_libraries(${PROJECT_NAME} + PUBLIC + eCAL::core + spdlog::spdlog + eCAL::sys_client_core + eCAL::core_pb + eCAL::app_pb + PRIVATE Threads::Threads tinyxml2::tinyxml2 - spdlog::spdlog protobuf::libprotobuf eCAL::protobuf_core - eCAL::core_pb - eCAL::app_pb EcalParser - eCAL::sys_client_core ) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) diff --git a/app/sys/sys_gui/CMakeLists.txt b/app/sys/sys_gui/CMakeLists.txt index a893413b1b..59886d27db 100644 --- a/app/sys/sys_gui/CMakeLists.txt +++ b/app/sys/sys_gui/CMakeLists.txt @@ -181,6 +181,7 @@ target_link_libraries (${PROJECT_NAME} PRIVATE CustomTclap tclap::tclap eCAL::core + eCAL::protobuf_core eCAL::sys_core protobuf::libprotobuf EcalParser diff --git a/cmake/helper_functions/ecal_add_functions.cmake b/cmake/helper_functions/ecal_add_functions.cmake index 089c46c5ff..2fd90cdcb9 100644 --- a/cmake/helper_functions/ecal_add_functions.cmake +++ b/cmake/helper_functions/ecal_add_functions.cmake @@ -127,6 +127,7 @@ endfunction() function(ecal_add_shared_library TARGET_NAME) add_library(${TARGET_NAME} SHARED ${ARGN}) + add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} @@ -136,6 +137,7 @@ endfunction() function(ecal_add_static_library TARGET_NAME) add_library(${TARGET_NAME} STATIC ${ARGN}) + add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} diff --git a/contrib/ecalhdf5/CMakeLists.txt b/contrib/ecalhdf5/CMakeLists.txt index cd9073b74b..9c8abcb291 100644 --- a/contrib/ecalhdf5/CMakeLists.txt +++ b/contrib/ecalhdf5/CMakeLists.txt @@ -67,7 +67,6 @@ set(ecalhdf5_header_base ) ecal_add_library(${PROJECT_NAME} ${ecalhdf5_src} ${ecalhdf5_header_base}) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE . diff --git a/contrib/ecaltime/ecaltime_pb/CMakeLists.txt b/contrib/ecaltime/ecaltime_pb/CMakeLists.txt index 9d6e87e0cc..a34f46f9c3 100644 --- a/contrib/ecaltime/ecaltime_pb/CMakeLists.txt +++ b/contrib/ecaltime/ecaltime_pb/CMakeLists.txt @@ -46,8 +46,6 @@ else() ecal_add_shared_library(${PROJECT_NAME} src/ecaltime_pb.cpp) endif() -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - protobuf_target_cpp(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src INSTALL_FOLDER "${eCAL_install_include_dir}" ${ProtoFiles} diff --git a/contrib/measurement/hdf5/CMakeLists.txt b/contrib/measurement/hdf5/CMakeLists.txt index efcabb3be1..b01f370c13 100644 --- a/contrib/measurement/hdf5/CMakeLists.txt +++ b/contrib/measurement/hdf5/CMakeLists.txt @@ -25,8 +25,6 @@ ecal_add_library(${PROJECT_NAME} src/writer.cpp ) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - target_include_directories(${PROJECT_NAME} PUBLIC $ $ diff --git a/ecal/core/CMakeLists.txt b/ecal/core/CMakeLists.txt index 94d2fa22eb..7cd63b4eff 100644 --- a/ecal/core/CMakeLists.txt +++ b/ecal/core/CMakeLists.txt @@ -605,8 +605,6 @@ if(UNIX) set_source_files_properties(src/util/convert_utf.cpp PROPERTIES COMPILE_FLAGS -Wno-implicit-fallthrough) endif() -add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) - target_compile_definitions(${TARGET_NAME} PUBLIC ASIO_STANDALONE diff --git a/ecal/core_pb/CMakeLists.txt b/ecal/core_pb/CMakeLists.txt index 892e6ea18c..7f392763b6 100644 --- a/ecal/core_pb/CMakeLists.txt +++ b/ecal/core_pb/CMakeLists.txt @@ -54,8 +54,6 @@ 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 "${eCAL_install_include_dir}" ${ProtoFiles} diff --git a/lang/c/core/CMakeLists.txt b/lang/c/core/CMakeLists.txt index 4f07d433b9..71311f157a 100644 --- a/lang/c/core/CMakeLists.txt +++ b/lang/c/core/CMakeLists.txt @@ -82,8 +82,6 @@ ecal_add_shared_library(${PROJECT_NAME} ${ecal_c_sources} ) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - target_include_directories(${PROJECT_NAME} PUBLIC $ diff --git a/lib/ecal_utils/CMakeLists.txt b/lib/ecal_utils/CMakeLists.txt index 1e887d83fd..e4336c8a3a 100644 --- a/lib/ecal_utils/CMakeLists.txt +++ b/lib/ecal_utils/CMakeLists.txt @@ -43,8 +43,6 @@ ecal_add_library(${PROJECT_NAME} ${ecal_utils_src} ) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - target_include_directories(${PROJECT_NAME} PRIVATE src/) target_include_directories(${PROJECT_NAME} PUBLIC $ diff --git a/serialization/protobuf/protobuf/CMakeLists.txt b/serialization/protobuf/protobuf/CMakeLists.txt index 4fd765f06b..4488fc2050 100644 --- a/serialization/protobuf/protobuf/CMakeLists.txt +++ b/serialization/protobuf/protobuf/CMakeLists.txt @@ -21,7 +21,6 @@ ########################## find_package(Protobuf REQUIRED) ecal_add_library(protobuf_base) -add_library(eCAL::protobuf_base ALIAS protobuf_base) target_sources(protobuf_base PUBLIC From 3a350cc16e02c60c732810dfb35ae8079b0eac4b Mon Sep 17 00:00:00 2001 From: DownerCase Date: Mon, 27 Jan 2025 12:56:53 +0000 Subject: [PATCH 03/11] Use ecal_add_interface_library and auto ALIAS --- cmake/helper_functions/ecal_add_functions.cmake | 1 + contrib/measurement/base/CMakeLists.txt | 3 +-- serialization/capnproto/capnproto/CMakeLists.txt | 3 +-- serialization/flatbuffers/flatbuffers/CMakeLists.txt | 3 +-- serialization/protobuf/protobuf/CMakeLists.txt | 3 +-- serialization/string/string/CMakeLists.txt | 6 ++---- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cmake/helper_functions/ecal_add_functions.cmake b/cmake/helper_functions/ecal_add_functions.cmake index 2fd90cdcb9..b7f0b381b6 100644 --- a/cmake/helper_functions/ecal_add_functions.cmake +++ b/cmake/helper_functions/ecal_add_functions.cmake @@ -149,6 +149,7 @@ endfunction() function(ecal_add_interface_library TARGET_NAME) add_library(${TARGET_NAME} INTERFACE) + add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) endfunction() function(ecal_add_library TARGET_NAME) diff --git a/contrib/measurement/base/CMakeLists.txt b/contrib/measurement/base/CMakeLists.txt index 258a0fdf9f..8d5f57974d 100644 --- a/contrib/measurement/base/CMakeLists.txt +++ b/contrib/measurement/base/CMakeLists.txt @@ -22,8 +22,7 @@ set(ecal_message_header include/ecal/measurement/base/measurement.h ) -add_library(${PROJECT_NAME} INTERFACE) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) +ecal_add_interface_library(${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} INTERFACE $ diff --git a/serialization/capnproto/capnproto/CMakeLists.txt b/serialization/capnproto/capnproto/CMakeLists.txt index 17593df37e..64db1d56cd 100644 --- a/serialization/capnproto/capnproto/CMakeLists.txt +++ b/serialization/capnproto/capnproto/CMakeLists.txt @@ -21,8 +21,7 @@ find_package(CapnProto REQUIRED) ########################## # Capnproto core communication extension ########################## -add_library(capnproto_core INTERFACE) -add_library(eCAL::capnproto_core ALIAS capnproto_core) +ecal_add_interface_library(capnproto_core) target_link_libraries(capnproto_core INTERFACE diff --git a/serialization/flatbuffers/flatbuffers/CMakeLists.txt b/serialization/flatbuffers/flatbuffers/CMakeLists.txt index 2df9982de0..ec7b143f9f 100644 --- a/serialization/flatbuffers/flatbuffers/CMakeLists.txt +++ b/serialization/flatbuffers/flatbuffers/CMakeLists.txt @@ -21,8 +21,7 @@ find_package(FlatBuffers REQUIRED) ########################## # FlatBuffers core communication extension ########################## -add_library(flatbuffers_core INTERFACE) -add_library(eCAL::flatbuffers_core ALIAS flatbuffers_core) +ecal_add_interface_library(flatbuffers_core) target_link_libraries(flatbuffers_core INTERFACE diff --git a/serialization/protobuf/protobuf/CMakeLists.txt b/serialization/protobuf/protobuf/CMakeLists.txt index 4488fc2050..f080dda919 100644 --- a/serialization/protobuf/protobuf/CMakeLists.txt +++ b/serialization/protobuf/protobuf/CMakeLists.txt @@ -59,8 +59,7 @@ set_property(TARGET protobuf_base PROPERTY FOLDER core) ########################## # Protobuf core communication extension ########################## -add_library(protobuf_core INTERFACE) -add_library(eCAL::protobuf_core ALIAS protobuf_core) +ecal_add_interface_library(protobuf_core) target_link_libraries(protobuf_core INTERFACE diff --git a/serialization/string/string/CMakeLists.txt b/serialization/string/string/CMakeLists.txt index 2da08e3dcd..6babb40ed1 100644 --- a/serialization/string/string/CMakeLists.txt +++ b/serialization/string/string/CMakeLists.txt @@ -23,8 +23,7 @@ # std::string core communication extension ########################## -add_library(string_base INTERFACE) -add_library(eCAL::string_base ALIAS string_base) +ecal_add_interface_library(string_base) target_sources(string_base INTERFACE @@ -48,8 +47,7 @@ install( ########################## # std::string core communication extension ########################## -add_library(string_core INTERFACE) -add_library(eCAL::string_core ALIAS string_core) +ecal_add_interface_library(string_core) target_link_libraries(string_core INTERFACE From cc13de0a6ccccac48d23a53848a894ba5a150d71 Mon Sep 17 00:00:00 2001 From: DownerCase Date: Mon, 27 Jan 2025 14:19:02 +0000 Subject: [PATCH 04/11] Apply warnings target to remaining libraries --- ecal/service/CMakeLists.txt | 22 ++++++++++++++++++++++ ecal/service/ecal_service/CMakeLists.txt | 9 ++------- lib/EcalParser/CMakeLists.txt | 3 --- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ecal/service/CMakeLists.txt b/ecal/service/CMakeLists.txt index 8743239f47..ef33de0d7a 100644 --- a/ecal/service/CMakeLists.txt +++ b/ecal/service/CMakeLists.txt @@ -19,6 +19,28 @@ cmake_minimum_required(VERSION 3.16) project(ecal_service) +# Root CMakeLists sets CMAKE_MODULE_PATH to include the correct path +# If the module cannot be found warnings basic warnings will be applied instead +include(helper_functions/ecal_compiler_warnings OPTIONAL RESULT_VARIABLE _ecal_warnings_found) +if("${_ecal_warnings_found}" STREQUAL "NOTFOUND") + message(AUTHOR_WARNING + " helper_functions/ecal_compiler_warnings.cmake not found.\n" + " Add the path to CMAKE_MODULE_PATH to use warnings specified by the main eCAL repo." + ) + add_library(_ecal_service_warnings INTERFACE) + set(cxx_compiler_flags "") + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + set(cxx_compiler_flags "/MP" "/W4") + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang") + set(cxx_compiler_flags "-Wall" "-Wextra") + else() + message(WARNING "Unknown compiler, will not set warning flags") + endif() + target_compile_options(_ecal_service_warnings INTERFACE "${cxx_compiler_flags}") +else() + add_library(_ecal_service_warnings ALIAS _ecal_warnings) +endif() + # Main library add_subdirectory(ecal_service) diff --git a/ecal/service/ecal_service/CMakeLists.txt b/ecal/service/ecal_service/CMakeLists.txt index f4b20103c0..87f26a32a0 100644 --- a/ecal/service/ecal_service/CMakeLists.txt +++ b/ecal/service/ecal_service/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5.1) +cmake_minimum_required(VERSION 3.16) project(ecal_service) @@ -61,6 +61,7 @@ target_link_libraries(${PROJECT_NAME} Threads::Threads $<$:ws2_32> $<$:wsock32> + _ecal_service_warnings ) @@ -72,12 +73,6 @@ target_compile_definitions(${PROJECT_NAME} target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) -target_compile_options(${PROJECT_NAME} PRIVATE - $<$,$,$>: - -Wall -Wextra> - $<$: - /W4>) - # Add own public include directory target_include_directories(${PROJECT_NAME} PUBLIC diff --git a/lib/EcalParser/CMakeLists.txt b/lib/EcalParser/CMakeLists.txt index 92ede4c3c3..ec574474ac 100644 --- a/lib/EcalParser/CMakeLists.txt +++ b/lib/EcalParser/CMakeLists.txt @@ -45,9 +45,6 @@ set(sources # QEcalParser is an internal implementation detail for applications so it can # always be static and not installed/exported ecal_add_static_library(${PROJECT_NAME} - ${includes} - ${sources} -) target_include_directories(${PROJECT_NAME} PUBLIC include/) target_include_directories(${PROJECT_NAME} PRIVATE src/) From c92fb4500e53e3ad93c6927a103e188c9a9e77ba Mon Sep 17 00:00:00 2001 From: DownerCase Date: Mon, 27 Jan 2025 14:31:02 +0000 Subject: [PATCH 05/11] Apply warnings to remaining executables --- ecal/service/samples/sample_client/CMakeLists.txt | 4 +++- ecal/service/samples/sample_server/CMakeLists.txt | 4 +++- ecal/service/samples/sample_standalone/CMakeLists.txt | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ecal/service/samples/sample_client/CMakeLists.txt b/ecal/service/samples/sample_client/CMakeLists.txt index 90c4cd4a67..240b994333 100644 --- a/ecal/service/samples/sample_client/CMakeLists.txt +++ b/ecal/service/samples/sample_client/CMakeLists.txt @@ -28,7 +28,9 @@ add_executable(${PROJECT_NAME} ${sources}) target_link_libraries(${PROJECT_NAME} PRIVATE - ecal_service) + ecal_service + _ecal_service_warnings +) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/service/samples/sample_server/CMakeLists.txt b/ecal/service/samples/sample_server/CMakeLists.txt index ffeca863a7..8ab0f4b92c 100644 --- a/ecal/service/samples/sample_server/CMakeLists.txt +++ b/ecal/service/samples/sample_server/CMakeLists.txt @@ -28,7 +28,9 @@ add_executable(${PROJECT_NAME} ${sources}) target_link_libraries(${PROJECT_NAME} PRIVATE - ecal_service) + ecal_service + _ecal_service_warnings +) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/service/samples/sample_standalone/CMakeLists.txt b/ecal/service/samples/sample_standalone/CMakeLists.txt index 0806b506a7..8896fbc7c6 100644 --- a/ecal/service/samples/sample_standalone/CMakeLists.txt +++ b/ecal/service/samples/sample_standalone/CMakeLists.txt @@ -28,7 +28,9 @@ add_executable(${PROJECT_NAME} ${sources}) target_link_libraries(${PROJECT_NAME} PRIVATE - ecal_service) + ecal_service + _ecal_service_warnings +) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) From 6a569a8e594a272c65bd62e7e7866fa2f544349a Mon Sep 17 00:00:00 2001 From: DownerCase Date: Mon, 27 Jan 2025 15:49:24 +0000 Subject: [PATCH 06/11] Revert use of ecal_helpers in serialization sub-project --- serialization/capnproto/capnproto/CMakeLists.txt | 3 ++- serialization/flatbuffers/flatbuffers/CMakeLists.txt | 3 ++- serialization/protobuf/protobuf/CMakeLists.txt | 5 ++++- serialization/string/string/CMakeLists.txt | 6 ++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/serialization/capnproto/capnproto/CMakeLists.txt b/serialization/capnproto/capnproto/CMakeLists.txt index 64db1d56cd..17593df37e 100644 --- a/serialization/capnproto/capnproto/CMakeLists.txt +++ b/serialization/capnproto/capnproto/CMakeLists.txt @@ -21,7 +21,8 @@ find_package(CapnProto REQUIRED) ########################## # Capnproto core communication extension ########################## -ecal_add_interface_library(capnproto_core) +add_library(capnproto_core INTERFACE) +add_library(eCAL::capnproto_core ALIAS capnproto_core) target_link_libraries(capnproto_core INTERFACE diff --git a/serialization/flatbuffers/flatbuffers/CMakeLists.txt b/serialization/flatbuffers/flatbuffers/CMakeLists.txt index ec7b143f9f..2df9982de0 100644 --- a/serialization/flatbuffers/flatbuffers/CMakeLists.txt +++ b/serialization/flatbuffers/flatbuffers/CMakeLists.txt @@ -21,7 +21,8 @@ find_package(FlatBuffers REQUIRED) ########################## # FlatBuffers core communication extension ########################## -ecal_add_interface_library(flatbuffers_core) +add_library(flatbuffers_core INTERFACE) +add_library(eCAL::flatbuffers_core ALIAS flatbuffers_core) target_link_libraries(flatbuffers_core INTERFACE diff --git a/serialization/protobuf/protobuf/CMakeLists.txt b/serialization/protobuf/protobuf/CMakeLists.txt index f080dda919..cfa80193f3 100644 --- a/serialization/protobuf/protobuf/CMakeLists.txt +++ b/serialization/protobuf/protobuf/CMakeLists.txt @@ -46,6 +46,8 @@ target_link_libraries(protobuf_base PUBLIC protobuf::libprotobuf) target_compile_features(protobuf_base PUBLIC cxx_std_14) +ecal_add_compiler_warnings(protobuf_base) + install( TARGETS protobuf_base EXPORT eCALCoreTargets @@ -59,7 +61,8 @@ set_property(TARGET protobuf_base PROPERTY FOLDER core) ########################## # Protobuf core communication extension ########################## -ecal_add_interface_library(protobuf_core) +add_library(protobuf_core INTERFACE) +add_library(eCAL::protobuf_core ALIAS protobuf_core) target_link_libraries(protobuf_core INTERFACE diff --git a/serialization/string/string/CMakeLists.txt b/serialization/string/string/CMakeLists.txt index 6babb40ed1..2da08e3dcd 100644 --- a/serialization/string/string/CMakeLists.txt +++ b/serialization/string/string/CMakeLists.txt @@ -23,7 +23,8 @@ # std::string core communication extension ########################## -ecal_add_interface_library(string_base) +add_library(string_base INTERFACE) +add_library(eCAL::string_base ALIAS string_base) target_sources(string_base INTERFACE @@ -47,7 +48,8 @@ install( ########################## # std::string core communication extension ########################## -ecal_add_interface_library(string_core) +add_library(string_core INTERFACE) +add_library(eCAL::string_core ALIAS string_core) target_link_libraries(string_core INTERFACE From 7336ad4d0dcf66c7a73fb17129ea097f06cbc98b Mon Sep 17 00:00:00 2001 From: DownerCase Date: Thu, 13 Feb 2025 10:30:01 +0000 Subject: [PATCH 07/11] Fixup ecal parser --- lib/EcalParser/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/EcalParser/CMakeLists.txt b/lib/EcalParser/CMakeLists.txt index ec574474ac..5af7ae8dbf 100644 --- a/lib/EcalParser/CMakeLists.txt +++ b/lib/EcalParser/CMakeLists.txt @@ -42,9 +42,12 @@ set(sources src/functions/username.h ) -# QEcalParser is an internal implementation detail for applications so it can +# EcalParser is an internal implementation detail for applications so it can # always be static and not installed/exported ecal_add_static_library(${PROJECT_NAME} + ${includes} + ${sources} +) target_include_directories(${PROJECT_NAME} PUBLIC include/) target_include_directories(${PROJECT_NAME} PRIVATE src/) From b6abe8e37dcc5125881884f62769e745ce016538 Mon Sep 17 00:00:00 2001 From: DownerCase Date: Tue, 18 Feb 2025 09:17:20 +0000 Subject: [PATCH 08/11] Revert alias changes --- app/app_pb/CMakeLists.txt | 2 ++ app/apps/CMakeLists.txt | 1 + app/mon/mon_plugin_lib/CMakeLists.txt | 1 + app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt | 1 + app/play/play_core/CMakeLists.txt | 1 + app/rec/rec_addon_core/CMakeLists.txt | 1 + app/rec/rec_client_core/CMakeLists.txt | 1 + app/rec/rec_server_core/CMakeLists.txt | 1 + app/sys/sys_client_core/CMakeLists.txt | 1 + app/sys/sys_core/CMakeLists.txt | 1 + cmake/helper_functions/ecal_add_functions.cmake | 3 --- contrib/ecalhdf5/CMakeLists.txt | 1 + contrib/ecaltime/ecaltime_pb/CMakeLists.txt | 2 ++ contrib/measurement/base/CMakeLists.txt | 1 + contrib/measurement/hdf5/CMakeLists.txt | 2 ++ ecal/core/CMakeLists.txt | 2 ++ ecal/core_pb/CMakeLists.txt | 2 ++ lang/c/core/CMakeLists.txt | 2 ++ lib/ecal_utils/CMakeLists.txt | 2 ++ serialization/protobuf/protobuf/CMakeLists.txt | 1 + 20 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/app_pb/CMakeLists.txt b/app/app_pb/CMakeLists.txt index 959431a20f..aba4a91ae4 100644 --- a/app/app_pb/CMakeLists.txt +++ b/app/app_pb/CMakeLists.txt @@ -57,6 +57,8 @@ else() ecal_add_shared_library(${PROJECT_NAME} src/app_pb.cpp) endif() +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + protobuf_target_cpp(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src INSTALL_FOLDER "${eCAL_install_include_dir}" ${ProtoFiles} diff --git a/app/apps/CMakeLists.txt b/app/apps/CMakeLists.txt index e0843a47c4..2e4c3d616b 100644 --- a/app/apps/CMakeLists.txt +++ b/app/apps/CMakeLists.txt @@ -23,6 +23,7 @@ set(ecal_apps_header ) ecal_add_interface_library(${PROJECT_NAME} ${ecal_apps_header}) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} INTERFACE $ # $ diff --git a/app/mon/mon_plugin_lib/CMakeLists.txt b/app/mon/mon_plugin_lib/CMakeLists.txt index fc0590419f..f7a6f4b708 100644 --- a/app/mon/mon_plugin_lib/CMakeLists.txt +++ b/app/mon/mon_plugin_lib/CMakeLists.txt @@ -36,6 +36,7 @@ set(ecalmonpluginlib_header ) ecal_add_library(${PROJECT_NAME} ${ecalmonpluginlib_src} ${ecalmonpluginlib_header}) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PUBLIC $ diff --git a/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt b/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt index eb6e202eac..8079e8e3fd 100644 --- a/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt +++ b/app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt @@ -38,6 +38,7 @@ set(source_files set(CMAKE_AUTOMOC ON) ecal_add_library(${PROJECT_NAME} ${source_files}) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PUBLIC src) diff --git a/app/play/play_core/CMakeLists.txt b/app/play/play_core/CMakeLists.txt index b39b3de150..ff1116394c 100644 --- a/app/play/play_core/CMakeLists.txt +++ b/app/play/play_core/CMakeLists.txt @@ -44,6 +44,7 @@ set(source_files ) ecal_add_library(${PROJECT_NAME} ${source_files}) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/rec/rec_addon_core/CMakeLists.txt b/app/rec/rec_addon_core/CMakeLists.txt index 31c0f1ac1c..cb86af603f 100644 --- a/app/rec/rec_addon_core/CMakeLists.txt +++ b/app/rec/rec_addon_core/CMakeLists.txt @@ -39,6 +39,7 @@ set(source_files ) ecal_add_library (${PROJECT_NAME} ${source_files}) +add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE diff --git a/app/rec/rec_client_core/CMakeLists.txt b/app/rec/rec_client_core/CMakeLists.txt index f25b6340d6..2f7dadb560 100644 --- a/app/rec/rec_client_core/CMakeLists.txt +++ b/app/rec/rec_client_core/CMakeLists.txt @@ -79,6 +79,7 @@ if (ECAL_USE_CURL) endif() ecal_add_library (${PROJECT_NAME} ${source_files}) +add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/rec/rec_server_core/CMakeLists.txt b/app/rec/rec_server_core/CMakeLists.txt index 0547e10073..8d31390ca5 100644 --- a/app/rec/rec_server_core/CMakeLists.txt +++ b/app/rec/rec_server_core/CMakeLists.txt @@ -57,6 +57,7 @@ set(source_files ) ecal_add_library (${PROJECT_NAME} ${source_files}) +add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/sys/sys_client_core/CMakeLists.txt b/app/sys/sys_client_core/CMakeLists.txt index 4a181d4437..93ee57bc30 100644 --- a/app/sys/sys_client_core/CMakeLists.txt +++ b/app/sys/sys_client_core/CMakeLists.txt @@ -35,6 +35,7 @@ set(source_files ) ecal_add_library (${PROJECT_NAME} ${source_files}) +add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE src) target_include_directories(${PROJECT_NAME} PUBLIC include) diff --git a/app/sys/sys_core/CMakeLists.txt b/app/sys/sys_core/CMakeLists.txt index 98604319a4..93efe6cbb9 100644 --- a/app/sys/sys_core/CMakeLists.txt +++ b/app/sys/sys_core/CMakeLists.txt @@ -75,6 +75,7 @@ set(ecalsyscore_src ) ecal_add_library(${PROJECT_NAME} ${ecalsyscore_src}) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE $ diff --git a/cmake/helper_functions/ecal_add_functions.cmake b/cmake/helper_functions/ecal_add_functions.cmake index b7f0b381b6..089c46c5ff 100644 --- a/cmake/helper_functions/ecal_add_functions.cmake +++ b/cmake/helper_functions/ecal_add_functions.cmake @@ -127,7 +127,6 @@ endfunction() function(ecal_add_shared_library TARGET_NAME) add_library(${TARGET_NAME} SHARED ${ARGN}) - add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} @@ -137,7 +136,6 @@ endfunction() function(ecal_add_static_library TARGET_NAME) add_library(${TARGET_NAME} STATIC ${ARGN}) - add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} @@ -149,7 +147,6 @@ endfunction() function(ecal_add_interface_library TARGET_NAME) add_library(${TARGET_NAME} INTERFACE) - add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) endfunction() function(ecal_add_library TARGET_NAME) diff --git a/contrib/ecalhdf5/CMakeLists.txt b/contrib/ecalhdf5/CMakeLists.txt index 9c8abcb291..cd9073b74b 100644 --- a/contrib/ecalhdf5/CMakeLists.txt +++ b/contrib/ecalhdf5/CMakeLists.txt @@ -67,6 +67,7 @@ set(ecalhdf5_header_base ) ecal_add_library(${PROJECT_NAME} ${ecalhdf5_src} ${ecalhdf5_header_base}) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE . diff --git a/contrib/ecaltime/ecaltime_pb/CMakeLists.txt b/contrib/ecaltime/ecaltime_pb/CMakeLists.txt index a34f46f9c3..9d6e87e0cc 100644 --- a/contrib/ecaltime/ecaltime_pb/CMakeLists.txt +++ b/contrib/ecaltime/ecaltime_pb/CMakeLists.txt @@ -46,6 +46,8 @@ else() ecal_add_shared_library(${PROJECT_NAME} src/ecaltime_pb.cpp) endif() +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + protobuf_target_cpp(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src INSTALL_FOLDER "${eCAL_install_include_dir}" ${ProtoFiles} diff --git a/contrib/measurement/base/CMakeLists.txt b/contrib/measurement/base/CMakeLists.txt index 8d5f57974d..8b91504e4f 100644 --- a/contrib/measurement/base/CMakeLists.txt +++ b/contrib/measurement/base/CMakeLists.txt @@ -23,6 +23,7 @@ set(ecal_message_header ) ecal_add_interface_library(${PROJECT_NAME}) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} INTERFACE $ diff --git a/contrib/measurement/hdf5/CMakeLists.txt b/contrib/measurement/hdf5/CMakeLists.txt index b01f370c13..efcabb3be1 100644 --- a/contrib/measurement/hdf5/CMakeLists.txt +++ b/contrib/measurement/hdf5/CMakeLists.txt @@ -25,6 +25,8 @@ ecal_add_library(${PROJECT_NAME} src/writer.cpp ) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + target_include_directories(${PROJECT_NAME} PUBLIC $ $ diff --git a/ecal/core/CMakeLists.txt b/ecal/core/CMakeLists.txt index 7cd63b4eff..94d2fa22eb 100644 --- a/ecal/core/CMakeLists.txt +++ b/ecal/core/CMakeLists.txt @@ -605,6 +605,8 @@ if(UNIX) set_source_files_properties(src/util/convert_utf.cpp PROPERTIES COMPILE_FLAGS -Wno-implicit-fallthrough) endif() +add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME}) + target_compile_definitions(${TARGET_NAME} PUBLIC ASIO_STANDALONE diff --git a/ecal/core_pb/CMakeLists.txt b/ecal/core_pb/CMakeLists.txt index 7f392763b6..892e6ea18c 100644 --- a/ecal/core_pb/CMakeLists.txt +++ b/ecal/core_pb/CMakeLists.txt @@ -54,6 +54,8 @@ 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 "${eCAL_install_include_dir}" ${ProtoFiles} diff --git a/lang/c/core/CMakeLists.txt b/lang/c/core/CMakeLists.txt index 71311f157a..4f07d433b9 100644 --- a/lang/c/core/CMakeLists.txt +++ b/lang/c/core/CMakeLists.txt @@ -82,6 +82,8 @@ ecal_add_shared_library(${PROJECT_NAME} ${ecal_c_sources} ) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + target_include_directories(${PROJECT_NAME} PUBLIC $ diff --git a/lib/ecal_utils/CMakeLists.txt b/lib/ecal_utils/CMakeLists.txt index e4336c8a3a..1e887d83fd 100644 --- a/lib/ecal_utils/CMakeLists.txt +++ b/lib/ecal_utils/CMakeLists.txt @@ -43,6 +43,8 @@ ecal_add_library(${PROJECT_NAME} ${ecal_utils_src} ) +add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + target_include_directories(${PROJECT_NAME} PRIVATE src/) target_include_directories(${PROJECT_NAME} PUBLIC $ diff --git a/serialization/protobuf/protobuf/CMakeLists.txt b/serialization/protobuf/protobuf/CMakeLists.txt index cfa80193f3..f1f696cb67 100644 --- a/serialization/protobuf/protobuf/CMakeLists.txt +++ b/serialization/protobuf/protobuf/CMakeLists.txt @@ -21,6 +21,7 @@ ########################## find_package(Protobuf REQUIRED) ecal_add_library(protobuf_base) +add_library(eCAL::protobuf_base ALIAS protobuf_base) target_sources(protobuf_base PUBLIC From 0484820c1e4f3cf58872588823474960c5f0e1e5 Mon Sep 17 00:00:00 2001 From: DownerCase Date: Tue, 18 Feb 2025 10:28:38 +0000 Subject: [PATCH 09/11] Refactor setting compiler warnings --- CMakeLists.txt | 8 ++++- .../helper_functions/ecal_add_functions.cmake | 12 ++++++- .../ecal_compiler_warnings.cmake | 34 +++++++------------ ecal/service/CMakeLists.txt | 29 +++++++--------- 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27b9f1735c..e1f40ef96d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,6 +202,13 @@ option(ECAL_INSTALL_SAMPLE_SOURCES "Install the sources of eCAL option(ECAL_USE_NPCAP "Enable the eCAL Npcap Receiver (i.e. the Win10 performance fix)" OFF) option(ECAL_USE_CLOCKLOCK_MUTEX "Use native mutex with monotonic clock (requires glibc >= 2.30)" OFF) +set(ECAL_EXTRA_COMPILER_ARGS "" CACHE STRING "; separated list of additional compiler arguments to use for eCAL code") +include(./cmake/helper_functions/ecal_compiler_warnings.cmake) +ecal_get_default_compiler_warnings(ecal_default_warnings) +list(APPEND ecal_default_warnings ${ECAL_EXTRA_COMPILER_ARGS}) +set(ECAL_COMPILER_WARNINGS "${ecal_default_warnings}" CACHE STRING "Warning flags used for eCAL code") +mark_as_advanced(FORCE ECAL_COMPILER_WARNINGS) + # -------------------------------------------------------- # ecal core configuration # -------------------------------------------------------- @@ -583,7 +590,6 @@ install(FILES ${eCAL_config} ${eCAL_config_version} install(FILES cmake/helper_functions/ecal_add_functions.cmake - cmake/helper_functions/ecal_compiler_warnings.cmake cmake/helper_functions/ecal_helper_functions.cmake cmake/helper_functions/ecal_install_functions.cmake DESTINATION ${${PROJECT_NAME}_install_cmake_dir}/helper_functions diff --git a/cmake/helper_functions/ecal_add_functions.cmake b/cmake/helper_functions/ecal_add_functions.cmake index 089c46c5ff..06cb7e5434 100644 --- a/cmake/helper_functions/ecal_add_functions.cmake +++ b/cmake/helper_functions/ecal_add_functions.cmake @@ -18,7 +18,17 @@ include_guard(GLOBAL) -include("${CMAKE_CURRENT_LIST_DIR}/ecal_compiler_warnings.cmake") +# ECAL_COMPILER_WARNINGS is set by the root CMakeLists and may be user customized +add_library(_ecal_warnings INTERFACE) +target_compile_options(_ecal_warnings INTERFACE + "$<$:${ECAL_COMPILER_WARNINGS}>" +) + +function(ecal_add_compiler_warnings TARGET_NAME) + target_link_libraries("${TARGET_NAME}" PRIVATE + "$" + ) +endfunction() # This function will set the output names of the target according to eCAL conventions. function(ecal_add_app_console TARGET_NAME) diff --git a/cmake/helper_functions/ecal_compiler_warnings.cmake b/cmake/helper_functions/ecal_compiler_warnings.cmake index dc657e3e0c..e992a1c120 100644 --- a/cmake/helper_functions/ecal_compiler_warnings.cmake +++ b/cmake/helper_functions/ecal_compiler_warnings.cmake @@ -1,27 +1,17 @@ include_guard(GLOBAL) -add_library(_ecal_warnings INTERFACE) +function(ecal_get_default_compiler_warnings cxx_out_var) + set(cxx_compiler_flags "") -set(cxx_compiler_flags "") + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + message(STATUS "MSVC detected - Adding flags") + set(cxx_compiler_flags "/MP" "/W4") + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang") + message(STATUS "Setting GNU/Clang flags") + set(cxx_compiler_flags "-Wall" "-Wextra") + else() + message(WARNING "Unknown compiler, will not set warning flags") + endif() -if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - message(STATUS "MSVC detected - Adding flags") - set(cxx_compiler_flags "/MP" "/W4") -elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang") - message(STATUS "Setting GNU/Clang flags") - set(cxx_compiler_flags "-Wall" "-Wextra") -else() - message(WARNING "Unknown compiler, will not set warning flags") -endif() - -target_compile_options(_ecal_warnings INTERFACE - "$<$:${cxx_compiler_flags}>" -) - -unset(cxx_compiler_flags) - -function(ecal_add_compiler_warnings TARGET_NAME) - target_link_libraries("${TARGET_NAME}" PRIVATE - "$" - ) + set("${cxx_out_var}" "${cxx_compiler_flags}" PARENT_SCOPE) endfunction() diff --git a/ecal/service/CMakeLists.txt b/ecal/service/CMakeLists.txt index ef33de0d7a..5ab8f3b249 100644 --- a/ecal/service/CMakeLists.txt +++ b/ecal/service/CMakeLists.txt @@ -19,26 +19,23 @@ cmake_minimum_required(VERSION 3.16) project(ecal_service) -# Root CMakeLists sets CMAKE_MODULE_PATH to include the correct path -# If the module cannot be found warnings basic warnings will be applied instead -include(helper_functions/ecal_compiler_warnings OPTIONAL RESULT_VARIABLE _ecal_warnings_found) -if("${_ecal_warnings_found}" STREQUAL "NOTFOUND") - message(AUTHOR_WARNING - " helper_functions/ecal_compiler_warnings.cmake not found.\n" - " Add the path to CMAKE_MODULE_PATH to use warnings specified by the main eCAL repo." - ) - add_library(_ecal_service_warnings INTERFACE) - set(cxx_compiler_flags "") +if(TARGET _ecal_warnings) + # _ecal_warnings is the internal eCAL target containing the warning flags + # and will be absent if this is being built standalone + add_library(_ecal_service_warnings ALIAS _ecal_warnings) +else() + # Otherwise, use a fallback implementation if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - set(cxx_compiler_flags "/MP" "/W4") + set(cxx_compiler_flags "/MP" "/W4") elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang") - set(cxx_compiler_flags "-Wall" "-Wextra") + set(cxx_compiler_flags "-Wall" "-Wextra") else() - message(WARNING "Unknown compiler, will not set warning flags") + message(WARNING "Unknown compiler, will not set warning flags") endif() - target_compile_options(_ecal_service_warnings INTERFACE "${cxx_compiler_flags}") -else() - add_library(_ecal_service_warnings ALIAS _ecal_warnings) + + set(ECAL_SERVICE_COMPILER_WARNINGS "${cxx_compiler_flags}" CACHE STRING "Warning flags used for eCAL service code") + add_library(_ecal_service_warnings INTERFACE) + target_compile_options(_ecal_service_warnings INTERFACE "${ECAL_SERVICE_COMPILER_WARNINGS}") endif() # Main library From da09b312ccca9f2e26d6a492bcddfdac5ab45a0f Mon Sep 17 00:00:00 2001 From: DownerCase Date: Tue, 18 Feb 2025 10:30:52 +0000 Subject: [PATCH 10/11] Remove redundant add compiler warnings --- serialization/protobuf/protobuf/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/serialization/protobuf/protobuf/CMakeLists.txt b/serialization/protobuf/protobuf/CMakeLists.txt index f1f696cb67..4fd765f06b 100644 --- a/serialization/protobuf/protobuf/CMakeLists.txt +++ b/serialization/protobuf/protobuf/CMakeLists.txt @@ -47,8 +47,6 @@ target_link_libraries(protobuf_base PUBLIC protobuf::libprotobuf) target_compile_features(protobuf_base PUBLIC cxx_std_14) -ecal_add_compiler_warnings(protobuf_base) - install( TARGETS protobuf_base EXPORT eCALCoreTargets From a9f67a6e68ed5c51b1c875fdcccb196a290481d7 Mon Sep 17 00:00:00 2001 From: DownerCase Date: Tue, 18 Feb 2025 11:23:02 +0000 Subject: [PATCH 11/11] Refactor warnings and extra args cache variables --- CMakeLists.txt | 18 ++++++++--- .../helper_functions/ecal_add_functions.cmake | 30 +++++++++---------- ecal/service/CMakeLists.txt | 6 ++-- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1f40ef96d..e46e43fe89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,13 +202,23 @@ option(ECAL_INSTALL_SAMPLE_SOURCES "Install the sources of eCAL option(ECAL_USE_NPCAP "Enable the eCAL Npcap Receiver (i.e. the Win10 performance fix)" OFF) option(ECAL_USE_CLOCKLOCK_MUTEX "Use native mutex with monotonic clock (requires glibc >= 2.30)" OFF) -set(ECAL_EXTRA_COMPILER_ARGS "" CACHE STRING "; separated list of additional compiler arguments to use for eCAL code") -include(./cmake/helper_functions/ecal_compiler_warnings.cmake) + +# Compiler warnings and additional flag configuration +include(${CMAKE_CURRENT_LIST_DIR}/cmake/helper_functions/ecal_compiler_warnings.cmake) ecal_get_default_compiler_warnings(ecal_default_warnings) -list(APPEND ecal_default_warnings ${ECAL_EXTRA_COMPILER_ARGS}) -set(ECAL_COMPILER_WARNINGS "${ecal_default_warnings}" CACHE STRING "Warning flags used for eCAL code") + +set(ECAL_COMPILER_WARNINGS "${ecal_default_warnings}" CACHE STRING "List of warning flags for eCAL code") mark_as_advanced(FORCE ECAL_COMPILER_WARNINGS) +set(ECAL_COMPILER_EXTRA_ARGS "" CACHE STRING "List of additional compiler arguments for eCAL code") +mark_as_advanced(FORCE ECAL_COMPILER_EXTRA_ARGS) + +# Internal cache variable combining the warning and extra flags +set(ECAL_COMPILER_ARGS + ${ECAL_COMPILER_WARNINGS} ${ECAL_COMPILER_EXTRA_ARGS} + CACHE INTERNAL "Compiler flags used for eCAL code" FORCE +) + # -------------------------------------------------------- # ecal core configuration # -------------------------------------------------------- diff --git a/cmake/helper_functions/ecal_add_functions.cmake b/cmake/helper_functions/ecal_add_functions.cmake index 06cb7e5434..65a2105349 100644 --- a/cmake/helper_functions/ecal_add_functions.cmake +++ b/cmake/helper_functions/ecal_add_functions.cmake @@ -19,14 +19,14 @@ include_guard(GLOBAL) # ECAL_COMPILER_WARNINGS is set by the root CMakeLists and may be user customized -add_library(_ecal_warnings INTERFACE) -target_compile_options(_ecal_warnings INTERFACE - "$<$:${ECAL_COMPILER_WARNINGS}>" +add_library(_ecal_compiler_args INTERFACE) +target_compile_options(_ecal_compiler_args INTERFACE + "$<$:${ECAL_COMPILER_ARGS}>" ) -function(ecal_add_compiler_warnings TARGET_NAME) +function(ecal_add_compiler_flags TARGET_NAME) target_link_libraries("${TARGET_NAME}" PRIVATE - "$" + "$" ) endfunction() @@ -38,7 +38,7 @@ function(ecal_add_app_console TARGET_NAME) VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} OUTPUT_NAME ecal_${TARGET_NAME}) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() # This helper function automatically adds a gtest to ecal. @@ -65,7 +65,7 @@ function(ecal_add_gtest TARGET_NAME) VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} OUTPUT_NAME ecal_${TARGET_NAME}) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_app_gui TARGET_NAME) @@ -75,7 +75,7 @@ function(ecal_add_app_gui TARGET_NAME) VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} OUTPUT_NAME ecal_${TARGET_NAME}) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_app_qt TARGET_NAME) @@ -87,7 +87,7 @@ function(ecal_add_app_qt TARGET_NAME) if(WIN32) set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") endif() - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_mon_plugin TARGET_NAME) @@ -112,7 +112,7 @@ function(ecal_add_mon_plugin TARGET_NAME) $<$:QT_NO_DEBUG> $<$:QT_NO_DEBUG> ) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_rec_addon TARGET_NAME) @@ -123,7 +123,7 @@ function(ecal_add_rec_addon TARGET_NAME) OUTPUT_NAME ecal_${TARGET_NAME} RUNTIME_OUTPUT_DIRECTORY $,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$/ecalrec_addons,${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ecal/addons/rec> ) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_time_plugin TARGET_NAME) @@ -132,7 +132,7 @@ function(ecal_add_time_plugin TARGET_NAME) VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} ) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_shared_library TARGET_NAME) @@ -141,7 +141,7 @@ function(ecal_add_shared_library TARGET_NAME) VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} OUTPUT_NAME ecal_${TARGET_NAME}) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_static_library TARGET_NAME) @@ -152,7 +152,7 @@ function(ecal_add_static_library TARGET_NAME) OUTPUT_NAME ecal_${TARGET_NAME} POSITION_INDEPENDENT_CODE ON ) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() function(ecal_add_interface_library TARGET_NAME) @@ -173,6 +173,6 @@ function(ecal_add_sample TARGET_NAME) VERSION ${eCAL_VERSION_STRING} SOVERSION ${eCAL_VERSION_MAJOR} OUTPUT_NAME ecal_sample_${TARGET_NAME}) - ecal_add_compiler_warnings(${TARGET_NAME}) + ecal_add_compiler_flags(${TARGET_NAME}) endfunction() diff --git a/ecal/service/CMakeLists.txt b/ecal/service/CMakeLists.txt index 5ab8f3b249..9a1a2bdf16 100644 --- a/ecal/service/CMakeLists.txt +++ b/ecal/service/CMakeLists.txt @@ -19,10 +19,10 @@ cmake_minimum_required(VERSION 3.16) project(ecal_service) -if(TARGET _ecal_warnings) - # _ecal_warnings is the internal eCAL target containing the warning flags +if(TARGET _ecal_compiler_args) + # _ecal_compiler_args is the internal eCAL target containing the warning flags # and will be absent if this is being built standalone - add_library(_ecal_service_warnings ALIAS _ecal_warnings) + add_library(_ecal_service_warnings ALIAS _ecal_compiler_args) else() # Otherwise, use a fallback implementation if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")