0 votes
ago by (160 points)
edited ago by

In the limpet physics module of openCARP, the header file ION_IF_datatypes.h (in physics/limpet/src) is automatically generated from imp_list.txt using a Perl script. However, the compilation sometimes failed to generate the file correctly or too late, leading to:

  • fatal error: ION_IF_datatypes.h: No such file or directory

  • undefined reference to ION_* (due to missing or stale definitions)

This happened especially when changes in imp_list.txt were made indirectly or in parallel builds.

1 Answer

0 votes
ago by (160 points)
edited ago by

We fixed this in MR !330 by:

  1. Creating a dedicated generate_ION_IF_datatypes target.

  2. Explicitly declaring its dependency in the limpet build target

  3. Adding ${CMAKE_CURRENT_BINARY_DIR} to the include paths

Here’s the working implementation:

# Path to Perl scripts
set(LIMPET_PERL "${CMAKE_CURRENT_SOURCE_DIR}/src/perl")
set(GENERATED_ION_IF_H "${CMAKE_CURRENT_BINARY_DIR}/ION_IF_datatypes.h")

# Header generation from imp_list.txt
add_custom_command(
  OUTPUT "${GENERATED_ION_IF_H}"
  COMMAND perl -w -I${LIMPET_PERL} ${LIMPET_PERL}/ION_IF.h.pl
  DEPENDS
    ${CMAKE_CURRENT_SOURCE_DIR}/models/imp_list.txt
    ${LIMPET_PERL}/ION_IF.h.pl
    ${LIMPET_PERL}/common.pl
  COMMENT "Generating ION_IF_datatypes.h from imp_list.txt"
  VERBATIM
)

# Always run this target
add_custom_target(generate_ION_IF_datatypes ALL
  DEPENDS "${GENERATED_ION_IF_H}"
)

# Add dependency and include path to limpet
if (TARGET limpet)
  add_dependencies(limpet generate_ION_IF_datatypes)
  target_include_directories(limpet PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
endif()

 that:

  • Ensures the header is always generated before limpet builds

  • Prevents parallel build issues or missing include errors

  • Clean separation of logic; easy to update if the generator script changes in the future


Reference
Implemented and validated in MR !330

Welcome to openCARP Q&A. Ask questions and receive answers from other members of the community. For best support, please use appropriate TAGS!
architecture, carputils, documentation, experiments, installation-containers-packages, limpet, slimfem, website, governance
...