cmakeο
This is the reference page for cmake generator.
Go to Integrations/CMake if you want to learn how to integrate your project or recipes with CMake.
It generates a file named conanbuildinfo.cmake and declares some variables and methods.
Variables in conanbuildinfo.cmakeο
- Package declared variables: - For each requirement conanbuildinfo.cmake file declares the following variables. Where - <PKG-NAME>is the placeholder for the name of the require in uppercase (- ZLIBfor- zlib/1.2.8@lasote/stable) in- cpp_info.names["cmake_find_package"]or- cpp_info.names["cmake_find_package_multi"]if specified:- NAME - VALUE - CONAN_<PKG-NAME>_ROOT - Abs path to root package folder. - CONAN_INCLUDE_DIRS_<PKG-NAME> - Headerβs folders - CONAN_LIB_DIRS_<PKG-NAME> - Library folders (default {CONAN_<PKG-NAME>_ROOT}/lib) - CONAN_BIN_DIRS_<PKG-NAME> - Binary folders (default {CONAN_<PKG-NAME>_ROOT}/bin) - CONAN_SRC_DIRS_<PKG-NAME> - Sources folders - CONAN_LIBS_<PKG-NAME> - Library names to link (package libs, system libs and frameworks) - CONAN_PKG_LIBS_<PKG-NAME> - Package library names to link - CONAN_SYSTEM_LIBS_<PKG-NAME> - System library names to link - CONAN_DEFINES_<PKG-NAME> - Library defines - CONAN_COMPILE_DEFINITIONS_<PKG-NAME> - Compile definitions - CONAN_CXX_FLAGS_<PKG-NAME> - CXX flags - CONAN_SHARED_LINK_FLAGS_<PKG-NAME> - Shared link flags - CONAN_C_FLAGS_<PKG-NAME> - C flags - CONAN_FRAMEWORKS_<PKG-NAME> - Frameworks names to use them in find_library() - CONAN_FRAMEWORKS_FOUND_<PKG-NAME> - Frameworks found after using CONAN_FRAMEWORKS in find_library() - CONAN_FRAMEWORK_PATHS_<PKG-NAME> - Framework folders to locate the frameworks (OSX) 
- Global declared variables: - This generator also declares some global variables with the aggregated values of all our requirements. The values are ordered in the right order according to the dependency tree. - NAME - VALUE - CONAN_INCLUDE_DIRS - Aggregated headerβs folders - CONAN_LIB_DIRS - Aggregated library folders - CONAN_BIN_DIRS - Aggregated binary folders - CONAN_SRC_DIRS - Aggregated sources folders - CONAN_LIBS - Aggregated library names to link (with system libs and frameworks) - CONAN_SYSTEM_LIBS - Aggregated system libraries names to link - CONAN_DEFINES - Aggregated library defines - CONAN_COMPILE_DEFINITIONS - Aggregated compile definitions - CONAN_CXX_FLAGS - Aggregated CXX flags - CONAN_SHARED_LINK_FLAGS - Aggregated Shared link flags - CONAN_C_FLAGS - Aggregated C flags - CONAN_FRAMEWORKS - Aggregated frameworks to be found with find_library() (OSX) - CONAN_FRAMEWORKS_FOUND - Aggregated found frameworks after find_library() call (OSX) - CONAN_FRAMEWORK_PATHS - Aggregated framework folders (OSX) - CONAN_BUILD_MODULES - Aggregated paths for build module files (like .cmake) 
- User information declared variables: - If any of the requirements is filling the user_info object in the package_info method a set of variables will be declared following this naming: - NAME - VALUE - CONAN_USER_<PKG-NAME>_<VAR-NAME> - User declared value - Where - <PKG-NAME>means the name of the requirement in uppercase and- <VAR-NAME>the variable name. For example, if this recipe declares:- class MyLibConan(ConanFile): name = "mylib" version = "1.6.0" # ... def package_info(self): self.user_info.var1 = 2 - Other library requiring - myliband using this generator will get:conanbuildinfo.cmakeο- # ... set(CONAN_USER_MYLIB_var1 "2") 
Macros available in conanbuildinfo.cmakeο
conan_basic_setup()ο
This is a helper and general purpose macro that uses all the macros below to set all the CMake variables according to the Conan generated variables. See the macros below for detailed information.
macro(conan_basic_setup)
    set(options TARGETS NO_OUTPUT_DIRS SKIP_RPATH KEEP_RPATHS SKIP_STD SKIP_FPIC)
- Parameters:
- TARGETS(Optional): Setup all the CMake variables by target (only CMake > 3.1.2). Activates the call to the macro- conan_target_link_libraries().
- NO_OUTPUT_DIRS(Optional): Do not adjust the build output directories. Deactivates the call to the macro [- conan_output_dirs_setup()](#conan_output_dirs_setup).
- SKIP_RPATH(Optional): [DEPRECATED] Use- KEEP_RPATHSinstead. Activate- CMAKE_SKIP_RPATHvariable in OSX.
- KEEP_RPATHS(Optional): Do not adjust the- CMAKE_SKIP_RPATHvariable in OSX. Activates the call to the macro- conan_set_rpath()
- SKIP_STD(Optional): Do not adjust the C++ standard flag in- CMAKE_CXX_FLAGS. Deactivates the call to the macro- conan_set_std().
- SKIP_FPIC(Optional): Do not adjust the- CMAKE_POSITION_INDEPENDENT_CODEflag. Deactivates the call to the macro- conan_set_fpic().
 
Note
You can also call each of the following macros individually instead of using the conan_basic_setup().
conan_target_link_libraries()ο
Helper to link all libraries to a specified target.
These targets are:
- A - CONAN_PKG::<PKG-NAME>target per package in the dependency graph. This is an- IMPORTED INTERFACEtarget.- IMPORTEDbecause it is external, a pre-compiled library.- INTERFACE, because it doesnβt necessarily match a library, it could be a header-only library, or the package could even contain several libraries. It contains all the properties (include paths, compile flags, etc.) that are defined in the consumer. It contains all the properties (include paths, compile flags, etc.) that are defined in the- package_info()method of the recipe.
- Inside each package a - CONAN_LIB::<PKG-NAME>_<LIB-NAME>target will be generated for each library. Its type is- IMPORTED UNKNOWNand its main purpose is to provide a correct link order. Their only properties are the location and the dependencies.
- A - CONAN_PKGdepends on every- CONAN_LIBthat belongs to it, and to its direct public dependencies (e.g. other- CONAN_PKGtargets from its requirements).
- Each - CONAN_LIBdepends on the direct public dependencies- CONAN_PKGtargets of its container package. This guarantees correct link order.
conan_check_compiler()ο
Checks that your compiler matches the one declared in settings.
This method can be disabled setting the CONAN_DISABLE_CHECK_COMPILER variable.
conan_output_dirs_setup()ο
Adjusts each CMAKE_RUNTIME_OUTPUT_DIRECTORY variable to be ${CMAKE_CURRENT_BINARY_DIR}/bin
and each CMAKE_ARCHIVE_OUTPUT_DIRECTORY and CMAKE_LIBRARY_OUTPUT_DIRECTORY variable to be
${CMAKE_CURRENT_BINARY_DIR}/lib.
Calling this method makes writing the package() method for recipies easier. All artifacts will
always be found in the same location. Otherwise, they may be found in different locations depending
on your build environment (eg Linux vs Windows).
conan_set_find_library_paths()ο
Sets CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
conan_global_flags()ο
Sets the corresponding variables to CMakeβs include_directories() and link_directories().
You can enable the variable CONAN_SYSTEM_INCLUDES in order to get directories included with the SYSTEM option.
conan_define_targets()ο
Defines the targets for each dependency (target flags instead of global flags).
conan_set_rpath()ο
Sets CMAKE_SKIP_RPATH=1 in the case of working in OSX.
conan_set_vs_runtime()ο
Adjusts the runtime flags /MD, /MDd, /MT or /MTd for Visual Studio.
conan_set_std()ο
Sets CMAKE_CXX_STANDARD and CMAKE_CXX_EXTENSIONS to the appropriate values.
conan_set_libcxx()ο
Adjusts the standard library flags (libc++`, libstdc++, libstdc++11) in CMAKE_CXX_FLAGS.
conan_set_find_paths()ο
Adjusts CMAKE_MODULE_PATH and CMAKE_PREFIX_PATH to the values of deps_cpp_info.build_paths.
conan_include_build_modules()ο
Includes CMake files declared in CONAN_BUILD_MODULES using the include(...) directive. This loads the functions or macros that
packages may export and makes them available for usage in the consumers CMakeLists.txt.
conan_find_apple_frameworks(FRAMEWORKS_FOUND FRAMEWORKS)ο
Find framework library names provided in ${FRAMEWORKS} using find_library() and return the found values in FRAMEWORKS_FOUND.
Input variables for conanbuildinfo.cmakeο
CONAN_CMAKE_SILENT_OUTPUTο
Default to: FALSE
Activate it to silence the Conan message output.
CONAN_DISABLE_CHECK_COMPILERο
Default to: FALSE
Deactivates the check of the compiler done with the method conan_check_compiler().