cmake_find_package_multi

Warning

This is an experimental feature subject to breaking changes in future releases.

This generator is similar to the cmake_find_package generator but it allows working with multi-configuration projects like Visual Studio with both Debug and Release. But there are some differences:

  • Only works with CMake > 3.0

  • It doesn’t generate Find<package_name>.cmake modules but <package_name>Config.cmake/<package_name>-config.cmake files.

  • The “global” approach is not supported, only “modern” CMake by using targets.

Usage

$ conan install . -g cmake_find_package_multi -s build_type=Debug
$ conan install . -g cmake_find_package_multi -s build_type=Release

These commands will generate several files for each dependency in your graph, including a <package_name>Config.cmake or <package_name>-config.cmake that can be located by the CMake find_package(<package_name> CONFIG) command.

Important

Add the CONFIG option to find_package so that module mode is explicitly skipped by CMake. This helps to solve issues when there is for example a FindXXXX.cmake file in CMake’s default modules directory that could be loaded instead of the <package_name>Config.cmake/<package_name>-config.cmake generated by Conan.

The name of the files follows the pattern <package_name>Config.cmake, and <package_name>-config.cmake for lower case names. So for the zlib/1.2.11 package, a zlib-config.cmake file will be generated.

See also

Check the section cmake_find_package_multi to read more about this generator and the adjusted CMake variables/targets.