From f44f05532decf830fcdb07e2a67a2fa4ccbc3870 Mon Sep 17 00:00:00 2001 From: Antonio Sanchez Date: Fri, 2 Jul 2021 13:03:30 -0700 Subject: Fix CMake directory issues. Allows absolute and relative paths for - `INCLUDE_INSTALL_DIR` - `CMAKEPACKAGE_INSTALL_DIR` - `PKGCONFIG_INSTALL_DIR` Type should be `PATH` not `STRING`. Contrary to !211, these don't seem to be made absolute if user-defined - according to the doc any directories should use `PATH` type, which allows a file dialog to be used via the GUI. It also better handles file separators. If user provides an absolute path, it will be made relative to `CMAKE_INSTALL_PREFIX` so that the `configure_packet_config_file` will work. Fixes #2155 and #2269. --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ba7d3872..bd1af32b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -424,25 +424,26 @@ endif() if(EIGEN_INCLUDE_INSTALL_DIR AND NOT INCLUDE_INSTALL_DIR) set(INCLUDE_INSTALL_DIR ${EIGEN_INCLUDE_INSTALL_DIR} - CACHE STRING "The directory relative to CMAKE_PREFIX_PATH where Eigen header files are installed") + CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen header files are installed") else() set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/eigen3" - CACHE STRING "The directory relative to CMAKE_PREFIX_PATH where Eigen header files are installed" + CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen header files are installed" ) endif() set(CMAKEPACKAGE_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/eigen3/cmake" - CACHE STRING "The directory relative to CMAKE_PREFIX_PATH where Eigen3Config.cmake is installed" + CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen3Config.cmake is installed" ) set(PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig" - CACHE STRING "The directory relative to CMAKE_PREFIX_PATH where eigen3.pc is installed" + CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where eigen3.pc is installed" ) foreach(var INCLUDE_INSTALL_DIR CMAKEPACKAGE_INSTALL_DIR PKGCONFIG_INSTALL_DIR) + # If an absolute path is specified, make it relative to "{CMAKE_INSTALL_PREFIX}". if(IS_ABSOLUTE "${${var}}") - message(FATAL_ERROR "${var} must be relative to CMAKE_PREFIX_PATH. Got: ${${var}}") + file(RELATIVE_PATH "${var}" "${CMAKE_INSTALL_PREFIX}" "${${var}}") endif() endforeach() -- cgit v1.2.3