Commit Graph

49 Commits

Author SHA1 Message Date
Brad King
987f3fa4e0 Help: Add cmake-buildsystem(7) subsections for each binary target type
Re-organize the "Binary Targets" section of the manual to have a
dedicated subsection for each kind of binary target.  Initialize each
subsection by documenting the object file and link semantics of the
corresponding target type.
2024-12-13 09:53:26 -05:00
Asit Dhal
a61c9afdf8 add_library: Reject shared libraries on platforms that do not support them
Add policy CMP0164 to provide compatibility.

Fixes: #25759
2024-03-29 11:06:32 -04:00
Brad King
e1519edd91 Help: Use signature directive for the 'add_library' command
This allows individual signatures to be cross-referenced from elsewhere.
It also associates with each signature its main documentation via
indentation.
2023-12-06 13:05:23 -05:00
namniav
7fc6d7247a Help: Fix signature of add_library(<name> INTERFACE EXCLUDE_FROM_ALL)
This signature was added by commit 4391913133 (Add INTERFACE libraries
to generated buildsystem if they have SOURCES, 2020-07-20,
v3.19.0-rc1~346^2~1) with incorrect documentation.

Previously the documented signature as:

    add_library(<name> INTERFACE [<source>...] [EXCLUDE_FROM_ALL])

which is incorrect.  CMake would recognize `EXCLUDE_FROM_ALL` as a source
file and report an error that it doesn't exists.

The correct signature is:

    add_library(<name> INTERFACE [EXCLUDE_FROM_ALL] [<source>...])

which places `EXCLUDE_FROM_ALL` in the same position used by the
documentation of other signatures.

Fixes: #25463
2023-12-04 10:37:01 -05:00
Ben Boeckel
c36910476a Help: remove links from pages to themselves
At least the top-reference links. Internal `:ref:` usages have been left
intact.
2022-11-18 14:09:32 -05:00
Alex Turbov
65457e4fae
Help: Add _See Also_ sections to related CMake commands 2022-11-09 23:52:30 +04:00
Alex Turbov
c86ec79d07
Help: Use direct refs to genexes instead of `$<GENEX-NAME>` 2022-11-09 23:52:30 +04:00
Kyle Edwards
d0d09aa29f FILE_SET: Make INTERFACE libraries with HEADER_SETS participate in buildsystem
If an INTERFACE library has HEADER_SETS, and its header sets contain
files generated by a custom command, the library needs to participate in
the buildsystem so that the files will be generated.

Fixes: #23422
2022-04-14 09:17:54 -04:00
Brad King
001870d451 Help: Clarify TARGET_RUNTIME_DLLS behavior on imported targets
This generator expression does not report the locations of `.dll`
files on imported targets with the `UNKNWON` type, since their
`IMPORTED_LOCATION` refers to the import library and not the DLL.

Fixes: #22845
2021-11-03 16:17:17 -04:00
Brad King
4d6e899578 Help: Document in add_library how to import libraries with SONAME
When using `add_library` to create an `IMPORTED` library target, there
are a few target properties that are essential to correctly tell CMake
about the library file.  We already cover `IMPORTED_LOCATION` and
`IMPORTED_IMPLIB`.  Add `IMPORTED_SONAME` and `IMPORTED_NO_SONAME`,
which are important in certain cases.

Fixes: #22016
2021-04-02 12:12:28 -04:00
Nikita Nemkin
c705279bae Help: Add .. versionadded directives to commands documentation
This change ony concerns directives that appear in the document body.

The guidelines for inserting version directives:

 * Baseline version is CMake 3.0, i.e. directives start at 3.1.
 * Always use `.. versionadded::` directive, avoid ad-hoc version
   references. Exception: policy pages.
 * For new command signatures, put `versionadded` on a separate line
   after the signature.
 * For a group of new signatures in a new document section,
   a single version note at the beginning of the section is sufficient.
 * For new options, put `versionadded` on a separate line before
   option description.
 * If all the option descriptions in the list are short one-liners,
   it's fine to put `versionadded` on the same line as the description.
 * If multiple option descriptions in close proximity would have
   the same ..versionadded directive, consider adding a single
   directive after the list, mentioning all added options.
 * For compact value lists and sub-option lists, put a single
  `versionadded` directive after the list mentioning all additions.
 * When a change is described in a single paragraph, put
   `versionadded` into that paragraph.
 * When only part of the paragraph has changed, separate the changed
   part if it doesn't break the flow. Otherwise, write a follow-up
   clarification paragraph and apply version directive to that.
 * When multiple version directives are close by, order earlier
   additions before later additions.
 * Indent related lists and code blocks to include them in the scope
   of `versionadded` directive.

Issue: #19715
2020-11-09 20:51:57 +05:00
Deniz Bahadir
0a5c3e3b97 Help: add_library(<name> OBJECT) can omit the source files 2020-09-10 16:59:34 +02:00
Brad King
d6ee9b4a43 Merge topic 'build-interface-targets'
bafa9fe887 fileapi: Add INTERFACE libraries with SOURCES to codemodel-v2
4391913133 Add INTERFACE libraries to generated buildsystem if they have SOURCES
afb998704e Remove filtering of allowed INTERFACE library properties
e7edba2baf Makefiles: Use IsInBuildSystem in global generator target type checks

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5078
2020-08-10 11:38:59 -04:00
Brad King
4391913133 Add INTERFACE libraries to generated buildsystem if they have SOURCES
INTERFACE libraries were created with the intention of collecting usage
requirements for use by other targets via `target_link_libraries`.
Therefore they were not allowed to have SOURCES and were not included in
the generated buildsystem.  In practice, this has become limiting:

* Header-only libraries do have sources, they just do not compile.
  Developers should be able to edit those sources (the header files)
  in their IDE.

* Header-only libraries may need to generate some of their header
  files via custom commands.

Some projects work around these limitations by pairing each interface
library with an `add_custom_target` that makes the header files and
custom commands appear in the generated buildsystem and in IDEs.

Lift such limitations by allowing INTERFACE libraries to have SOURCES.
For those with sources, add a corresponding build target to the
generated buildsystem.

Fixes: #19145
2020-08-07 08:46:32 -04:00
Brad King
1f1feb72f8 Help: Document in add_library that IMPORTED_IMPLIB is for DLL import libs
Fixes: #21053
2020-08-04 09:29:42 -04:00
Brad King
ee5b58f491 Help: State in add_library that INTERFACE libraries have no build targets 2020-07-31 12:04:17 -04:00
Brad King
99b1e85f07 Help: Consolidate add_library documentation on IMPORTED libraries
Move documentation on IMPORTED INTERFACE libraries to the main section
on Imported Libraries.  Revise the section to clarify the different
kinds of imported libraries that can be created and what properties they
need.

Issue: #18975
2020-07-31 11:40:15 -04:00
Brad King
716e76be3e Help: Re-order add_library sections
Put all the sections that create in-project targets first,
and move Imported Libraries and Alias Libraries at the end.
2020-07-31 11:22:28 -04:00
Marc Chevrier
056489d567 add_library/add_executable: allow local alias to imported targets
Fixes: #20641
2020-06-02 17:11:47 +02:00
Cristian Adam
4127f82179 add_library: Document UNKNOWN type of imported targets 2019-06-02 08:44:47 +02:00
Avraham Shukron
a40f9083dd INTERFACE Target: allow (PUBLIC/PRIVATE)_HEADER properties
Also support installing headers on an INTERFACE library.

Signed-off-by: Avraham Shukron <avraham.shukron@gmail.com>
Fixes: #15234
2019-04-11 11:09:42 -04:00
Joachim Wuttke (o)
adbaadf0ee Help: Apply syntax highlighting to project commands
* Replace most "::" by ".. code-block:: cmake"
  * Header sentence in imperative voice,
    detailed command description in present tense.
2018-10-25 13:47:31 +02:00
Bartosz Kosiorek
fc1602456a Help: Replace occurrences of "Mac OS X" with "macOS"
Apple's main Operating system changed their name from OS X to macOS:

    https://www.engadget.com/2016/06/13/os-x-is-now-macos/

Revise documentation accordingly.
2018-09-05 16:10:49 -04:00
Brad King
42065828c3 Merge topic 'doc-add_library-IMPORTED_OBJECTS'
62b4df1e84 Help: Mention IMPORTED_OBJECTS in add_library docs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2216
2018-07-16 09:07:23 -04:00
Brad King
62b4df1e84 Help: Mention IMPORTED_OBJECTS in add_library docs
The `IMPORTED_OBJECTS` is to object libraries as `IMPORTED_LOCATION`
is to normal libraries.

Fixes: #18176
2018-07-16 08:17:51 -04:00
Marc Chevrier
b16fd1341d Help: add_library(INTERFACE): add reference to add_link_options() 2018-06-20 11:55:32 +02:00
Brad King
bafe655b11 Help: Document linking behavior of OBJECT libraries
Inspired-by: Deniz Bahadir <dbahadir@benocs.com>
Issue: #14778
2018-03-01 09:27:50 -05:00
Ben Boeckel
4c40ab261c add_library: mention that Xcode requires a real source file
The docs mentioned that it happened, but not when. Mention Xcode since
it is the culprit today.

See #16524.
2017-12-01 10:37:15 -05:00
Deniz Bahadir
494906a8a2 Add support for IMPORTED GLOBAL targets to be aliased
Issue: #15569
Issue: #17197
2017-10-26 09:11:04 -04:00
Deniz Bahadir
4e7f67383f 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
2017-10-24 08:14:47 -04:00
Gregor Jasny
6a6cbd47fb Help: Fix typo in add_library(... ALIAS ...) text 2017-05-14 22:09:19 +02:00
Roman Lebedev
32400110fe Help: Document HEADER_FILE_ONLY use case
Describe how to get sources into IDE project files.
2017-05-09 11:46:29 -04:00
Robert Maynard
eec93bceec Allow OBJECT libraries to be installed, exported, and imported
Teach install() and export() to handle the actual object files.
Disallow this on Xcode with multiple architectures because it
still cannot be cleanly supported there.

Co-Author: Brad King <brad.king@kitware.com>
2017-04-18 11:36:10 -04:00
Gregor Jasny
071f8e78dd Apple: Add support for static frameworks
Closes: #16432
2017-01-31 08:59:15 -05:00
Felix Geyer
49e82c15d5 Fix spelling typos in comments and documentation (#16037)
The Debian package checker tool (lintian) detected several typos in
CMake.
2016-03-29 14:31:02 -04:00
James Johnston
6556481eb8 Help: Document that SHARED libraries must export a symbol (#15775)
CMake assumes that a SHARED library compiled on Windows will export a LIB file.
This is not actually the case on Visual C++ if the library does not export any
symbols, and causes incremental builds to break if the user specifies SHARED
anyway.  (Users should use MODULE libraries instead.)
2015-10-08 13:53:51 -04:00
Brad King
eb8eaaecbe Help: Document Apple Framework creation with an example (#15651) 2015-07-14 14:57:02 -04:00
Brad King
67c4be51a3 Merge branch 'release-doc-formatting' into doc-formatting
Resolve conflict in Modules/ExternalProject.cmake by keeping our side,
which is more completely revised.
2014-11-06 14:52:49 -05:00
Brad King
f84ddd4b56 Help: Format add_library documented list of INTERFACE commands
Use a bullet list to make it easier to read.
2014-11-06 14:46:18 -05:00
Nils Gladitz
38825396f9 Documentation: Fix minor typo thecommand -> the command 2014-10-31 11:27:50 -04:00
Brad King
2c470b775a add_library: Allow arbitrary non-linked sources in OBJECT libraries
Loosen this restriction on OBJECT libraries to allow source files of any
name to be generated by custom commands or listed for reference in IDE
projects so long as they would not affect linking of a normal library.
Update the rejection message to be more specific about the looser
restriction.

Extend the ObjectLibrary test to cover a ".cmake" file generated by a
custom command in an OBJECT library.
2014-07-09 09:43:42 -04:00
Brad King
20f5460288 Help: Link to Object Library docs from add_library 2014-06-12 13:59:13 -04:00
Brad King
a81531817e Help: Organize add_library command documentation
Add a section for each library type signature.  Add a table of contents
at the top for the html builder.
2014-06-12 13:59:00 -04:00
Brad King
4054534cc6 Help: Mention INTERFACE_SOURCES as settable for INTERFACE libs
The add_library(INTERFACE) and Interface Libraries documentation
list all the INTERFACE_* properties and target_* commands that
can be used to define the interface.  Add INTERFACE_SOURCES
and target_sources() to these lists for completeness.
2014-06-12 13:31:01 -04:00
Stephen Kelly
e5da9e51d0 cmTarget: Allow any generator expression in SOURCES property.
Remove use of UseObjectLibraries from Makefile and Ninja generators. It
is not needed now because those generators use GetExternalObjects
which already contains the objects from object libraries.

The VS10 generator calls both the UseObjectLibraries and the GetExternalObjects
methods. Ensure that duplicates are not created by skipping objects
from object libraries in handling of GetExternalObjects.

Similarly, fix VS6, VS7 and Xcode object handling by skipping
external objects from OBJECT_LIBRARY usage as appropriate.

The error message in the BadSourceExpression1 test is now reported
by the generator expression evaluator, so it has different text.
2014-04-02 23:12:56 +02:00
Stephen Kelly
ba4c2fa8fd Help: Mark up the buildsystem commands documentation
Cross-link to the cmake-buildsystem manual.
2014-02-06 16:15:53 -05:00
Stephen Kelly
9eb06d0dde add_library: Disallow invalid signatures for INTERFACE_LIBRARY.
Document the valid signatures. Add a test for the IMPORTED GLOBAL
signature.
2014-01-06 17:25:10 +01:00
Brad King
441f2808ec Help: Fix reStructuredText syntax in auto-generated documents 2013-10-15 14:12:49 -04:00
Kitware Robot
f051814ed0 Convert builtin help to reStructuredText source files
Run the convert-help.bash script to convert documentation:

 ./convert-help.bash "/path/to/CMake-build/bin"

Then remove it.
2013-10-15 14:12:03 -04:00