user10146018
user10146018

Reputation:

Tell CMake to use custom Find*.cmake instead of system wide one

I wanna use the KWayland library which I compiled from source and installed in a folder. I want my other project to use that. But instead, it uses the one installed system-wide as a dependency of KDE by the package manager.

I tried setting CMAKE_PREFIX_PATH to /path/to/my/cmakefiles;/usr in QtCreator and reconfigured the project, but it still uses the one in /usr.

Upvotes: 1

Views: 113

Answers (1)

Kevin
Kevin

Reputation: 18313

Setting CMAKE_PREFIX_PATH for an example package ABC will look for a package configuration file, which will have one of the following forms for package ABC:

  • abc-config.cmake
  • ABCConfig.cmake

By setting CMAKE_PREFIX_PATH, it does not tell CMake to look elsewhere for a find module (e.g.: FindABC.cmake).

If you installed your package ABC (in your case, KWayland), the installed package should have provided a package configuration file you can use. So point the CMAKE_PREFIX_PATH variable to this file instead:

CMAKE_PREFIX_PATH: /path/to/KWayland/package/config/files

If no package configuration file was provided, you could use a find module (FindABC.cmake) instead to import the package into your project. To tell CMake to look in a non-default location for find modules, you need to update the CMAKE_MODULE_PATH variable instead:

CMAKE_MODULE_PATH: /path/to/my/cmakefiles

Upvotes: 1

Related Questions