Skip to content
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
10 changes: 10 additions & 0 deletions examples/tools/cmake/cmake_toolchain/use_package_config_cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ This is a very typical recipe, the main difference is the ``package_info()`` met
- It is defining that it will contain the build scripts (like the ``xxx-config.cmake`` package) inside that folder, to
be located by consumers.

.. note::

If the in-package ``xxx-config.cmake`` file has a different name than the Conan
package name, set the ``cmake_file_name`` property with the right value, so that
``find_package()`` can locate it:

.. code-block:: python

self.cpp_info.set_property("cmake_file_name", "MyPkg")

So the responsibility of defining the package details has been transferred to the ``CMakeLists.txt`` that contains:

.. code-block:: cmake
Expand Down
12 changes: 11 additions & 1 deletion tutorial/creating_packages/define_package_information.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,19 @@ And re-create the package:
You can see how Conan now declares the target ``hello::myhello`` instead of the default
``hello::hello`` and the *test_package* builds successfully.

Similarly, if the CMake config file name differs from the Conan package name, set the
``cmake_file_name`` property so consumers can call ``find_package()`` with the right name,
for example if the consumers are expected to do ``find_package(MyHello CONFIG REQUIRED)``

.. code-block:: python
:caption: *conanfile.py*

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "MyHello")

The target name is not the only property you can set in the ``CMakeDeps`` generator. For a
complete list of properties that affect the ``CMakeDeps`` generator behaviour, please check
the :ref:`reference<CMakeDeps Properties>`.
the :ref:`reference<CMakeDeps Properties>`.

Propagating environment or configuration information to consumers
-----------------------------------------------------------------
Expand Down