Skip to content

Commit

Permalink
Beautify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Jul 25, 2016
1 parent 50e55cd commit ec959de
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions docs/overview/automatic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Build instructions from Hunter archive triggered automatically when
``hunter_add_package`` function called. Hence there is no need to specify
dependencies in a raw ``README`` file like:

::
.. code-block:: none
:emphasize-lines: 2, 5
For OSX please do:
> brew install foo boo
Expand All @@ -22,7 +23,8 @@ dependencies in a raw ``README`` file like:
Now it's simply:

::
.. code-block:: none
:emphasize-lines: 2
Just run build:
> cmake -H. -B_builds # dependencies installed automatically
Expand All @@ -34,6 +36,7 @@ Optional dependencies
Optional dependency? No problems, expressed in a pretty clean way:

.. code-block:: cmake
:emphasize-lines: 4
# required dependencies
hunter_add_package(foo)
Expand All @@ -50,7 +53,8 @@ Same commands:

instead of:

::
.. code-block:: none
:emphasize-lines: 2, 3, 6
Additionally if you want bar support please run:
> brew install bar # OSX
Expand All @@ -68,16 +72,19 @@ Note that such approach differs from
duplication of logic in many cases even if ``requirements.txt`` do downloads
automatically too.

Imagine we have to specify dependencies in ``requirements`` file and there is
user's option:
Imagine we have to specify dependencies in some kind of ``requirements.cmake``
file and there is user's option:

.. code-block:: cmake
:emphasize-lines: 3
# requirements.cmake
if(WIN32 AND BUILD_WITH_BAR)
# install Bar
command_to_install(Bar)
endif()
In case it's not CMake code this will look even fancy:
In case it's not CMake code this will look even fancy, say ``requirements.json``:

.. code-block:: json
Expand All @@ -93,12 +100,25 @@ In case it's not CMake code this will look even fancy:
You have to repeat same condition in ``CMakeLists.txt`` file:

.. code-block:: cmake
:emphasize-lines: 3
# requirements.cmake
if(WIN32 AND BUILD_WITH_BAR)
command_to_install(Bar)
endif()
.. code-block:: cmake
:emphasize-lines: 3
# CMakeLists.txt
if(WIN32 AND BUILD_WITH_BAR)
find_package(Bar CONFIG REQUIRED)
target_compile_definitions(... PUBLIC "WITH_BAR")
endif()
In case this part change you must not to forget to modify ``requirements``
In case when this part will change you must not to forget to modify ``requirements``
accordingly too. And real world libraries can have nontrivial chain of conditions, e.g.
`OpenCV components <https://github.com/Itseez/opencv/blob/ec63343f34658d9b0ec94dc15e1b71e8f7d1d553/CMakeLists.txt#L170>`__.

Expand Down

0 comments on commit ec959de

Please sign in to comment.