-
Notifications
You must be signed in to change notification settings - Fork 372
adding conan build in the tutorial #4152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
memsharded
wants to merge
1
commit into
conan-io:develop2
Choose a base branch
from
memsharded:feature/conan_build_tutorial
base: develop2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -394,6 +394,42 @@ demonstrates how to import bindings for the library depending on the graphics AP | |||||
tools<conan_tools_env_virtualrunenv>` without the need to copy them to the local | ||||||
folder. | ||||||
|
||||||
|
||||||
Use the build() method and ``conan build`` command | ||||||
-------------------------------------------------- | ||||||
|
||||||
If you have a recipe that implements a ``build()`` method, then it is possible to automatically call | ||||||
the full ``conan install + cmake <configure> + cmake <build>`` flow with a single command. Though this | ||||||
might not be the typical developer flow, it can be a convenient shortcut in some cases. | ||||||
|
||||||
You can try it with: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
$ mkdir myproj && cd myproj | ||||||
$ conan new cmake_lib | ||||||
$ conan build . | ||||||
|
||||||
|
||||||
The ``conan new`` command creates a simple project containing a ``conanfile.py``, a ``CMakeLists.txt`` and some C++ code. | ||||||
If you inspect the ``conanfile.py``, you can see it contains a ``build()`` method, with the instructions how to | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
configure and build this project, using some Conan helpers such as ``cmake.configure()`` and ``cmake.build()``. | ||||||
|
||||||
It is not important to fully understand the ``build()`` method now, it will explained later in the tutorial. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
The ``conan build .`` command will automatically call ``conan install .`` (``conan build`` can receive all the same | ||||||
arguments, profiles, settings, etc. as ``install``) to install the dependencies and call the ``generarators``, | ||||||
and after it finishes, it will call the ``build()`` method, which in turns call the CMake configure and build steps, | ||||||
doing a local build of the project. | ||||||
|
||||||
.. note:: | ||||||
|
||||||
**Best practices** | ||||||
|
||||||
The ``conan build`` command does not intend to replace or change the typical developer flow using CMake and | ||||||
other build tools, and using their IDEs. It is just a convenient shortcut for cases in which we want to locally | ||||||
build a project easily without having to type several commands or use the IDE. | ||||||
|
||||||
|
||||||
.. seealso:: | ||||||
|
||||||
- :ref:`Using "cmake_layout" + "CMakeToolchain" + "CMakePresets feature" to build your project<examples-tools-cmake-toolchain-build-project-presets>`. | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think explaining the build method would be a good addition to this lesson but I would introduce it in a different way.
Instead of saying that if you have a recipe that implements this and showing it with
conan new
(that we introduce in the creating packages section), just continue the story as another advantage of theconanfile.py
vs thetxt
one and explain users how to add a build method, just adding this to theconanfile.py
they already have:then do the
conan build
and also adding links here to the local development section to give it a bit more visibility.