mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 12:49:36 -06:00
Defer check for sources within a target until generation.
The `add_library` and `add_executable` commands can now be called with no source-files and won't generate a warning or error message, as long as source-files will be added later via the `target_sources` command. If during the generation step still no sources are associated with targets created by such calls a useful error message will be generated and generation fails. Targets of type `INTERFACE_LIBRARY`, `UTILITY` or `GLOBAL_TARGET` are excluded from this check because we do not need sources for these target types during generation. Fixes: #16872
This commit is contained in:
@@ -7,14 +7,15 @@ Add an executable to the project using the specified source files.
|
||||
|
||||
add_executable(<name> [WIN32] [MACOSX_BUNDLE]
|
||||
[EXCLUDE_FROM_ALL]
|
||||
source1 [source2 ...])
|
||||
[source1] [source2 ...])
|
||||
|
||||
Adds an executable target called ``<name>`` to be built from the source
|
||||
files listed in the command invocation. The ``<name>`` corresponds to the
|
||||
logical target name and must be globally unique within a project. The
|
||||
actual file name of the executable built is constructed based on
|
||||
conventions of the native platform (such as ``<name>.exe`` or just
|
||||
``<name>``).
|
||||
files listed in the command invocation. (The source files can be omitted
|
||||
here if they are added later using :command:`target_sources`.) The
|
||||
``<name>`` corresponds to the logical target name and must be globally
|
||||
unique within a project. The actual file name of the executable built is
|
||||
constructed based on conventions of the native platform (such as
|
||||
``<name>.exe`` or just ``<name>``).
|
||||
|
||||
By default the executable file will be created in the build tree
|
||||
directory corresponding to the source tree directory in which the
|
||||
|
||||
@@ -14,13 +14,14 @@ Normal Libraries
|
||||
|
||||
add_library(<name> [STATIC | SHARED | MODULE]
|
||||
[EXCLUDE_FROM_ALL]
|
||||
source1 [source2 ...])
|
||||
[source1] [source2 ...])
|
||||
|
||||
Adds a library target called ``<name>`` to be built from the source files
|
||||
listed in the command invocation. The ``<name>`` corresponds to the
|
||||
logical target name and must be globally unique within a project. The
|
||||
actual file name of the library built is constructed based on
|
||||
conventions of the native platform (such as ``lib<name>.a`` or
|
||||
listed in the command invocation. (The source files can be omitted here
|
||||
if they are added later using :command:`target_sources`.) The ``<name>``
|
||||
corresponds to the logical target name and must be globally unique within
|
||||
a project. The actual file name of the library built is constructed based
|
||||
on conventions of the native platform (such as ``lib<name>.a`` or
|
||||
``<name>.lib``).
|
||||
|
||||
``STATIC``, ``SHARED``, or ``MODULE`` may be given to specify the type of
|
||||
|
||||
Reference in New Issue
Block a user