From c1f5a44b28047cde74e2fb10e8d68e314272f699 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 24 Apr 2018 17:01:01 +0200 Subject: LINK_OPTIONS: Add new family of properties This family enable to manage link flags Three new properties: * directory property: LINK_OPTIONS * target properties: LINK_OPTIONS and INTERFACE_LINK_OPTIONS Two new commands * add_link_options(): to populate directory property * target_link_options(): to populate target properties Fixes: #16543 --- Help/command/COMPILE_OPTIONS_SHELL.txt | 9 --- Help/command/OPTIONS_SHELL.txt | 9 +++ Help/command/add_compile_options.rst | 2 +- Help/command/add_link_options.rst | 24 +++++++ Help/command/target_compile_options.rst | 2 +- Help/command/target_link_libraries.rst | 3 +- Help/command/target_link_options.rst | 40 +++++++++++ Help/manual/cmake-commands.7.rst | 2 + Help/manual/cmake-properties.7.rst | 3 + Help/prop_dir/LINK_OPTIONS.rst | 16 +++++ Help/prop_tgt/INTERFACE_LINK_OPTIONS.rst | 9 +++ Help/prop_tgt/LINK_FLAGS.rst | 8 ++- Help/prop_tgt/LINK_FLAGS_CONFIG.rst | 4 ++ Help/prop_tgt/LINK_OPTIONS.rst | 21 ++++++ Help/release/dev/LINK_OPTIONS.rst | 11 +++ Source/CMakeLists.txt | 4 ++ Source/cmAddLinkOptionsCommand.cxx | 20 ++++++ Source/cmAddLinkOptionsCommand.h | 31 +++++++++ Source/cmCommands.cxx | 5 ++ Source/cmExportBuildAndroidMKGenerator.cxx | 6 ++ Source/cmExportBuildFileGenerator.cxx | 3 + Source/cmExportInstallFileGenerator.cxx | 3 + Source/cmGeneratorExpressionDAGChecker.h | 3 +- Source/cmGeneratorTarget.cxx | 81 +++++++++++++++++++--- Source/cmGeneratorTarget.h | 6 ++ Source/cmGlobalXCodeGenerator.cxx | 4 ++ Source/cmLocalGenerator.cxx | 8 +++ Source/cmLocalVisualStudio7Generator.cxx | 7 ++ Source/cmMakefile.cxx | 15 ++++ Source/cmMakefile.h | 3 + Source/cmMakefileExecutableTargetGenerator.cxx | 4 +- Source/cmMakefileLibraryTargetGenerator.cxx | 8 +-- Source/cmMakefileTargetGenerator.cxx | 8 ++- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmState.cxx | 2 + Source/cmStateDirectory.cxx | 52 ++++++++++++++ Source/cmStateDirectory.h | 7 ++ Source/cmStatePrivate.h | 4 ++ Source/cmStateSnapshot.cxx | 7 ++ Source/cmTarget.cxx | 77 ++++++++++++++++++-- Source/cmTarget.h | 6 ++ Source/cmTargetLinkOptionsCommand.cxx | 41 +++++++++++ Source/cmTargetLinkOptionsCommand.h | 41 +++++++++++ Source/cmVisualStudio10TargetGenerator.cxx | 5 ++ .../CMakeCommands/add_link_options/CMakeLists.txt | 20 ++++++ .../add_link_options/LinkOptionsExe.c | 4 ++ .../target_link_options/CMakeLists.txt | 19 +++++ .../target_link_options/LinkOptionsLib.c | 7 ++ Tests/CMakeLists.txt | 3 + Tests/ExportImport/Export/CMakeLists.txt | 10 +++ Tests/ExportImport/Import/A/CMakeLists.txt | 5 ++ .../ExportImport/Import/A/imp_testLinkOptions.cpp | 8 +++ Tests/RunCMake/AndroidMK/AndroidMK.cmake | 6 +- .../RunCMake/AndroidMK/expectedBuildAndroidMK.txt | 8 +++ .../AndroidMK/expectedInstallAndroidMK.txt | 8 +++ Tests/RunCMake/CMakeLists.txt | 2 + Tests/RunCMake/add_link_options/CMakeLists.txt | 5 ++ .../add_link_options/LINK_OPTIONS-exe-check.cmake | 7 ++ .../add_link_options/LINK_OPTIONS-exe-result.txt | 1 + .../add_link_options/LINK_OPTIONS-mod-check.cmake | 7 ++ .../add_link_options/LINK_OPTIONS-mod-result.txt | 1 + .../LINK_OPTIONS-shared-check.cmake | 7 ++ .../LINK_OPTIONS-shared-result.txt | 1 + Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake | 17 +++++ Tests/RunCMake/add_link_options/LinkOptionsExe.c | 4 ++ Tests/RunCMake/add_link_options/LinkOptionsLib.c | 7 ++ Tests/RunCMake/add_link_options/RunCMakeTest.cmake | 28 ++++++++ .../RunCMake/set_property/LINK_OPTIONS-stdout.txt | 2 + Tests/RunCMake/set_property/LINK_OPTIONS.cmake | 3 + Tests/RunCMake/set_property/RunCMakeTest.cmake | 1 + Tests/RunCMake/target_link_options/CMakeLists.txt | 5 ++ .../LINK_OPTIONS-basic-check.cmake | 7 ++ .../LINK_OPTIONS-basic-result.txt | 1 + .../LINK_OPTIONS-exe-check.cmake | 7 ++ .../LINK_OPTIONS-exe-result.txt | 1 + .../LINK_OPTIONS-interface-check.cmake | 4 ++ .../LINK_OPTIONS-interface-result.txt | 1 + .../LINK_OPTIONS-mod-check.cmake | 7 ++ .../LINK_OPTIONS-mod-result.txt | 1 + .../LINK_OPTIONS-shared-check.cmake | 7 ++ .../LINK_OPTIONS-shared-result.txt | 1 + .../target_link_options/LINK_OPTIONS.cmake | 39 +++++++++++ .../RunCMake/target_link_options/LinkOptionsExe.c | 4 ++ .../RunCMake/target_link_options/LinkOptionsLib.c | 7 ++ .../target_link_options/RunCMakeTest.cmake | 62 +++++++++++++++++ 85 files changed, 929 insertions(+), 42 deletions(-) delete mode 100644 Help/command/COMPILE_OPTIONS_SHELL.txt create mode 100644 Help/command/OPTIONS_SHELL.txt create mode 100644 Help/command/add_link_options.rst create mode 100644 Help/command/target_link_options.rst create mode 100644 Help/prop_dir/LINK_OPTIONS.rst create mode 100644 Help/prop_tgt/INTERFACE_LINK_OPTIONS.rst create mode 100644 Help/prop_tgt/LINK_OPTIONS.rst create mode 100644 Help/release/dev/LINK_OPTIONS.rst create mode 100644 Source/cmAddLinkOptionsCommand.cxx create mode 100644 Source/cmAddLinkOptionsCommand.h create mode 100644 Source/cmTargetLinkOptionsCommand.cxx create mode 100644 Source/cmTargetLinkOptionsCommand.h create mode 100644 Tests/CMakeCommands/add_link_options/CMakeLists.txt create mode 100644 Tests/CMakeCommands/add_link_options/LinkOptionsExe.c create mode 100644 Tests/CMakeCommands/target_link_options/CMakeLists.txt create mode 100644 Tests/CMakeCommands/target_link_options/LinkOptionsLib.c create mode 100644 Tests/ExportImport/Import/A/imp_testLinkOptions.cpp create mode 100644 Tests/RunCMake/add_link_options/CMakeLists.txt create mode 100644 Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake create mode 100644 Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt create mode 100644 Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake create mode 100644 Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt create mode 100644 Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake create mode 100644 Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt create mode 100644 Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake create mode 100644 Tests/RunCMake/add_link_options/LinkOptionsExe.c create mode 100644 Tests/RunCMake/add_link_options/LinkOptionsLib.c create mode 100644 Tests/RunCMake/add_link_options/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt create mode 100644 Tests/RunCMake/set_property/LINK_OPTIONS.cmake create mode 100644 Tests/RunCMake/target_link_options/CMakeLists.txt create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt create mode 100644 Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake create mode 100644 Tests/RunCMake/target_link_options/LinkOptionsExe.c create mode 100644 Tests/RunCMake/target_link_options/LinkOptionsLib.c create mode 100644 Tests/RunCMake/target_link_options/RunCMakeTest.cmake diff --git a/Help/command/COMPILE_OPTIONS_SHELL.txt b/Help/command/COMPILE_OPTIONS_SHELL.txt deleted file mode 100644 index a1316c8..0000000 --- a/Help/command/COMPILE_OPTIONS_SHELL.txt +++ /dev/null @@ -1,9 +0,0 @@ -The final set of compile options used for a target is constructed by -accumulating options from the current target and the usage requirements of -it dependencies. The set of options is de-duplicated to avoid repetition. -While beneficial for individual options, the de-duplication step can break -up option groups. For example, ``-D A -D B`` becomes ``-D A B``. One may -specify a group of options using shell-like quoting along with a ``SHELL:`` -prefix. The ``SHELL:`` prefix is dropped and the rest of the option string -is parsed using the :command:`separate_arguments` ``UNIX_COMMAND`` mode. -For example, ``"SHELL:-D A" "SHELL:-D B"`` becomes ``-D A -D B``. diff --git a/Help/command/OPTIONS_SHELL.txt b/Help/command/OPTIONS_SHELL.txt new file mode 100644 index 0000000..530c012 --- /dev/null +++ b/Help/command/OPTIONS_SHELL.txt @@ -0,0 +1,9 @@ +The final set of compile or link options used for a target is constructed by +accumulating options from the current target and the usage requirements of +it dependencies. The set of options is de-duplicated to avoid repetition. +While beneficial for individual options, the de-duplication step can break +up option groups. For example, ``-D A -D B`` becomes ``-D A B``. One may +specify a group of options using shell-like quoting along with a ``SHELL:`` +prefix. The ``SHELL:`` prefix is dropped and the rest of the option string +is parsed using the :command:`separate_arguments` ``UNIX_COMMAND`` mode. +For example, ``"SHELL:-D A" "SHELL:-D B"`` becomes ``-D A -D B``. diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst index c445608..350a1c0 100644 --- a/Help/command/add_compile_options.rst +++ b/Help/command/add_compile_options.rst @@ -22,4 +22,4 @@ 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 +.. include:: OPTIONS_SHELL.txt diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst new file mode 100644 index 0000000..c827d70 --- /dev/null +++ b/Help/command/add_link_options.rst @@ -0,0 +1,24 @@ +add_link_options +---------------- + +Adds options to the link of targets. + +:: + + add_link_options(