aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Antonio Sanchez <cantonios@google.com>2021-07-02 13:03:30 -0700
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2021-07-07 17:24:57 +0000
commitf44f05532decf830fcdb07e2a67a2fa4ccbc3870 (patch)
tree27c3fc9254673a1371b64ccfa6aa288b6278410e
parentf5a9873bbb5488bcba3e37f92b4ec09a8db76081 (diff)
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.
-rw-r--r--CMakeLists.txt11
1 files 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()