diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index a61d2c8..9e9ed22 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -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 diff --git a/generate_parameter_library/cmake/generate_parameter_library.cmake b/generate_parameter_library/cmake/generate_parameter_library.cmake index 3211036..6d5f66d 100644 --- a/generate_parameter_library/cmake/generate_parameter_library.cmake +++ b/generate_parameter_library/cmake/generate_parameter_library.cmake @@ -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") @@ -53,7 +53,7 @@ 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) @@ -61,10 +61,10 @@ function(generate_parameter_library LIB_NAME YAML_FILE) # 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 can be used in the local package (deprecated) @@ -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)