From 66ea1a3795f76ce921bc48f82ff228bcceed4524 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Mon, 30 Apr 2018 18:56:25 +0200 Subject: LINK_OPTIONS: Add support of "LINKER:" prefix --- Help/command/LINK_OPTIONS_LINKER.txt | 10 +++ Help/command/add_link_options.rst | 10 ++- Help/command/target_link_options.rst | 4 +- Help/manual/cmake-variables.7.rst | 2 + Help/release/dev/LINK_OPTIONS.rst | 8 +- Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst | 39 +++++++++ .../CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP.rst | 9 ++ Modules/Compiler/ARMCC.cmake | 2 + Modules/Compiler/Absoft-Fortran.cmake | 1 + Modules/Compiler/Bruce-C.cmake | 2 + Modules/Compiler/Clang.cmake | 2 + Modules/Compiler/G95-Fortran.cmake | 2 + Modules/Compiler/GNU.cmake | 3 + Modules/Compiler/HP-C.cmake | 3 + Modules/Compiler/HP-CXX.cmake | 3 + Modules/Compiler/HP-Fortran.cmake | 3 + Modules/Compiler/PGI.cmake | 3 + Modules/Compiler/QCC.cmake | 3 + Modules/Compiler/SCO.cmake | 3 + Modules/Compiler/SunPro-C.cmake | 3 + Modules/Compiler/SunPro-CXX.cmake | 3 + Modules/Compiler/SunPro-Fortran.cmake | 3 + Modules/Compiler/TinyCC-C.cmake | 3 + Modules/Compiler/XL.cmake | 3 + Modules/Platform/Apple-Intel.cmake | 3 + Modules/Platform/Generic-ADSP-C.cmake | 4 +- Modules/Platform/Generic-ADSP-CXX.cmake | 4 +- Modules/Platform/Generic-SDCC-C.cmake | 3 +- Modules/Platform/Linux-Intel.cmake | 3 + Modules/Platform/Windows-Embarcadero.cmake | 2 + Source/cmGeneratorTarget.cxx | 96 +++++++++++++++++++++- .../LINKER_SHELL_expansion-build-check.cmake | 2 + .../add_link_options/LINKER_SHELL_expansion.cmake | 4 + .../LINKER_expansion-build-check.cmake | 2 + .../add_link_options/LINKER_expansion-list.cmake | 36 ++++++++ .../LINKER_expansion-validation.cmake | 15 ++++ .../add_link_options/LINKER_expansion.cmake | 4 + Tests/RunCMake/add_link_options/RunCMakeTest.cmake | 10 +++ .../add_link_options/bad_SHELL_usage-result.txt | 1 + .../add_link_options/bad_SHELL_usage-stderr.txt | 4 + .../add_link_options/bad_SHELL_usage.cmake | 6 ++ Tests/RunCMake/add_link_options/dump.c | 13 +++ .../LINKER_expansion-LINKER-check.cmake | 2 + .../LINKER_expansion-LINKER_SHELL-check.cmake | 2 + .../LINKER_expansion-validation.cmake | 15 ++++ .../target_link_options/LINKER_expansion.cmake | 49 +++++++++++ .../target_link_options/RunCMakeTest.cmake | 35 ++------ .../target_link_options/bad_SHELL_usage-result.txt | 1 + .../target_link_options/bad_SHELL_usage-stderr.txt | 4 + .../target_link_options/bad_SHELL_usage.cmake | 5 ++ Tests/RunCMake/target_link_options/dump.c | 13 +++ 51 files changed, 423 insertions(+), 42 deletions(-) create mode 100644 Help/command/LINK_OPTIONS_LINKER.txt create mode 100644 Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst create mode 100644 Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP.rst create mode 100644 Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake create mode 100644 Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake create mode 100644 Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake create mode 100644 Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake create mode 100644 Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake create mode 100644 Tests/RunCMake/add_link_options/LINKER_expansion.cmake create mode 100644 Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt create mode 100644 Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt create mode 100644 Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake create mode 100644 Tests/RunCMake/add_link_options/dump.c create mode 100644 Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake create mode 100644 Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake create mode 100644 Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake create mode 100644 Tests/RunCMake/target_link_options/LINKER_expansion.cmake create mode 100644 Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt create mode 100644 Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt create mode 100644 Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake create mode 100644 Tests/RunCMake/target_link_options/dump.c diff --git a/Help/command/LINK_OPTIONS_LINKER.txt b/Help/command/LINK_OPTIONS_LINKER.txt new file mode 100644 index 0000000..76927be --- /dev/null +++ b/Help/command/LINK_OPTIONS_LINKER.txt @@ -0,0 +1,10 @@ +To pass options to the linker tool, each compiler driver has is own syntax. +The ``LINKER:`` prefix can be used to specify, in a portable way, options +to pass to the linker tool. The ``LINKER:`` prefix is replaced by the required +driver option and the rest of the option string defines linker arguments using +``,`` as separator. These arguments will be formatted according to the +:variable:`CMAKE__LINKER_WRAPPER_FLAG` and +:variable:`CMAKE__LINKER_WRAPPER_FLAG_SEP` variables. + +For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for +``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``. diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst index c827d70..821198d 100644 --- a/Help/command/add_link_options.rst +++ b/Help/command/add_link_options.rst @@ -7,12 +7,12 @@ Adds options to the link of targets. add_link_options(