From 888ba08569ee0f167410cdd5145b3c2ad14faf08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 2 Mar 2023 12:34:16 +0100 Subject: [PATCH] CMake: make it possible to use _ROOT to locate dependencies. --- CMakeLists.txt | 5 +++++ doc/building.dox | 10 +++++++--- doc/changelog.dox | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75d5d4431..07dccb01b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,11 @@ endif() if(POLICY CMP0071) cmake_policy(SET CMP0071 NEW) endif() +# Allow _ROOT to be used on 3.12+ to point to per-package install +# locations that find_package(PackageName) subsequently picks up +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() # Superprojects can use just set(MAGNUM_WITH_BLAH ON) without FORCE CACHE on # 3.13+ if(POLICY CMP0077) diff --git a/doc/building.dox b/doc/building.dox index df3a11e8f..6e4ab0696 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -371,7 +371,9 @@ See @ref building-features "below" for additional configuration options. If you have the dependencies installed in non-standard location (other than `/usr`, e.g. `/home/xyz/projects`), set `CMAKE_PREFIX_PATH` to that directory to help CMake find them. You can enter more different dirs if you separate them -with semicolons. +with semicolons. On CMake 3.12+ you can also use `_ROOT` variables +to point to dependency-specific locations, e.g. +`-DCorrade_ROOT=/home/xyz/projects/corrade-install`. Also, if you plan to install the library to non-standard location, you might want to set `CMAKE_INSTALL_RPATH` to `lib/` subdir of given prefix (e.g. @@ -392,7 +394,7 @@ want to set `CMAKE_INSTALL_RPATH` to `lib/` subdir of given prefix (e.g. On Windows you can use MSVC, clang-cl or the MinGW-w64 compiler. It's then up to you whether you will use QtCreator, Visual Studio or another IDE or do the -build from a command line. Note that for most convenient usage it's best use +build from a command line. Note that for most convenient usage it's best to use some dedicated directory (e.g. `C:/Sys`) for installing dependencies instead of putting each dependency to its own directory in `C:/Program Files` or elsewhere. Then you can just add its `bin/` subdir (e.g. `C:/Sys/bin`) to @@ -403,7 +405,9 @@ prepared for exactly this. Then, when running CMake, set `CMAKE_PREFIX_PATH` and `CMAKE_INSTALL_PREFIX` value to that directory (e.g. `-DCMAKE_INSTALL_PREFIX=C:/Sys`). If you have dependencies scattered across multiple locations, enter them into -`CMAKE_PREFIX_PATH` separated with semicolons. +`CMAKE_PREFIX_PATH` separated with semicolons. On CMake 3.12+ you can also +use `_ROOT` variables to point to dependency-specific locations, +e.g. `-DCorrade_ROOT=C:/projects/corrade-install`. @subsubsection building-windows-msvc Using Visual Studio diff --git a/doc/changelog.dox b/doc/changelog.dox index a648eafc0..59956f611 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -733,6 +733,9 @@ See also: - @ref Trade::ObjImporter "ObjImporter" uses exceptions internally and needs an explicit exception-enabling flag when built with Emscripten 1.39.0 and newer +- It's now possible to use `_ROOT` to point to install locations + of dependencies such as Corrade on CMake 3.12+, in addition to putting them + all together inside `CMAKE_PREFIX_PATH`. See also [mosra/magnum#614](https://github.com/mosra/magnum/issues/614). - On CMake 3.16 and newer, `FindMagnum.cmake` can provide additional details if some component is not found. - The Homebrew package now uses `std_cmake_args` instead of hardcoded build