[CMake] Which to use: find_file and find_library; or check_include_file and check_library_exists

Alexander Neundorf a.neundorf-work at gmx.net
Wed Apr 22 16:08:10 EDT 2009


On Wednesday 22 April 2009, Marcel Loose wrote:
> Hi Alex,
>
> So if I understand it correctly:
> The find_file() and find_library() commands should be used in
> FindXXX.cmake files; the check_include_file() and check_library_exists()
> command can in fact only be used in CMakeLists.txt files.
> Right? Or am I seeing things too black-and-white?

Yes.
The Find-modules are basically included in the CMakeLists.txt, i.e. there is 
not difference for the commands. I.e. both find_xxx() and 
check_something_exists() work the same way whether it's directly in 
CMakeLists.txt or in some Find-module.

So, if you are searching for a library in a find-module, you really should use 
find_library(). Once you found it, you may want to check whether this library 
contains some specific function, then you can use check_symbol_exists() or 
something like this with the library you just found.

Alex


More information about the CMake mailing list