From f93b13151e8e82601568b7f2c2d22943e9e2e048 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 31 Mar 2023 11:00:46 -0400 Subject: Help: Link to COMPILE_LANGUAGE genex from add_compile_options Follow-up commit e2830cf16b (Help: Link to COMPILE_LANGUAGE genex from target_compile_options, 2023-03-28). Issue: #24639 --- Help/command/add_compile_options.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst index 0ccebc6..f587ae6 100644 --- a/Help/command/add_compile_options.rst +++ b/Help/command/add_compile_options.rst @@ -48,5 +48,9 @@ See Also * The command :command:`target_compile_options` adds target-specific options. +* This command adds compile options for all languages. + Use the :genex:`COMPILE_LANGUAGE` generator expression to specify + per-language compile options. + * The source file property :prop_sf:`COMPILE_OPTIONS` adds options to one source file. -- cgit v0.12 From 530faee017ffaabb0315bc81405bdc2ef0995c62 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 31 Mar 2023 09:41:35 -0400 Subject: Help: Clarify that CMAKE__FLAGS are used when driving linking State explicitly that these flags are used when driving either compiling or linking. For linking, document their order w.r.t. link flags specified by commands. Fixes: #24662 --- Help/variable/CMAKE_LANG_FLAGS.rst | 18 +++++++++++------- Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst | 17 ++++++++++++----- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 4b39b1d..747ac93 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -1,9 +1,10 @@ CMAKE__FLAGS ------------------ -Flags for all build types. - -```` flags used regardless of the value of :variable:`CMAKE_BUILD_TYPE`. +Language-wide flags for language ```` used when building for +all configurations. These flags will be passed to all invocations +of the compiler. This includes invocations that drive compiling +and those that drive linking. For each language, if this variable is not defined, it is initialized and stored in the cache using values from environment variables in @@ -27,7 +28,10 @@ combination with CMake's builtin defaults for the toolchain: This value is a command-line string fragment. Therefore, multiple options should be separated by spaces, and options with spaces should be quoted. -The flags in this variable will be passed to the compiler before those -in the per-configuration :variable:`CMAKE__FLAGS_` variant, -and before flags added by the :command:`add_compile_options` or -:command:`target_compile_options` commands. +The flags in this variable will be passed before those in the +per-configuration :variable:`CMAKE__FLAGS_` variable. +On invocations driving compiling, flags from both variables will be passed +before flags added by commands such as :command:`add_compile_options` and +:command:`target_compile_options`. On invocations driving linking, +they will be passed before before flags added by commands such as +:command:`add_link_options` and :command:`target_link_options`. diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst index f0900fd..de7bd53 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst @@ -1,9 +1,16 @@ CMAKE__FLAGS_ --------------------------- -Flags for language ```` when building for the ```` configuration. +Language-wide flags for language ```` used when building for +the ```` configuration. These flags will be passed to all +invocations of the compiler in the corresponding configuration. +This includes invocations that drive compiling and those that drive +linking. -The flags in this variable will be passed to the compiler after those -in the :variable:`CMAKE__FLAGS` variable, but before flags added -by the :command:`add_compile_options` or :command:`target_compile_options` -commands. +The flags in this variable will be passed after those in the +:variable:`CMAKE__FLAGS` variable. On invocations driving compiling, +flags from both variables will be passed before flags added by commands +such as :command:`add_compile_options` and :command:`target_compile_options`. +On invocations driving linking, they will be passed before before flags +added by commands such as :command:`add_link_options` and +:command:`target_link_options`. -- cgit v0.12 From 561ae21f40d1416aee9a1b63be3b7bafa7b29231 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 31 Mar 2023 11:10:36 -0400 Subject: Help: Clarify that {add,target}_compile_options are not used for linking Link to alternatives that can be used for adding link options. Issue: #24662 --- Help/command/add_compile_options.rst | 11 +++++++++++ Help/command/add_link_options.rst | 4 ++++ Help/command/target_compile_options.rst | 9 +++++++++ Help/command/target_link_options.rst | 4 ++++ Help/variable/CMAKE_LANG_FLAGS.rst | 2 +- Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst | 4 ++-- 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst index f587ae6..869d0c2 100644 --- a/Help/command/add_compile_options.rst +++ b/Help/command/add_compile_options.rst @@ -11,6 +11,11 @@ Adds options to the :prop_dir:`COMPILE_OPTIONS` directory property. These options are used when compiling targets from the current directory and below. +.. note:: + + These options are not used when linking. + See the :command:`add_link_options` command for that. + Arguments ^^^^^^^^^ @@ -54,3 +59,9 @@ See Also * The source file property :prop_sf:`COMPILE_OPTIONS` adds options to one source file. + +* :command:`add_link_options` adds options for linking. + +* :variable:`CMAKE__FLAGS` and :variable:`CMAKE__FLAGS_` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst index c09e106..df72715 100644 --- a/Help/command/add_link_options.rst +++ b/Help/command/add_link_options.rst @@ -38,3 +38,7 @@ See Also * :command:`link_libraries` * :command:`target_link_libraries` * :command:`target_link_options` + +* :variable:`CMAKE__FLAGS` and :variable:`CMAKE__FLAGS_` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst index f3ac97b..7cfb24b 100644 --- a/Help/command/target_compile_options.rst +++ b/Help/command/target_compile_options.rst @@ -15,6 +15,11 @@ are used when compiling the given ````, which must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target `. +.. note:: + + These options are not used when linking the target. + See the :command:`target_link_options` command for that. + Arguments ^^^^^^^^^ @@ -60,3 +65,7 @@ See Also * :command:`target_link_options` * :command:`target_precompile_headers` * :command:`target_sources` + +* :variable:`CMAKE__FLAGS` and :variable:`CMAKE__FLAGS_` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/command/target_link_options.rst b/Help/command/target_link_options.rst index 0d026f2..dca9598 100644 --- a/Help/command/target_link_options.rst +++ b/Help/command/target_link_options.rst @@ -62,3 +62,7 @@ See Also * :command:`target_link_directories` * :command:`target_precompile_headers` * :command:`target_sources` + +* :variable:`CMAKE__FLAGS` and :variable:`CMAKE__FLAGS_` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 747ac93..909a001 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -33,5 +33,5 @@ per-configuration :variable:`CMAKE__FLAGS_` variable. On invocations driving compiling, flags from both variables will be passed before flags added by commands such as :command:`add_compile_options` and :command:`target_compile_options`. On invocations driving linking, -they will be passed before before flags added by commands such as +they will be passed before flags added by commands such as :command:`add_link_options` and :command:`target_link_options`. diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst index de7bd53..5daa4c0 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst @@ -11,6 +11,6 @@ The flags in this variable will be passed after those in the :variable:`CMAKE__FLAGS` variable. On invocations driving compiling, flags from both variables will be passed before flags added by commands such as :command:`add_compile_options` and :command:`target_compile_options`. -On invocations driving linking, they will be passed before before flags -added by commands such as :command:`add_link_options` and +On invocations driving linking, they will be passed before flags added by +commands such as :command:`add_link_options` and :command:`target_link_options`. -- cgit v0.12