Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for 9087 #2121

Merged
merged 4 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions reference/conanfile/tools/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ conan.tools.cmake

.. toctree::
:maxdepth: 2

cmake/cmakedeps
cmake/cmaketoolchain
cmake/cmake
35 changes: 35 additions & 0 deletions reference/conanfile/tools/cmake/cmakedeps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,38 @@ Use the **build_context_build_modules** attribute to specify require names to in
# Choose the build modules from "build" context
cmake.build_context_build_modules = ["my_tool"]
cmake.generate()

Properties
++++++++++

The following properties affect the CMakeDeps generator:

- **cmake_file_name**: The config file generated for the current package will follow the ``<VALUE>-config.cmake`` pattern,
so to find the package you write ``find_package(<VALUE>)``.
- **cmake_target_name**: Name of the target to be consumed. When set on the root ``cpp_info``,
it changes the namespace of the target. When set to a component, it changes the name of the target
(see the example below).
- **cmake_build_modules**: List of ``.cmake`` files (route relative to root package folder) that are automatically
included when the consumer run the ``find_package()``.
- **skip_deps_file**: It tells the ``CMakeDeps`` generator to skip the creation of files for the package declaring
this property. It can be used, for instance, to create a system wrapper package so the consumers find
the config files in the CMake installation config path and not in the generated by Conan (because it has been skipped).

Example:

.. code-block:: python

def package_info(self):
...
# MyFileName-config.cmake
self.cpp_info.set_property("cmake_file_name", "MyFileName")
# Foo:: namespace for the targets (Foo::Foo if no components)
self.cpp_info.set_property("cmake_target_name", "Foo")
# Foo::Var target name for the component "mycomponent"
self.cpp_info.components["mycomponent"].set_property("cmake_target_name", "Var")
# Automatically include the lib/mypkg.cmake file when calling find_package()
self.cpp_info.components["mycomponent"].set_property("cmake_build_modules", [os.path.join("lib", "mypkg.cmake")])

# Skip this package when generating the files for the whole dependency tree in the consumer
# note: it will make useless the previous adjustements.
self.cpp_info.set_property("skip_deps_file", True)