From ec959decd47fb6de92ca312efdf803d17a39806a Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 26 Jul 2016 02:22:11 +0300 Subject: [PATCH] Beautify examples --- docs/overview/automatic.rst | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/overview/automatic.rst b/docs/overview/automatic.rst index eecc90590b..1dd587c950 100644 --- a/docs/overview/automatic.rst +++ b/docs/overview/automatic.rst @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 `__.