Skip to content

Conversation

traversaro
Copy link
Member

@traversaro traversaro commented May 26, 2025

This parameter can be used to (optionally) generate the files related to device param parser in an arbitrary location. This is typically used to generate the files in the build directory instead of the source one, removing the need of committing generate files in the repo, avoiding problems such as the one discussed in icub-tech-iit/ergocub-software#310 and #3225 (comment) .

The change is completely backward compatible, and an example of its use can be found in traversaro/ergocub-software@d811e32, from which this snippet is extracted:

yarp_prepare_plugin(couplingXCubHandMk5
                    CATEGORY device
                    TYPE CouplingXCubHandMk5
                    INCLUDE CouplingXCubHandMk5.h
                    GENERATE_PARSER
                    GENERATE_PARSER_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}
                    DEFAULT ON)

if(ENABLE_couplingXCubHandMk5)
  yarp_add_plugin(yarp_couplingXCubHandMk5)

  if(MSVC)
    add_definitions(-D_USE_MATH_DEFINES)
  endif()

  target_sources(yarp_couplingXCubHandMk5 PRIVATE CouplingXCubHandMk5.cpp
                                                  CouplingXCubHandMk5.h
                                                  CouplingXCubHandMk5_ParamsParser.cpp
                                                  CouplingXCubHandMk5_ParamsParser.h)
                                                  ${CMAKE_CURRENT_BINARY_DIR}/CouplingXCubHandMk5_ParamsParser.cpp
                                                  ${CMAKE_CURRENT_BINARY_DIR}/CouplingXCubHandMk5_ParamsParser.h)

  target_include_directories(yarp_couplingXCubHandMk5 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

I am aware that there is currently a PR freeze (see #3227 (comment)), but I preferred to open a PR before I moved to work on something else, to avoid forgetting about it, so that the PR will be ready once the PR will be accepted again.

fyi @pattacini @Nicogene @PeterBowman @MSECode

@randaz81 randaz81 force-pushed the supportarbitrarylocationforparamparsergen branch from 04e4b7f to 65b9270 Compare May 27, 2025 07:48
@randaz81 randaz81 temporarily deployed to code-analysis May 27, 2025 07:49 — with GitHub Actions Inactive
@randaz81 randaz81 temporarily deployed to code-analysis May 27, 2025 07:50 — with GitHub Actions Inactive
@randaz81 randaz81 force-pushed the supportarbitrarylocationforparamparsergen branch from 65b9270 to c2e4368 Compare May 29, 2025 22:30
@randaz81 randaz81 temporarily deployed to code-analysis May 29, 2025 23:29 — with GitHub Actions Inactive
This parameter can be used to (optionally) generate the files related to device param
parser in an arbitrary location. This is tipically used to generate the files
in the build directory instead of the source one, removing the need of committing
generate files in the repo.
@randaz81 randaz81 force-pushed the supportarbitrarylocationforparamparsergen branch from c2e4368 to 64c6ca0 Compare June 4, 2025 21:40
@randaz81 randaz81 temporarily deployed to code-analysis June 4, 2025 21:42 — with GitHub Actions Inactive
@randaz81 randaz81 temporarily deployed to code-analysis June 4, 2025 21:42 — with GitHub Actions Inactive
Copy link

sonarqubecloud bot commented Jun 4, 2025

@PeterBowman
Copy link
Member

PeterBowman commented Jul 21, 2025

While I like this idea, I have also realized that those .h and .cpp files will (still) be regenerated on every CMake run, thus updating the generation timestamp in the header, thus forcing recompilation of all devices that use this mechanism. Would it be possible to only regenerate/compile them when changes are applied to the .md file?

Edit: since I am implementing icub-tech-iit/ergocub-software#310 as a workaround for YARP 3.12, I forgot that (in the usual scenario) generation would be enabled explicitly via setting ALLOW_DEVICE_PARAM_PARSER_GENERATION to ON, that is, only when we want to force regeneration of said files. Please ignore my previous question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants