Reputation: 12737
I'm debugging a cmake file which fails to find certain packages (using find_package()
). What does find_package()
actually do when it searches for packages, and can I simulate it with a command line call (without invoking cmake)?
Upvotes: 21
Views: 10844
Reputation: 701
1. What find_package does:
From the documentation of find_package():
CMake searches for a file called Find.cmake in the CMAKE_MODULE_PATH followed by the CMake installation. If the file is found, it is read and processed by CMake.
On Linux, the default scripts usually are located here:
ls /usr/share/cmake*/Modules/Find*.cmake
2. How to use find_package on the command-line:
# cmake --find-package -DNAME=Boost -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=EXIST
Boost found
# cmake --find-package -DNAME=Boost -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=COMPILE
-I/usr/include
# cmake --find-package -DNAME=Boost -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
-rdynamic
Upvotes: 31