From 53d31f363941e1ef1aa85714d840ee5ca59ff5fd Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Tue, 10 Oct 2023 23:37:03 +0200 Subject: [PATCH] Fix CMake error when entire ament projects are added via add_subdirectory (#484) Signed-off-by: Silvio Traversaro --- .../cmake/environment_hooks/ament_environment_hooks.cmake | 2 +- .../ament_generate_package_environment.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ament_cmake_core/cmake/environment_hooks/ament_environment_hooks.cmake b/ament_cmake_core/cmake/environment_hooks/ament_environment_hooks.cmake index 6eef39cf..bd3d3850 100644 --- a/ament_cmake_core/cmake/environment_hooks/ament_environment_hooks.cmake +++ b/ament_cmake_core/cmake/environment_hooks/ament_environment_hooks.cmake @@ -82,7 +82,7 @@ function(ament_environment_hooks) get_filename_component(hook_basename "${hook}" NAME_WE) if(DEFINED AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_${hook_basename}) # write .dsv file containing the descriptor of the environment hook - set(dsv_file "${CMAKE_BINARY_DIR}/ament_cmake_environment_hooks/${hook_basename}.dsv") + set(dsv_file "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_environment_hooks/${hook_basename}.dsv") file(GENERATE OUTPUT "${dsv_file}" CONTENT "${AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_${hook_basename}}\n") install( FILES "${dsv_file}" diff --git a/ament_cmake_core/cmake/environment_hooks/ament_generate_package_environment.cmake b/ament_cmake_core/cmake/environment_hooks/ament_generate_package_environment.cmake index d7b6bbb4..cfb417fa 100644 --- a/ament_cmake_core/cmake/environment_hooks/ament_generate_package_environment.cmake +++ b/ament_cmake_core/cmake/environment_hooks/ament_generate_package_environment.cmake @@ -102,7 +102,7 @@ function(ament_generate_package_environment) endforeach() endif() list(APPEND all_package_level_extensions "dsv") - set(dsv_file "${CMAKE_BINARY_DIR}/ament_cmake_environment_hooks/local_setup.dsv") + set(dsv_file "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_environment_hooks/local_setup.dsv") file(GENERATE OUTPUT "${dsv_file}" CONTENT "${all_hooks}") install( FILES "${dsv_file}" @@ -111,7 +111,7 @@ function(ament_generate_package_environment) # generate package.dsv file list(SORT all_package_level_extensions) - set(dsv_file "${CMAKE_BINARY_DIR}/ament_cmake_environment_hooks/package.dsv") + set(dsv_file "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_environment_hooks/package.dsv") set(dsv_content "") foreach(ext ${all_package_level_extensions}) set(dsv_content "${dsv_content}source;share/${PROJECT_NAME}/local_setup.${ext}\n")