Skip to content

Commit

Permalink
- document custom template definitions (#2051)
Browse files Browse the repository at this point in the history
Signed-off-by: SSE4 <tomskside@gmail.com>
  • Loading branch information
SSE4 committed Mar 30, 2021
1 parent bac1d95 commit d1efac0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
35 changes: 35 additions & 0 deletions extending/template_system/command_new.rst
Expand Up @@ -100,3 +100,38 @@ This is a very simple example for a header only library:
def package_id(self):
self.info.header_only()
Custom definitions
------------------

Sometimes it's needed to provide additional variables for the custom templates. For instance, if
it's desired to have ``description`` and ``homepage`` to be templated as well:


.. code-block:: text
# Recipe autogenerated with Conan {{ conan_version }} using `conan new --template` command
from conans import ConanFile
class {{package_name}}Conan(ConanFile):
name = "{{ name }}"
version = "{{ version }}"
description = "{{ description }}"
homepage = "{{ homepage }}"
settings = "os", "arch", "compiler", "build_type"
exports_sources = "include/*"
def package(self):
self.copy("*.hpp", dst="include")
self.copy("LICENSE.txt", dst="licenses")
def package_id(self):
self.info.header_only()
now it's easy to overwrite these values from the command line:

.. code-block:: bash
$ conan new mypackage/version --template=header_only -d homepage=https://www.example.com -d description="the best package"
4 changes: 3 additions & 1 deletion reference/commands/creator/new.rst
Expand Up @@ -58,6 +58,9 @@ Creates a new package recipe template with a 'conanfile.py' and optionally,
excluded
-ciu CI_UPLOAD_URL, --ci-upload-url CI_UPLOAD_URL
Define URL of the repository to upload
-d DEFINE, --define DEFINE
Define additional variables to be processed within
template
**Examples**:
Expand Down Expand Up @@ -93,5 +96,4 @@ Creates a new package recipe template with a 'conanfile.py' and optionally,
$ conan new mypackage/1.0 --template=myconanfile.py # Single template file
$ conan new mypackage/1.0 --template=header_only # Template directory
Refer to the section :ref:`template_command_new` for more information about these templates.

0 comments on commit d1efac0

Please sign in to comment.