Skip to content

Commit

Permalink
Docs from 1.50 introduced changes (#2624)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Jun 30, 2022
1 parent 18f7667 commit 909ea0f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
16 changes: 11 additions & 5 deletions reference/tools/cmake/cmake_layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ For the previous example, the values assigned by the ``cmake_layout`` (installin
configuration) would be:

- ``conanfile.folders.build``:
- ``apple-clang-shared_false``: if the cmake generator is multi-configuration.
- ``apple-clang-shared_false/Debug``: if the cmake generator is single-configuration.
- ``conanfile.folders.generators``: ``apple-clang-shared_false/generators``
- ``build/apple-clang-shared_false``: if the cmake generator is multi-configuration.
- ``build/apple-clang-shared_false/Debug``: if the cmake generator is single-configuration.
- ``conanfile.folders.generators``: ``build/generators``

If we repeat the previous install with a different configuration:

Expand All @@ -76,8 +76,8 @@ If we repeat the previous install with a different configuration:
The values assigned by the ``cmake_layout`` (installing the Release/shared configuration) would be:

- ``conanfile.folders.build``:
- ``build-apple-clang-shared_true``: if the cmake generator is multi-configuration.
- ``cmake-build-debug-apple-clang-shared_true``: if the cmake generator is single-configuration.
- ``build/apple-clang-shared_true``: if the cmake generator is multi-configuration.
- ``build/apple-clang-shared_true/Debug``: if the cmake generator is single-configuration.
- ``conanfile.folders.generators``: ``build-apple-clang-shared_true/generators``


Expand All @@ -89,6 +89,12 @@ names for the presets, being very handy to install N configurations and building
selecting the chosen preset.


.. note::

The ``settings.build_type`` value is forbidden in ``tools.cmake.cmake_layout:build_folder_vars`` because the
build_type is already managed automatically with multi-config support in ``CMakeDeps`` and ``CMakeToolchain``.


Reference
---------

Expand Down
19 changes: 18 additions & 1 deletion reference/tools/cmake/cmaketoolchain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ This will be translated to:
- One ``add_definitions()`` definition, using a cmake generator expression in ``conan_toolchain.cmake`` file,
using the different values for different configurations.


variables
^^^^^^^^^

Expand Down Expand Up @@ -143,6 +142,24 @@ The booleans assigned to a variable will be translated to ``ON`` and ``OFF`` sym
Will generate the sentences: ``set(FOO ON ...)`` and ``set(VAR OFF ...)``.

cache_variables
^^^^^^^^^^^^^^^

This attribute allows defining CMake cache-variables. These variables, unlike the ``variables``, are single-config. They
will be stored in the ``CMakePresets.json`` file (at the `cacheVariables` in the `configurePreset`) and will be
applied with ``-D`` arguments when calling ``cmake.configure`` using the :ref:`CMake() build helper<conan-cmake-build-helper>`.


.. code:: python
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["foo"] = True
tc.cache_variables["foo2"] = False
tc.cache_variables["var"] = "23"
The booleans assigned to a cache_variable will be translated to ``ON`` and ``OFF`` symbols in CMake.


Using a custom toolchain file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
18 changes: 18 additions & 0 deletions reference/tools/files/basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ Usage:
replace_in_file(self, os.path.join(self.source_folder, "folder", "file.txt"), "foo", "bar")
conan.tools.files.rm()
----------------------

.. currentmodule:: conan.tools.files.files

.. autofunction:: rm


Usage:

.. code-block:: python
from conan.tools.files import rm
rm(self, "*.tmp", self.build_folder, recursive=True)
conan.tools.files.mkdir()
-------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ it to perform checks of the input settings. If, for example, your project does n
make Conan return with a special error code. This will indicate that the configuration
used for settings or options is not supported.

Use the objects ``self.info.settings`` and ``self.info.options`` to read the configuration,
otherwise, the "compatible" packages (method ``compatibility()`` and plugin ``compatibility.py`` won't be able to
verify if the potentially compatible configurations are valid or not.


.. code-block:: python
:caption: conanfile.py
Expand All @@ -328,7 +333,7 @@ used for settings or options is not supported.
...
def validate(self):
if self.settings.os == "Macos" and self.settings.arch == "armv8":
if self.info.settings.os == "Macos" and self.info.settings.arch == "armv8":
raise ConanInvalidConfiguration("ARM v8 not supported")
Expand Down

0 comments on commit 909ea0f

Please sign in to comment.