Help: Organize Binary Targets section of cmake-buildsystem.7

Add a subsection for Binary Executables just before Binary Library
Types.  Divide the library section into Normal Libraries and Object
Libraries.
This commit is contained in:
Brad King 2014-06-12 13:40:34 -04:00
parent 4054534cc6
commit 50dca47106
1 changed files with 26 additions and 7 deletions

View File

@ -19,8 +19,8 @@ and the rules for regeneration in response to change.
Binary Targets
==============
Executables and libraries are defined using the :command:`add_library`
and :command:`add_executable` commands. The resulting binary files have
Executables and libraries are defined using the :command:`add_executable`
and :command:`add_library` commands. The resulting binary files have
appropriate prefixes, suffixes and extensions for the platform targeted.
Dependencies between binary targets are expressed using the
:command:`target_link_libraries` command:
@ -37,9 +37,28 @@ is defined as an executable formed by compiling and linking ``zipapp.cpp``.
When linking the ``zipapp`` executable, the ``archive`` static library is
linked in.
Binary Executables
------------------
The :command:`add_executable` command defines an executable target:
.. code-block:: cmake
add_executable(mytool mytool.cpp)
Commands such as :command:`add_custom_command`, which generates rules to be
run at build time can transparently use an :prop_tgt:`EXECUTABLE <TYPE>`
target as a ``COMMAND`` executable. The buildsystem rules will ensure that
the executable is built before attempting to run the command.
Binary Library Types
--------------------
.. _`Normal Libraries`:
Normal Libraries
^^^^^^^^^^^^^^^^
By default, the :command:`add_library` command defines a static library,
unless a type is specified. A type may be specified when using the command:
@ -66,6 +85,11 @@ It is a type which is loaded as a plugin using runtime techniques.
add_library(archive MODULE 7z.cpp)
.. _`Object Libraries`:
Object Libraries
^^^^^^^^^^^^^^^^
The ``OBJECT`` library type is also not linked to. It defines a non-archival
collection of object files resulting from compiling the given source files.
The object files collection can be used as source inputs to other targets:
@ -83,11 +107,6 @@ they may not be installed, exported, or used in the right hand side of
:command:`target_link_libraries`. They also may not be used as the ``TARGET``
in a use of the :command:`add_custom_command(TARGET)` command signature.
Commands such as :command:`add_custom_command`, which generates rules to be
run at build time can transparently use an :prop_tgt:`EXECUTABLE <TYPE>`
target as a ``COMMAND`` executable. The buildsystem rules will ensure that
the executable is built before attempting to run the command.
Build Specification and Usage Requirements
==========================================