From 8eca9eeadb8709a88943db6b4d460b54f68ee67f Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 11 May 2023 20:42:34 +0000 Subject: [PATCH] Move everything that depends on message definitions to "compiled" Signed-off-by: Michael Carroll --- {core/src => compiled}/Factory_TEST.cc | 0 .../PointCloudPackedUtils_TEST.cc | 0 {core/src => compiled}/Utility_TEST.cc | 0 {core/src => compiled}/cmd/CMakeLists.txt | 0 {core/src => compiled}/cmd/cmdmsgs.rb.in | 0 .../cmd/msgs.bash_completion.sh | 0 {core/src => compiled}/gz.cc | 0 {core/src => compiled}/gz.hh | 0 core/src/CMakeLists.txt | 222 ------------------ 9 files changed, 222 deletions(-) rename {core/src => compiled}/Factory_TEST.cc (100%) rename {core/src => compiled}/PointCloudPackedUtils_TEST.cc (100%) rename {core/src => compiled}/Utility_TEST.cc (100%) rename {core/src => compiled}/cmd/CMakeLists.txt (100%) rename {core/src => compiled}/cmd/cmdmsgs.rb.in (100%) rename {core/src => compiled}/cmd/msgs.bash_completion.sh (100%) rename {core/src => compiled}/gz.cc (100%) rename {core/src => compiled}/gz.hh (100%) diff --git a/core/src/Factory_TEST.cc b/compiled/Factory_TEST.cc similarity index 100% rename from core/src/Factory_TEST.cc rename to compiled/Factory_TEST.cc diff --git a/core/src/PointCloudPackedUtils_TEST.cc b/compiled/PointCloudPackedUtils_TEST.cc similarity index 100% rename from core/src/PointCloudPackedUtils_TEST.cc rename to compiled/PointCloudPackedUtils_TEST.cc diff --git a/core/src/Utility_TEST.cc b/compiled/Utility_TEST.cc similarity index 100% rename from core/src/Utility_TEST.cc rename to compiled/Utility_TEST.cc diff --git a/core/src/cmd/CMakeLists.txt b/compiled/cmd/CMakeLists.txt similarity index 100% rename from core/src/cmd/CMakeLists.txt rename to compiled/cmd/CMakeLists.txt diff --git a/core/src/cmd/cmdmsgs.rb.in b/compiled/cmd/cmdmsgs.rb.in similarity index 100% rename from core/src/cmd/cmdmsgs.rb.in rename to compiled/cmd/cmdmsgs.rb.in diff --git a/core/src/cmd/msgs.bash_completion.sh b/compiled/cmd/msgs.bash_completion.sh similarity index 100% rename from core/src/cmd/msgs.bash_completion.sh rename to compiled/cmd/msgs.bash_completion.sh diff --git a/core/src/gz.cc b/compiled/gz.cc similarity index 100% rename from core/src/gz.cc rename to compiled/gz.cc diff --git a/core/src/gz.hh b/compiled/gz.hh similarity index 100% rename from core/src/gz.hh rename to compiled/gz.hh diff --git a/core/src/CMakeLists.txt b/core/src/CMakeLists.txt index 456ed535..e8c728ae 100644 --- a/core/src/CMakeLists.txt +++ b/core/src/CMakeLists.txt @@ -1,215 +1,9 @@ -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -################################################## -# A function that calls protoc on a protobuf file -# Options: -# GENERATE_RUBY - generates ruby code for the message if specified -# GENERATE_CPP - generates c++ code for the message if specified -# One value arguments: -# PROTO_PACKAGE - Protobuf package the file belongs to (e.g. ".gz.msgs") -# PROTOC_EXEC - Path to protoc -# INPUT_PROTO - Path to the input .proto file -# OUTPUT_CPP_DIR - Path where C++ files are saved -# OUTPUT_RUBY_DIR - Path where Ruby files are saved -# OUTPUT_INCLUDES - A CMake variable name containing a list that the C++ header path should be appended to -# OUTPUT_CPP_HH_VAR - A CMake variable name containing a list that the C++ header path should be appended to -# OUTPUT_GZ_CPP_HH_VAR - A CMake variable name containing a list that the C++ header path should be appended to -# OUTPUT_CPP_CC_VAR - A Cmake variable name containing a list that the C++ source path should be appended to -# OUTPUT_RUBY_VAR - A Cmake variable name containing a list that the ruby file should be apenned to -# Multi value arguments -# PROTO_PATH - Passed to protoc --proto_path -function(gz_msgs_protoc) - set(options GENERATE_RUBY GENERATE_CPP) - set(oneValueArgs - PROTO_PACKAGE - PROTOC_EXEC - INPUT_PROTO - OUTPUT_CPP_DIR - OUTPUT_RUBY_DIR - OUTPUT_INCLUDES - OUTPUT_CPP_HH_VAR - OUTPUT_GZ_CPP_HH_VAR - OUTPUT_DETAIL_CPP_HH_VAR - OUTPUT_CPP_CC_VAR - OUTPUT_RUBY_VAR) - set(multiValueArgs PROTO_PATH) - - cmake_parse_arguments(gz_msgs_protoc "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - get_filename_component(ABS_FIL ${gz_msgs_protoc_INPUT_PROTO} ABSOLUTE) - get_filename_component(FIL_WE ${gz_msgs_protoc_INPUT_PROTO} NAME_WE) - - set(protoc_args) - set(output_files) - - set(proto_package_dir ".") - if(gz_msgs_protoc_PROTO_PACKAGE) - string(REPLACE "." "/" proto_package_dir ${gz_msgs_protoc_PROTO_PACKAGE}) - endif() - - if(gz_msgs_protoc_GENERATE_CPP) - # Full path to generated header (${PROJECT_BINARY_DIR}/include/gz/msgs/foo.pb.h) - set(output_header "${gz_msgs_protoc_OUTPUT_CPP_DIR}${proto_package_dir}/${FIL_WE}.pb.h") - # Full path to generated detail header (${PROJECT_BINARY_DIR}/include/gz/msgs/details/foo.pb.h) - set(output_detail_header "${gz_msgs_protoc_OUTPUT_CPP_DIR}${proto_package_dir}/details/${FIL_WE}.pb.h") - # Full path to generated source (${PROJECT_BINARY_DIR}/include/foo.pb.cc) - set(output_source "${gz_msgs_protoc_OUTPUT_CPP_DIR}${proto_package_dir}/${FIL_WE}.pb.cc") - - # Generate a clean relative path (gz/msgs/foo.pb.h) - string(REPLACE "${PROJECT_BINARY_DIR}/include/" "" output_include ${output_header}) - list(APPEND ${gz_msgs_protoc_OUTPUT_INCLUDES} "${output_include}") - - list(APPEND ${gz_msgs_protoc_OUTPUT_CPP_HH_VAR} ${output_header}) - list(APPEND ${gz_msgs_protoc_OUTPUT_CPP_CC_VAR} ${output_source}) - list(APPEND ${gz_msgs_protoc_OUTPUT_GZ_CPP_HH_VAR} ${output_ign_header}) - list(APPEND ${gz_msgs_protoc_OUTPUT_DETAIL_CPP_HH_VAR} ${output_detail_header}) - - list(APPEND output_files ${output_header}) - list(APPEND output_files ${output_detail_header}) - list(APPEND output_files ${output_ign_header}) - list(APPEND output_files ${output_source}) - - set(${gz_msgs_protoc_OUTPUT_INCLUDES} ${${gz_msgs_protoc_OUTPUT_INCLUDES}} PARENT_SCOPE) - set(${gz_msgs_protoc_OUTPUT_GZ_CPP_HH_VAR} ${${gz_msgs_protoc_OUTPUT_GZ_CPP_HH_VAR}} PARENT_SCOPE) - set(${gz_msgs_protoc_OUTPUT_DETAIL_CPP_HH_VAR} ${${gz_msgs_protoc_OUTPUT_DETAIL_CPP_HH_VAR}} PARENT_SCOPE) - set(${gz_msgs_protoc_OUTPUT_CPP_HH_VAR} ${${gz_msgs_protoc_OUTPUT_CPP_HH_VAR}} PARENT_SCOPE) - set(${gz_msgs_protoc_OUTPUT_CPP_CC_VAR} ${${gz_msgs_protoc_OUTPUT_CPP_CC_VAR}} PARENT_SCOPE) - endif() - - if(gz_msgs_protoc_GENERATE_RUBY) - file(MAKE_DIRECTORY ${gz_msgs_protoc_OUTPUT_RUBY_DIR}) - set(output_ruby "${gz_msgs_protoc_OUTPUT_RUBY_DIR}${proto_package_dir}/${FIL_WE}_pb.rb") - list(APPEND ${gz_msgs_protoc_OUTPUT_RUBY_VAR} ${output_ruby}) - list(APPEND output_files ${output_ruby}) - list(APPEND protoc_args "--ruby_out=${gz_msgs_protoc_OUTPUT_RUBY_DIR}") - set(${gz_msgs_protoc_OUTPUT_RUBY_VAR} ${${gz_msgs_protoc_OUTPUT_RUBY_VAR}} PARENT_SCOPE) - endif() - - - set(GENERATE_ARGS - --protoc-exec "$" - --gz-generator-bin "${GZ_MSGS_GEN_EXECUTABLE}" - --proto-path "${gz_msgs_protoc_PROTO_PATH}" - --input-path "${ABS_FIL}" - ) - - if(${gz_msgs_protoc_GENERATE_CPP}) - list(APPEND GENERATE_ARGS - --generate-cpp - --output-cpp-path "${gz_msgs_protoc_OUTPUT_CPP_DIR}") - endif() - - if(${gz_msgs_protoc_GENERATE_RUBY}) - list(APPEND GENERATE_ARGS - --generate-ruby - --output-ruby-path "${gz_msgs_protoc_OUTPUT_RUBY_DIR}") - endif() - - add_custom_command( - OUTPUT ${output_files} - COMMAND Python3::Interpreter - ARGS tools/gz_msgs_generate.py ${GENERATE_ARGS} - DEPENDS - ${ABS_FIL} - gz_msgs_gen - # While the script is executed in the source directory, it does not write - # to the source tree. All outputs are stored in the build directory. - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Running protoc on ${gz_msgs_protoc_INPUT_PROTO}" - VERBATIM - ) - -endfunction() - - -################################################## -file (GLOB proto_files ${PROJECT_SOURCE_DIR}/proto/gz/msgs/*.proto) - -foreach(proto_file ${proto_files}) - gz_msgs_protoc( - PROTO_PACKAGE - .gz.msgs - GENERATE_CPP - GENERATE_RUBY - INPUT_PROTO - ${proto_file} - PROTOC_EXEC - protobuf::protoc - OUTPUT_CPP_DIR - "${PROJECT_BINARY_DIR}/include" - OUTPUT_RUBY_DIR - "${PROJECT_BINARY_DIR}/ruby" - OUTPUT_INCLUDES - gen_includes - OUTPUT_CPP_HH_VAR - gen_headers - OUTPUT_DETAIL_CPP_HH_VAR - gen_detail_headers - OUTPUT_GZ_CPP_HH_VAR - gen_ign_headers - OUTPUT_CPP_CC_VAR - gen_sources - OUTPUT_RUBY_VAR - gen_ruby_scripts - PROTO_PATH - "${PROJECT_SOURCE_DIR}/proto") -endforeach() - -if(NOT MSVC) - # -Wno-switch-default flags is required for suppressing a warning in some of - # the generated protobuf files. - set_source_files_properties(${gen_sources} COMPILE_FLAGS -Wno-switch-default) -endif() - -if(MSVC) - # Warning #4251 is the "dll-interface" warning that tells you when types used - # by a class are not being exported. These generated source files have private - # members that don't get exported, so they trigger this warning. However, the - # warning is not important since those members do not need to be interfaced - # with. - set_source_files_properties(${gen_sources} COMPILE_FLAGS "/wd4251 /wd4146") - # Fix for protobuf 3.12 - allow big object files - add_definitions(/bigobj) -endif() - -set_source_files_properties(${gen_headers} ${gen_ign_headers} ${gen_detail_headers} ${gen_sources} ${gen_ruby_scripts} - PROPERTIES GENERATED TRUE) - -message(STATUS "Installing Ruby messages to ${CMAKE_INSTALL_PREFIX}/${GZ_LIB_INSTALL_DIR}/ruby/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}") -install(FILES ${gen_ruby_scripts} DESTINATION ${CMAKE_INSTALL_PREFIX}/${GZ_LIB_INSTALL_DIR}/ruby/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}) - -# Install gz/msgs -gz_install_includes( - "${GZ_INCLUDE_INSTALL_DIR_POSTFIX}/gz/${GZ_DESIGNATION}" - ${gen_headers}) - -# Install gz/msgs/details -gz_install_includes( - "${GZ_INCLUDE_INSTALL_DIR_POSTFIX}/gz/${IGN_DESIGNATION}/details" - ${gen_detail_headers}) - -################################################## -# Generate gz/msgs/MessageTypes.hh -foreach (hdr ${gen_includes}) - string(CONCAT gz_msgs_headers ${gz_msgs_headers} "#include <${hdr}>\n") -endforeach() - -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/MessageTypes.hh.in - ${PROJECT_BINARY_DIR}/include/gz/msgs/MessageTypes.hh) - -gz_install_includes( - "${GZ_INCLUDE_INSTALL_DIR_POSTFIX}/gz/${GZ_DESIGNATION}" - "${PROJECT_BINARY_DIR}/include/gz/${GZ_DESIGNATION}/MessageTypes.hh") - ################################################## # Build the main library gz_create_core_library(SOURCES - ${gen_sources} Factory.cc MessageFactory.cc DynamicFactory.cc - gz.cc - Utility.cc ) target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} @@ -234,11 +28,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE -Wno-invalid-offsetof) endif() -target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} - PUBLIC - $ - $) - ################################################## # Build unit tests gz_get_libsources_and_unittests(sources gtest_sources) @@ -250,14 +39,3 @@ gz_build_tests(TYPE UNIT LIB_DEPS TINYXML2::TINYXML2 ) - -if (TARGET UNIT_Factory_TEST) - target_compile_definitions(UNIT_Factory_TEST - PRIVATE GZ_MSGS_TEST_PATH="${PROJECT_SOURCE_DIR}/test") -endif() - -################################################## -# gz msgs command -if(NOT WIN32) - add_subdirectory(cmd) -endif()