Index: lib/MsgUtils/cmake/MsgUtils.cmake =================================================================== diff -u -r402926738e7394ee2d3dc7add2e6d755f06a289d -r8165b9eb5d23253e5d38b6ffde9d1a21cb1cbc52 --- lib/MsgUtils/cmake/MsgUtils.cmake (.../MsgUtils.cmake) (revision 402926738e7394ee2d3dc7add2e6d755f06a289d) +++ lib/MsgUtils/cmake/MsgUtils.cmake (.../MsgUtils.cmake) (revision 8165b9eb5d23253e5d38b6ffde9d1a21cb1cbc52) @@ -57,6 +57,34 @@ ) endfunction() +# \brief This function custom command to generate/update a message handling INI. +# \param[in] _input_confs list of message conf files to use to generate the INI +# \param[in] _output_ini path to the INI file to create or update +# \param[in] _target_name name of the custom target to add +function(generate_message_ini _input_confs _output_ini _target_name) + find_package(Python3 COMPONENTS Interpreter Development REQUIRED) + + # cmake >= 3.20: cmake_path(ABSOLUTE_PATH _output_ini) + get_filename_component(_output_ini ${_output_ini} ABSOLUTE) # cmake < 3.20 + + # generate a pretty string containing a list of the absolute paths of all conf files + foreach(_path ${${_input_confs}}) + # cmake >= 3.20: cmake_path(ABSOLUTE_PATH _path) + get_filename_component(_path ${_path} ABSOLUTE) + list(APPEND _files ${_path}) + endforeach() + list(JOIN _files ", " _file_list) + + add_custom_target(${_target_name} + COMMAND + ${PROJECT_PYTHON} ${MSGUTILS_SCRIPTS_DIR}/GenerateMsgIni.py + ${${_input_confs}} + ${_output_ini} + COMMENT "Generating/updating LeahiRt message INI ${_output_ini} from input ${_file_list}" + VERBATIM + ) +endfunction() + # \brief This function adds a custom command to generate a Protobuf file from inputted message conf files # \param[in] _input_confs list of message conf files to use to generate the header # \param[in] _protobuf_filename name of the generated protobuf file