summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorMichael Hirsch <scivision@users.noreply.gitlab.kitware.com>2022-11-28 01:15:18 (GMT)
committerCraig Scott <craig.scott@crascit.com>2022-11-28 22:12:17 (GMT)
commitf03a1833e2b0608ca053df819772759698fbcdb6 (patch)
treee2210904c58d580c42e4693f3117684f3d36aaf3 /Help
parent00630bbac783152a7e22bcbbc86c70ab16dca28c (diff)
downloadCMake-f03a1833e2b0608ca053df819772759698fbcdb6.zip
CMake-f03a1833e2b0608ca053df819772759698fbcdb6.tar.gz
CMake-f03a1833e2b0608ca053df819772759698fbcdb6.tar.bz2
Help: Update compiler-specific add_compile_options() example and prose
Avoid hard-coding a warning-as-error flag now that CMake offers a first class abstraction for that. Also mention some relevant generator expressions which can be used to provide even more specific targeting with language-specific flags. Fixes: #24200
Diffstat (limited to 'Help')
-rw-r--r--Help/command/add_compile_options.rst11
1 files changed, 7 insertions, 4 deletions
diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst
index ad65357..0ccebc6 100644
--- a/Help/command/add_compile_options.rst
+++ b/Help/command/add_compile_options.rst
@@ -28,13 +28,16 @@ this command is in a compiler-specific conditional clause:
.. code-block:: cmake
if (MSVC)
- # warning level 4 and all warnings as errors
- add_compile_options(/W4 /WX)
+ # warning level 4
+ add_compile_options(/W4)
else()
- # lots of warnings and all warnings as errors
- add_compile_options(-Wall -Wextra -pedantic -Werror)
+ # additional warnings
+ add_compile_options(-Wall -Wextra -Wpedantic)
endif()
+To set per-language options, use the :genex:`$<COMPILE_LANGUAGE>`
+or :genex:`$<COMPILE_LANGUAGE:languages>` generator expressions.
+
See Also
^^^^^^^^