Skip to content

cmake "file RELATIVE_PATH must be passed a full path to the directory" error #96

Open

Description

@armaho

I tried compiling ros2_rolling from source based on the official tutorial, but I got this error:

CMake Error at CMakeLists.txt:39 (file):
  file RELATIVE_PATH must be passed a full path to the directory:
  lib/urdfdom_headers/cmake

CMake Error at CMakeLists.txt:40 (file):
  file RELATIVE_PATH must be passed a full path to the directory: lib

I was able to compile this project before, and I think that the issue is related to pull request #90. I not completely sure if this happens only on my machine or not. here are the value for related variables:

CMAKE_CONFIG_INSTALL_DIR = lib/urdfdom_headers/cmake
CMAKE_INSTALL_LIBDIR = lib
CMAKE_INSTALL_PREFIX = /home/arman/ros2_rolling/install/urdfdom_headers

Activity

  1. armaho commented on Feb 7, 2026

    @armaho
    Author

    I think the problem was with the assumption that CMAKE_INSTALL_LIBDIR is absolute. I was able to resolve this by changing the following piece of code in cmake:

    if(WIN32 AND NOT CYGWIN)
      set(CMAKE_CONFIG_INSTALL_DIR CMake)
    else()
      set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake)
    endif()

    to:

    if(WIN32 AND NOT CYGWIN)
      set(CMAKE_CONFIG_INSTALL_DIR CMake)
    else()
      if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
        set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
      endif()
      set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake)
    endif()

    I'm not sure if this is the right solution though.

  2. armaho commented on Feb 7, 2026

    @armaho
    Author

    Based on this, it's not recommended to concatenate CMAKE_INSTALL_<dir> to CMAKE_INSTALL_PREFIX manually. So i think the following solution would be better:

    if(WIN32 AND NOT CYGWIN)
      set(CMAKE_CONFIG_INSTALL_DIR CMake)
    else()
      set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/cmake)
    endif()
    file(RELATIVE_PATH RELATIVE_PATH_CMAKE_DIR_TO_PREFIX "${CMAKE_CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}")
    file(RELATIVE_PATH RELATIVE_PATH_LIBDIR_TO_PREFIX "${CMAKE_INSTALL_FULL_LIBDIR}" "${CMAKE_INSTALL_PREFIX}")
  3. rhaschke commented on Feb 7, 2026

    @rhaschke
    Contributor

    I'm running into the same issue:

    -- urdfdom_headers version 2.1.0
    CMake Error at CMakeLists.txt:39 (file):
      file RELATIVE_PATH must be passed a full path to the directory:
      lib/x86_64-linux-gnu/urdfdom_headers/cmake
    
    CMake Error at CMakeLists.txt:40 (file):
      file RELATIVE_PATH must be passed a full path to the directory:
      lib/x86_64-linux-gnu
    

    I think these two lines should only be applied if the path variables actually are absolute:

    file(RELATIVE_PATH RELATIVE_PATH_CMAKE_DIR_TO_PREFIX "${CMAKE_CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}")
    file(RELATIVE_PATH RELATIVE_PATH_LIBDIR_TO_PREFIX "${CMAKE_INSTALL_LIBDIR}" "${CMAKE_INSTALL_PREFIX}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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