mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 21:40:15 +08:00
Tutorial: Update Step 1 instructions
To demonstrate how simple a CMake project can be, move the `Build and Run` section earlier in the step.
This commit is contained in:
@@ -24,6 +24,45 @@ Upper, lower, and mixed case commands are supported by CMake. The source
|
|||||||
code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be
|
code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be
|
||||||
used to compute the square root of a number.
|
used to compute the square root of a number.
|
||||||
|
|
||||||
|
Build and Run
|
||||||
|
-------------
|
||||||
|
|
||||||
|
That's all that is needed - we can build and run our project now! First, run
|
||||||
|
the :manual:`cmake <cmake(1)>` executable or the
|
||||||
|
:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
|
||||||
|
with your chosen build tool.
|
||||||
|
|
||||||
|
For example, from the command line we could navigate to the
|
||||||
|
``Help/guide/tutorial`` directory of the CMake source code tree and create a
|
||||||
|
build directory:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
mkdir Step1_build
|
||||||
|
|
||||||
|
Next, navigate to the build directory and run CMake to configure the project
|
||||||
|
and generate a native build system:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
cd Step1_build
|
||||||
|
cmake ../Step1
|
||||||
|
|
||||||
|
Then call that build system to actually compile/link the project:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
cmake --build .
|
||||||
|
|
||||||
|
Finally, try to use the newly built ``Tutorial`` with these commands:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
Tutorial 4294967296
|
||||||
|
Tutorial 10
|
||||||
|
Tutorial
|
||||||
|
|
||||||
|
|
||||||
Adding a Version Number and Configured Header File
|
Adding a Version Number and Configured Header File
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
@@ -113,39 +152,24 @@ call to ``add_executable``.
|
|||||||
:language: cmake
|
:language: cmake
|
||||||
:end-before: # configure a header file to pass some of the CMake settings
|
:end-before: # configure a header file to pass some of the CMake settings
|
||||||
|
|
||||||
Build and Test
|
Rebuild
|
||||||
--------------
|
-------
|
||||||
|
|
||||||
Run the :manual:`cmake <cmake(1)>` executable or the
|
Let's build our project again. We already created a build directory and ran
|
||||||
:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
|
CMake, so we can skip to the build step:
|
||||||
with your chosen build tool.
|
|
||||||
|
|
||||||
For example, from the command line we could navigate to the
|
|
||||||
``Help/guide/tutorial`` directory of the CMake source code tree and create a
|
|
||||||
build directory:
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
mkdir Step1_build
|
|
||||||
|
|
||||||
Next, navigate to the build directory and run CMake to configure the project
|
|
||||||
and generate a native build system:
|
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
cd Step1_build
|
cd Step1_build
|
||||||
cmake ../Step1
|
|
||||||
|
|
||||||
Then call that build system to actually compile/link the project:
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
cmake --build .
|
cmake --build .
|
||||||
|
|
||||||
Finally, try to use the newly built ``Tutorial`` with these commands:
|
Now we can try to use the newly built ``Tutorial`` with same commands as before:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
Tutorial 4294967296
|
Tutorial 4294967296
|
||||||
Tutorial 10
|
Tutorial 10
|
||||||
Tutorial
|
Tutorial
|
||||||
|
|
||||||
|
Check that the version number is now reported when running the executable without
|
||||||
|
any arguments.
|
||||||
|
Reference in New Issue
Block a user