Skip to content

CMake macros should use installed paths instead of relative build/source paths #46

@xmfcx

Description

@xmfcx

Description

The three exported CMake macros use hardcoded relative paths from CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR to locate scripts and resources:

Macro Relative paths used
autoware_system_designer_build_deploy.cmake ${CMAKE_BINARY_DIR}/../autoware_system_designer/script/deployment_process.py, system_designer_runner.py, resource/; ${CMAKE_SOURCE_DIR}/../autoware_system_designer as PYTHONPATH
autoware_system_designer_generate_launcher.cmake ${CMAKE_BINARY_DIR}/../autoware_system_designer/script/generate_node_launcher.py, system_designer_runner.py
autoware_system_designer_parameter.cmake ${CMAKE_BINARY_DIR}/../autoware_system_designer/script/parameter_process.py, system_designer_runner.py

This assumes the autoware_system_designer source and build trees coexist as siblings of the consuming package at build time. This breaks when:

  • Staged Docker builds clean build artifacts between stages (e.g., via build_and_clean.sh), so the build directory no longer exists when a downstream package tries to use the macro
  • The package is pre-installed (e.g., from a debian/apt package)
  • Someone builds with --packages-select <consumer> without autoware_system_designer in the same workspace

Suggested fix

Install the scripts to the package's share directory, then derive the path in the -extras.cmake from the installed find_package result. For example:

# In CMakeLists.txt - install scripts
install(DIRECTORY script/ DESTINATION share/${PROJECT_NAME}/script)

# In the exported cmake macros
set(SYSTEM_DESIGNER_RUNNER_SCRIPT "${autoware_system_designer_DIR}/../../share/autoware_system_designer/script/system_designer_runner.py")

This works from both the colcon workspace build and the install space.

🎗️ In summary, the constraint is that Package A is not allowed to require the build folder of the dependency Package B.

Context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions