Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line equivalent of cmake's find_package?

Tags:

cmake

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)?

like image 700
Phonon Avatar asked Mar 04 '15 19:03

Phonon


People also ask

What does Find_package do in CMake?

CMake searches for a file called Find<package>. cmake in the CMAKE_MODULE_PATH followed by the CMake installation. If the file is found, it is read and processed by CMake. It is responsible for finding the package, checking the version, and producing any needed messages.

Where does Find_package look CMake?

CMake ships with its own set of built-in find_package scripts, and their location is in the default CMAKE_MODULE_PATH.

Where is CMake path in Windows?

CMake maintains a list of package information in the Windows registry under HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\ . Packages build from source can register there using the export command. Other projects build later on the same machine will then be able to find that package without additional configuration.

Where are CMake modules stored?

Using Modules For CMake, these sections are called cmake-modules and can be found in the Modules subdirectory of your installation.


Video Answer


1 Answers

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
like image 166
wfr Avatar answered Oct 26 '22 06:10

wfr