mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Options specified via `COMPILE_OPTIONS` and `INTERFACE_COMPILE_OPTIONS`
are deduplicated, but individual options can legitimately be duplicated
when grouped with other options, e.g.
-D A -D B
After deduplication that becomes `-D A B`. Therefore we need a way to
treat groups of options as units during deduplication. A simple approach
is to specify each group as one option, e.g.
"-D A" "-D B"
However, that conflicts with options that legitimately have spaces. To
break this ambiguity, add a `SHELL:` prefix syntax to specify that an
option should be parsed like shell command line arguments after
deduplication, e.g.
"SHELL:-D A" "SHELL:-D B"
These will survive deduplication intact, and then be parsed to produce
`-D A -D B` on the final command line.
Fixes: #15826
26 lines
998 B
ReStructuredText
26 lines
998 B
ReStructuredText
add_compile_options
|
|
-------------------
|
|
|
|
Adds options to the compilation of source files.
|
|
|
|
::
|
|
|
|
add_compile_options(<option> ...)
|
|
|
|
Adds options to the compiler command line for targets in the current
|
|
directory and below that are added after this command is invoked.
|
|
See documentation of the :prop_dir:`directory <COMPILE_OPTIONS>` and
|
|
:prop_tgt:`target <COMPILE_OPTIONS>` ``COMPILE_OPTIONS`` properties.
|
|
|
|
This command can be used to add any options, but alternative commands
|
|
exist to add preprocessor definitions (:command:`target_compile_definitions`
|
|
and :command:`add_definitions`) or include directories
|
|
(:command:`target_include_directories` and :command:`include_directories`).
|
|
|
|
Arguments to ``add_compile_options`` may use "generator expressions" with
|
|
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
|
|
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
|
|
manual for more on defining buildsystem properties.
|
|
|
|
.. include:: COMPILE_OPTIONS_SHELL.txt
|