2

I know that if I want CMake to find my custom FindBlabla.cmake file I can put the path leading to it to CMAKE_MODULE_PATH variable. But what if have a BlablaConfig.cmake file and want to tell CMake where it's located. I know also I can set -DBlabla_DIR=/path/to/BlablaConfig.cmake flag and I'll get what I want. But what if I have several such config files? I would like to avoid setting *_DIR variables for each of them.

To be more concrete we can consider the example of Qt config files. If I have e.g. Gentoo and install qt5 from Portage then the config files will be put to /usr/lib/cmake/Qt5*/Qt5*Config.cmake and CMake will be able to find it by default. But if I build qt5 from sources and install it to /usr/local/Qt-some.version then I have to tell CMake where to find those config files since /usr/local/Qt-some.version/lib/cmake/Qt5*/Qt5*.Config.cmake files are not visible to CMake by default.

Any ideas?

krokoziabla
  • 695
  • 1
  • 6
  • 21

1 Answers1

1

Setting CMAKE_PREFIX_PATH variable affects on all packages:

set(CMAKE_PREFIX_PATH "/usr/local/Qt-some.version")
...
find_package(Qt5) # This will firstly consult "/usr/local/Qt-some.version" path.

See also my answer to related question about hinting to FindXXX.cmake scripts.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153