cmake_find_packagegenerator.Go to Integrations/CMake if you want to learn how to integrate your project or recipes with CMake.
Cmake Find_library Example
Command findpackage has two modes: Module mode and Config mode. You are trying to use Module mode when you actually need Config mode. Find.cmake file located within your project.
- Just to give you more insight on this and add details on top of Juan's answer, CMake will only able to find libraries with the.lib extension because it is what you are supposed to link against. And CMake explicitly defines that in the following file.
- Basic CMake, part 2: libraries By Martin Hořeňovský Jun 2nd 2018 Tags: CMake, Tutorial, C. My previous post about CMake provided a simple CMakeLists.txt for a small, self-contained, project. In practice, very few projects are fully self-contained, as they either depend on external libraries or are themselves libraries that other projects depend on.
- CMAKE linker does not find library; but library is found with findlibrary Hot Network Questions Cat stool sample collection in household with two cats.
cmake_find_package generator creates a file for each requirement specified in the conanfile.
The name of the files follow the pattern
Find<PKG-NAME>.cmake. So for the
Findasio.cmake file will be generated.
Variables in Find<PKG-NAME>.cmake¶
<PKG-NAME> the package name used in the reference (by default) or the one declared in
cpp_info.name or in
cpp_info.names['cmake_find_package'] if specified:
Cmake Find_library Debug
|<PKG-NAME>_FOUND||Set to 1|
|<PKG-NAME>_INCLUDE_DIRS||Containing all the include directories of the package|
|<PKG-NAME>_INCLUDES||Same as the XXX_INCLUDE_DIRS|
|<PKG-NAME>_DEFINITIONS||Definitions of the library|
|<PKG-NAME>_LIBS||Library paths to link|
|<PKG-NAME>_LIBRARIES||Same as <PKG-NAME>_LIBS|
|<PKG-NAME>_BUILD_MODULES||List of CMake module files with functionalities for consumers|
|<PKG-NAME>_SYSTEM_LIBS||System libraries to link|
|<PKG-NAME>_FRAMEWORKS||Framework names to do a find_library()|
|<PKG-NAME>_FRAMEWORKS_FOUND||Found frameworks to link with after find_library()|
|<PKG-NAME>_FRAMEWORK_DIRS||Framework directories to perform the find_library() of <PKG-NAME>_FRAMEWORKS|
This file uses <PKG-NAME>_BUILD_MODULES values to include the files using the include(…) CMake directive after the targets arecreated. This makes functions or utilities exported by the package available for consumers just by setting find_package(<PKG-NAME>) in theCMakeLists.txt.
Moreover, this also adjusts CMAKE_MODULE_PATH and CMAKE_PREFIX_PATH to the values declared by the package in
cpp_info.buildirs, somodules in those directories can be found.
Cmake Find_library Usage
Targets in Find<PKG-NAME>.cmake¶
A target named
<PKG-NAME>::<PKG-NAME> target is generated with the following properties adjusted:
INTERFACE_INCLUDE_DIRECTORIES: Containing all the include directories of the package.
INTERFACE_LINK_LIBRARIES: Library paths to link.
INTERFACE_COMPILE_DEFINITIONS: Definitions of the library.
The targets are transitive. So, if your project depends on a packages
B, and at the same time
A depends on
A target will contain automatically the properties of the
C dependency, soin your CMakeLists.txt file you only need to
If a recipe uses components, the targets generated will be
<PKG-NAME>::<COMP-NAME> with the following properties adjusted:
INTERFACE_INCLUDE_DIRECTORIES: Containing all the include directories of the component.
INTERFACE_LINK_DIRECTORIES: Containing all the lib directories of the component.
INTERFACE_LINK_LIBRARIES: Containing the targets to link the component to (includes component’s libraries and dependencies).
INTERFACE_COMPILE_DEFINITIONS: Containing the definitions of the component.
INTERFACE_COMPILE_OPTIONS: Containing the compile options of the component.
Moreover, a global target
<PKG-NAME>::<PKG-NAME> will be declared with the following properties adjusted:
INTERFACE_LINK_LIBRARIES: Containing all the component targets to link the global target to (includes package’s components only).
Name conflicts: If the name of the global target is the same for different packages, Conan will aggregate into this global targetall the components from all those different packages. This means that this global target will contain information coming from differentpackages. For the components themselves, a name conflict will result in one of them being inaccessible without further notice.