Skip to content

Commit

Permalink
export target in the macro
Browse files Browse the repository at this point in the history
  • Loading branch information
AugusteBourgois committed Aug 13, 2024
1 parent d169ef2 commit 9c1c6f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ install(
DESTINATION include/generate_parameter_library_example
)

install(TARGETS minimal_publisher admittance_controller_parameters
install(TARGETS minimal_publisher
EXPORT export_generate_parameter_library_example
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# POSSIBILITY OF SUCH DAMAGE.


function(generate_parameter_library LIB_NAME YAML_FILE)
macro(generate_parameter_library LIB_NAME YAML_FILE)
find_program(generate_parameter_library_cpp_BIN NAMES "generate_parameter_library_cpp")
if(NOT generate_parameter_library_cpp_BIN)
message(FATAL_ERROR "generate_parameter_library_cpp() variable 'generate_parameter_library_cpp_BIN' must not be empty")
Expand All @@ -53,18 +53,18 @@ function(generate_parameter_library LIB_NAME YAML_FILE)
endif()

# Set the yaml file parameter to be relative to the current source dir
set(YAML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${YAML_FILE})
set(YAML_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${YAML_FILE})

# Set the output parameter header file name
set(PARAM_HEADER_FILE ${LIB_INCLUDE_DIR}/${LIB_NAME}.hpp)

# Generate the header for the library
add_custom_command(
OUTPUT ${PARAM_HEADER_FILE}
COMMAND ${generate_parameter_library_cpp_BIN} ${PARAM_HEADER_FILE} ${YAML_FILE} ${VALIDATE_HEADER_FILENAME}
DEPENDS ${YAML_FILE} ${VALIDATE_HEADER}
COMMAND ${generate_parameter_library_cpp_BIN} ${PARAM_HEADER_FILE} ${YAML_FILE_PATH} ${VALIDATE_HEADER_FILENAME}
DEPENDS ${YAML_FILE_PATH} ${VALIDATE_HEADER}
COMMENT
"Running `${generate_parameter_library_cpp_BIN} ${PARAM_HEADER_FILE} ${YAML_FILE} ${VALIDATE_HEADER_FILENAME}`"
"Running `${generate_parameter_library_cpp_BIN} ${PARAM_HEADER_FILE} ${YAML_FILE_PATH} ${VALIDATE_HEADER_FILENAME}`"
VERBATIM
)
# necessary so that #include <param_file.hpp> can be used in the local package (deprecated)
Expand Down Expand Up @@ -98,9 +98,10 @@ function(generate_parameter_library LIB_NAME YAML_FILE)
tl_expected::tl_expected
)
install(DIRECTORY ${LIB_INCLUDE_DIR} DESTINATION include)
install(TARGETS ${LIB_NAME} EXPORT ${PROJECT_NAME}Targets)
ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)
ament_export_dependencies(fmt parameter_traits rclcpp rclcpp_lifecycle rsl tcb_span tl_expected)
set(_AMENT_CMAKE_EXPORT_DEPENDENCIES "${_AMENT_CMAKE_EXPORT_DEPENDENCIES}" PARENT_SCOPE)
endfunction()
endmacro()


function(generate_parameter_module LIB_NAME YAML_FILE)
Expand Down

0 comments on commit 9c1c6f3

Please sign in to comment.