mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 02:39:48 -06:00
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
This commit is contained in:
committed by
Craig Scott
parent
00630bbac7
commit
f03a1833e2
@@ -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
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
Reference in New Issue
Block a user