Refactor: add_goby_executable and add_goby_library CMake functions in GobyTarget.cmake, replace protobuf_generate_cpp_dccl#36
Conversation
…p_dccl Agent-Logs-Url: https://github.com/GobySoft/goby3-examples/sessions/1bb95bbd-d7a1-41b8-99ec-01bdd2fa1a1b Co-authored-by: tsaubergine <732276+tsaubergine@users.noreply.github.com>
…ariable name in gps_driver Agent-Logs-Url: https://github.com/GobySoft/goby3-examples/sessions/1bb95bbd-d7a1-41b8-99ec-01bdd2fa1a1b Co-authored-by: tsaubergine <732276+tsaubergine@users.noreply.github.com>
tsaubergine
left a comment
There was a problem hiding this comment.
Please fix failing build. Also do something similar for the libraries (add_goby_library function)
…, add add_goby_library Agent-Logs-Url: https://github.com/GobySoft/goby3-examples/sessions/6a9e9ae6-5731-4b98-9887-cc0af1167fbd Co-authored-by: tsaubergine <732276+tsaubergine@users.noreply.github.com>
Fixed in 7c90421. Build failures: The root cause was
|
There was a problem hiding this comment.
Please rename to GobyTarget.cmake
There was a problem hiding this comment.
Done in 8303e61 — cmake/GobyApp.cmake renamed to cmake/GobyTarget.cmake and the include(GobyApp) in the root updated to include(GobyTarget).
| target_link_libraries(amac_simple goby ${Boost_LIBRARIES} ${PROTOBUF_LIBRARIES}) | ||
| add_goby_executable(TARGET amac_simple | ||
| SOURCES amac_simple.cpp) | ||
| install(TARGETS amac_simple RUNTIME DESTINATION bin) |
There was a problem hiding this comment.
Add the install to the add_goby_executable function (for all excecutables)
There was a problem hiding this comment.
Done in 8303e61 — install(TARGETS ${args_TARGET} RUNTIME DESTINATION bin) added to add_goby_executable, and the 9 individual install(...) lines removed from the per-target CMakeLists.txt files.
CMakeLists.txt
Outdated
| @@ -9,20 +9,18 @@ if(((NOT DEFINED CMAKE_CXX_STANDARD) OR ("${CMAKE_CXX_STANDARD}" STREQUAL "03") | |||
| message ("Setting CMAKE_CXX_STANDARD to 17 as required by Goby. If you wish to use a newer standard, set CMAKE_CXX_STANDARD directly") | |||
| endif() | |||
There was a problem hiding this comment.
Write this more concisely if possible
There was a problem hiding this comment.
Done in 8303e61 — simplified to:
if(NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17)…cutable, simplify CXX_STANDARD check Agent-Logs-Url: https://github.com/GobySoft/goby3-examples/sessions/0063b641-6e58-4ecb-8477-a394964c9b24 Co-authored-by: tsaubergine <732276+tsaubergine@users.noreply.github.com>
Summary
Introduces a new
cmake/GobyTarget.cmakefile withadd_goby_executableandadd_goby_libraryconvenience functions that consolidate the repetitive boilerplate used for every binary and library target in the project. Replaces the customprotobuf_generate_cpp_dcclwith directadd_custom_commandcalls replicating the same--cpp_out + --dccl_outprotoc invocation, and removesFindProtobufLocal.cmakein favor of CMake's standardfind_package(Protobuf REQUIRED).Changes
New
cmake/GobyTarget.cmakeDefines two public functions and one internal helper:
add_goby_executable— build a Goby application binary (linking againstgobyand installing tobinare both implied):add_goby_library— build a Goby library target (SHARED by default; passSTATICorMODULEto change):Both functions accept
TARGET,SOURCES,PROTOS,LINK_LIBRARIES,PROTO_IMPORT_DIRS, andPROTOC_OUT_DIR. Proto files are compiled via an internal_goby_generate_protoshelper that issuesadd_custom_commandwith:This matches the original
protobuf_generate_cpp_dcclinvocation pattern exactly, ensuring DCCL's insertion-point mechanism works correctly across all supported distros.add_goby_executablealso callsgenerate_interfaces()automatically whenexport_goby_interfacesis ON, and automatically installs the target tobin.cmake/FindProtobufLocal.cmakeReplaced with a stub comment. All its custom functions (
PROTOBUF_GENERATE_CPP_DCCL,PROTOBUF_INCLUDE_DIRS) are removed.Root
CMakeLists.txtcmake_minimum_requiredto 3.13find_package(ProtobufLocal)withfind_package(Protobuf REQUIRED)GOBY_PROTOBUF_IMPORT_DIRSvariable (global protoc import paths used by both functions)include(GobyTarget)CMAKE_CXX_STANDARDguard toif(NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17)All binary
CMakeLists.txtfiles (30+)Every
add_executable+ proto codegen +target_link_libraries+install+generate_interfacesblock replaced with a singleadd_goby_executable(...)call.Library
CMakeLists.txtfilessrc/messages/,src/components/acomms/modemdriver/pluggable_driver/,src/components/moos/gobyexample_protobuf/, andgps_moos_pluginupdated to useadd_goby_library.Before / After Example
Before:
After: