diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 766dff4550..1ea48c04b5 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -143,6 +143,7 @@ syn keyword cmakeProperty contained \ COMPILE_PDB_NAME \ COMPILE_PDB_OUTPUT_DIRECTORY \ COMPILE_WARNING_AS_ERROR + \ COMPILE_WRAPPERS \ COST \ CPACK_DESKTOP_SHORTCUTS \ CPACK_NEVER_OVERWRITE @@ -279,6 +280,7 @@ syn keyword cmakeProperty contained \ INTERFACE_COMPILE_DEFINITIONS \ INTERFACE_COMPILE_FEATURES \ INTERFACE_COMPILE_OPTIONS + \ INTERFACE_COMPILE_WRAPPERS \ INTERFACE_CXX_MODULE_SETS \ INTERFACE_HEADER_SETS \ INTERFACE_HEADER_SETS_TO_VERIFY @@ -289,6 +291,7 @@ syn keyword cmakeProperty contained \ INTERFACE_LINK_LIBRARIES_DIRECT \ INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE \ INTERFACE_LINK_OPTIONS + \ INTERFACE_LINK_WRAPPERS \ INTERFACE_POSITION_INDEPENDENT_CODE \ INTERFACE_PRECOMPILE_HEADERS \ INTERFACE_SOURCES @@ -325,6 +328,7 @@ syn keyword cmakeProperty contained \ LINK_SEARCH_START_STATIC \ LINK_WARNING_AS_ERROR \ LINK_WHAT_YOU_USE + \ LINK_WRAPPERS \ LISTFILE_STACK \ LOCATION \ MACHO_COMPATIBILITY_VERSION diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index 761ce60efa..a4e0f9d0a8 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -570,6 +570,12 @@ for compiling a target. List of header files to precompile and include when compiling sources in the target. +:prop_tgt:`COMPILE_WRAPPERS` + .. versionadded:: 4.5 + + List of wrapper names to be prepended to the compile commands for a target's + sources. See also :prop_gbl:`CMAKE_COMPILE_WRAPPER_`. + :prop_tgt:`AUTOMOC_MACRO_NAMES` .. versionadded:: 3.10 @@ -627,6 +633,13 @@ for linking a target. via :prop_tgt:`LINK_OPTIONS` may be listed here such that changing them causes binaries to be linked again. +:prop_tgt:`LINK_WRAPPERS` + .. versionadded:: 4.5 + + List of wrapper names to be prepended to the link command for a target's + output artifact, if it is an executable, shared library, or module library. + See also :prop_gbl:`CMAKE_LINK_WRAPPER_`. + .. _`Target Usage Requirements`: Target Usage Requirements @@ -760,6 +773,13 @@ compiling consumers. List of header files to precompile and include when compiling sources in the target's consumers. +:prop_tgt:`INTERFACE_COMPILE_WRAPPERS` + .. versionadded:: 4.5 + + List of wrapper names to be prepended to the compile commands when compiling + sources in the target's consumers. See also + :prop_gbl:`CMAKE_COMPILE_WRAPPER_`. + :prop_tgt:`INTERFACE_AUTOMOC_MACRO_NAMES` .. versionadded:: 3.27 @@ -809,6 +829,13 @@ linking consumers. List of files on which linking the target's consumers depends, for those that are executables, shared libraries, or module libraries. +:prop_tgt:`INTERFACE_LINK_WRAPPERS` + .. versionadded:: 4.5 + + List of wrapper names to be prepended to the link commands for a target's + consumers' output artifact, for those that are executables, shared libraries, + and module libraries. See also :prop_gbl:`CMAKE_LINK_WRAPPER_`. + .. _`Custom Transitive Properties`: Custom Transitive Properties diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 629336a621..8e46870e68 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -23,9 +23,11 @@ Properties of Global Scope /prop_gbl/AUTORCC_SOURCE_GROUP /prop_gbl/AUTOUIC_SOURCE_GROUP /prop_gbl/CMAKE_C_KNOWN_FEATURES + /prop_gbl/CMAKE_COMPILE_WRAPPER_NAME /prop_gbl/CMAKE_CUDA_KNOWN_FEATURES /prop_gbl/CMAKE_CXX_KNOWN_FEATURES /prop_gbl/CMAKE_HIP_KNOWN_FEATURES + /prop_gbl/CMAKE_LINK_WRAPPER_NAME /prop_gbl/CMAKE_ROLE /prop_gbl/DEBUG_CONFIGURATIONS /prop_gbl/DISABLED_FEATURES @@ -213,6 +215,7 @@ Properties on Targets /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /prop_tgt/COMPILE_WARNING_AS_ERROR + /prop_tgt/COMPILE_WRAPPERS /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX /prop_tgt/CROSSCOMPILING_EMULATOR @@ -329,6 +332,7 @@ Properties on Targets /prop_tgt/INTERFACE_COMPILE_DEFINITIONS /prop_tgt/INTERFACE_COMPILE_FEATURES /prop_tgt/INTERFACE_COMPILE_OPTIONS + /prop_tgt/INTERFACE_COMPILE_WRAPPERS /prop_tgt/INTERFACE_CXX_MODULE_SETS /prop_tgt/INTERFACE_FILE_SETS_TYPE /prop_tgt/INTERFACE_HEADER_SETS @@ -340,6 +344,7 @@ Properties on Targets /prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT /prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE /prop_tgt/INTERFACE_LINK_OPTIONS + /prop_tgt/INTERFACE_LINK_WRAPPERS /prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE /prop_tgt/INTERFACE_PRECOMPILE_HEADERS /prop_tgt/INTERFACE_SOURCE_SETS @@ -390,6 +395,7 @@ Properties on Targets /prop_tgt/LINK_SEARCH_START_STATIC /prop_tgt/LINK_WARNING_AS_ERROR /prop_tgt/LINK_WHAT_YOU_USE + /prop_tgt/LINK_WRAPPERS /prop_tgt/LINKER_LANGUAGE /prop_tgt/LINKER_TYPE /prop_tgt/LOCATION diff --git a/Help/prop_gbl/CMAKE_COMPILE_WRAPPER_NAME.rst b/Help/prop_gbl/CMAKE_COMPILE_WRAPPER_NAME.rst new file mode 100644 index 0000000000..413ef30376 --- /dev/null +++ b/Help/prop_gbl/CMAKE_COMPILE_WRAPPER_NAME.rst @@ -0,0 +1,67 @@ +CMAKE_COMPILE_WRAPPER_ +---------------------------- + +.. versionadded:: 4.5 + +Command line to be prepended to compile commands. + +This property holds a command line to be used with the +:prop_tgt:`COMPILE_WRAPPERS` and/or :prop_tgt:`INTERFACE_COMPILE_WRAPPERS` +target properties. Named values in those target properties (which are +:ref:`semicolon-separated lists `) will reference the +correspondingly-named ``CMAKE_COMPILE_WRAPPER_`` and prepend the compile +command(s) for source(s) of the given target or its consumer(s) with the value +of this property. + +This property is supported only by :ref:`Makefile Generators` and +:ref:`Ninja Generators`, and is ignored by other generators. + +The value is a :ref:`semicolon-separated list ` of +command line arguments. Empty arguments are preserved, and a literal +semicolon within an argument may be written as ``\;``. + +Contents of ``CMAKE_COMPILE_WRAPPER_`` may use "generator expressions" +with 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. + +Example +^^^^^^^ + +Consider the following example: + +.. code-block:: cmake + + add_library(iface INTERFACE) + add_executable(main main.c) + target_link_libraries(main PRIVATE iface) + + set_property(GLOBAL + PROPERTY CMAKE_COMPILE_WRAPPER_2_PYTHON_WRAPPER + "${Python_EXECUTABLE}" my_wrapper.py + ) + set_property(GLOBAL + PROPERTY CMAKE_COMPILE_WRAPPER_1_TIME + "${CMAKE_COMMAND}" -E time + ) + + set_target_properties(iface PROPERTIES + INTERFACE_COMPILE_WRAPPERS 1_TIME + ) + set_target_properties(main PROPERTIES + COMPILE_WRAPPERS 2_PYTHON_WRAPPER + ) + +Here, all compile commands for the sources of ``main`` will look like: + +.. code-block:: shell + + /path/to/cmake -E time /path/to/python my_wrapper.py ... + +See Also +^^^^^^^^ + +* :prop_gbl:`CMAKE_LINK_WRAPPER_` +* :prop_tgt:`COMPILE_WRAPPERS` +* :prop_tgt:`INTERFACE_COMPILE_WRAPPERS` +* :prop_tgt:`_COMPILER_LAUNCHER` diff --git a/Help/prop_gbl/CMAKE_LINK_WRAPPER_NAME.rst b/Help/prop_gbl/CMAKE_LINK_WRAPPER_NAME.rst new file mode 100644 index 0000000000..4375fb3b7b --- /dev/null +++ b/Help/prop_gbl/CMAKE_LINK_WRAPPER_NAME.rst @@ -0,0 +1,65 @@ +CMAKE_LINK_WRAPPER_ +------------------------- + +.. versionadded:: 4.5 + +Command line to be prepended to link commands. + +This property holds a command line to be used with the +:prop_tgt:`LINK_WRAPPERS` and/or :prop_tgt:`INTERFACE_LINK_WRAPPERS` +target properties. Named values in those properties (which are +:ref:`semicolon-separated lists `) will reference the +correspondingly-named ``CMAKE_LINK_WRAPPER_`` and prepend the link +command for the output artifact of the given target or its consumer(s) with the +value of this property. + +This property is supported only by :ref:`Makefile Generators` and +:ref:`Ninja Generators`, and is ignored by other generators. + +The value is a :ref:`semicolon-separated list ` of +command line arguments. Empty arguments are preserved, and a literal +semicolon within an argument may be written as ``\;``. + +Contents of ``CMAKE_LINK_WRAPPER_`` may use "generator expressions" +with 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. + +Example +^^^^^^^ + +.. code-block:: cmake + + add_library(iface INTERFACE) + add_executable(main main.c) + target_link_libraries(main PRIVATE iface) + + set_property(GLOBAL + PROPERTY CMAKE_LINK_WRAPPER_2_PYTHON_WRAPPER + "${Python_EXECUTABLE}" my_wrapper.py + ) + set_property(GLOBAL + PROPERTY CMAKE_LINK_WRAPPER_1_TIME + "${CMAKE_COMMAND}" -E time + ) + + set_target_properties(iface PROPERTIES + INTERFACE_LINK_WRAPPERS 1_TIME + ) + set_target_properties(main PROPERTIES + LINK_WRAPPERS 2_PYTHON_WRAPPER + ) + +Here, the link command for ``main`` will look like: + +.. code-block:: shell + + /path/to/cmake -E time /path/to/python my_wrapper.py ... + +See Also +^^^^^^^^ + +* :prop_gbl:`CMAKE_COMPILE_WRAPPER_` +* :prop_tgt:`INTERFACE_LINK_WRAPPERS` +* :prop_tgt:`LINK_WRAPPERS` +* :prop_tgt:`_LINKER_LAUNCHER` diff --git a/Help/prop_tgt/COMPILE_WRAPPERS.rst b/Help/prop_tgt/COMPILE_WRAPPERS.rst new file mode 100644 index 0000000000..054341e0df --- /dev/null +++ b/Help/prop_tgt/COMPILE_WRAPPERS.rst @@ -0,0 +1,59 @@ +COMPILE_WRAPPERS +---------------- + +.. versionadded:: 4.5 + +List of wrapper names to be prepended to the compile commands for a target's +sources. + +This property holds a :ref:`semicolon-separated list ` +of names, where each item is a ```` keyed to the +:prop_gbl:`CMAKE_COMPILE_WRAPPER_` global property. + +.. note:: + + If a target has multiple wrappers, either via its ``COMPILE_WRAPPERS`` and/or + the :prop_tgt:`INTERFACE_COMPILE_WRAPPERS` inherited from its dependents, the + wrappers will be deduplicated and ordered lexicographically based on their + name in the resulting compile command(s). + +This property is supported only by :ref:`Makefile Generators` and +:ref:`Ninja Generators`, and is ignored by other generators. Further, it is +supported only when the target's language is one of: ``C``, ``CXX``, ``CUDA``, +``Fortran``, ``HIP``, ``ISPC``, ``OBJC``, ``OBJCXX``. + +Contents of ``COMPILE_WRAPPERS`` may use "generator expressions" with 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. + +Interaction With Launchers +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Wrappers are placed *outside* of any :prop_tgt:`_COMPILER_LAUNCHER`. +The resulting compile command is: + +.. code-block:: shell + + + +A tool that expects to be given the compiler as its first argument, such as +``ccache`` or ``distcc``, should be used as a launcher rather than a wrapper. + +When a static analysis tool is enabled for a source via +:prop_tgt:`_CLANG_TIDY`, :prop_tgt:`_CPPCHECK`, +:prop_tgt:`_CPPLINT`, :prop_tgt:`_INCLUDE_WHAT_YOU_USE`, or a +similar property, the wrappers and the launcher apply only to the compiler +invocation and *not* to the analysis tool. + +The launcher used by :manual:`ctest(1)` (see :variable:`CTEST_USE_LAUNCHERS`) +remains outermost and runs the wrappers as part of the command it launches. + +See Also +^^^^^^^^ + +Related properties: + +* :prop_tgt:`INTERFACE_COMPILE_WRAPPERS` +* :prop_tgt:`_COMPILER_LAUNCHER` +* :prop_tgt:`LINK_WRAPPERS` diff --git a/Help/prop_tgt/INTERFACE_COMPILE_WRAPPERS.rst b/Help/prop_tgt/INTERFACE_COMPILE_WRAPPERS.rst new file mode 100644 index 0000000000..5abec254a6 --- /dev/null +++ b/Help/prop_tgt/INTERFACE_COMPILE_WRAPPERS.rst @@ -0,0 +1,17 @@ +INTERFACE_COMPILE_WRAPPERS +-------------------------- + +.. versionadded:: 4.5 + +.. |property_name| replace:: compile wrappers +.. |command_name| replace:: :command:`target_link_libraries` +.. |PROPERTY_INTERFACE_NAME| replace:: ``INTERFACE_COMPILE_WRAPPERS`` +.. |PROPERTY_LINK| replace:: :prop_tgt:`COMPILE_WRAPPERS` +.. include:: include/INTERFACE_BUILD_PROPERTY.rst + +See Also +^^^^^^^^ + +Related properties: + +* :prop_tgt:`COMPILE_WRAPPERS` diff --git a/Help/prop_tgt/INTERFACE_LINK_WRAPPERS.rst b/Help/prop_tgt/INTERFACE_LINK_WRAPPERS.rst new file mode 100644 index 0000000000..1da83b6509 --- /dev/null +++ b/Help/prop_tgt/INTERFACE_LINK_WRAPPERS.rst @@ -0,0 +1,17 @@ +INTERFACE_LINK_WRAPPERS +----------------------- + +.. versionadded:: 4.5 + +.. |property_name| replace:: link wrappers +.. |command_name| replace:: :command:`target_link_libraries` +.. |PROPERTY_INTERFACE_NAME| replace:: ``INTERFACE_LINK_WRAPPERS`` +.. |PROPERTY_LINK| replace:: :prop_tgt:`LINK_WRAPPERS` +.. include:: include/INTERFACE_BUILD_PROPERTY.rst + +See Also +^^^^^^^^ + +Related properties: + +* :prop_tgt:`LINK_WRAPPERS` diff --git a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst index 2e039bd3a1..df7c56a957 100644 --- a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst +++ b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst @@ -19,3 +19,9 @@ when a target is created. The property value may use :manual:`generator expressions `. + +.. versionadded:: 4.5 + + Any wrappers specified by :prop_tgt:`COMPILE_WRAPPERS` and + :prop_tgt:`INTERFACE_COMPILE_WRAPPERS` are placed before the launcher + command line. See :prop_tgt:`COMPILE_WRAPPERS` for details. diff --git a/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst b/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst index 86f5f871fd..307f62771a 100644 --- a/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst +++ b/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst @@ -38,3 +38,12 @@ created. The property value may use :manual:`generator expressions `. + +The launcher is used only for linking executables, shared libraries, and +module libraries. It is not used when creating static libraries. + +.. versionadded:: 4.5 + + Any wrappers specified by :prop_tgt:`LINK_WRAPPERS` and + :prop_tgt:`INTERFACE_LINK_WRAPPERS` are placed before the launcher command + line. See :prop_tgt:`LINK_WRAPPERS` for details. diff --git a/Help/prop_tgt/LINK_WRAPPERS.rst b/Help/prop_tgt/LINK_WRAPPERS.rst new file mode 100644 index 0000000000..ce51132acb --- /dev/null +++ b/Help/prop_tgt/LINK_WRAPPERS.rst @@ -0,0 +1,55 @@ +LINK_WRAPPERS +------------- + +.. versionadded:: 4.5 + +List of wrapper names to be prepended to the link commands for a target's +output artifact. + +This property holds a :ref:`semicolon-separated list ` +of names, where each item is a ```` keyed to the +:prop_gbl:`CMAKE_LINK_WRAPPER_` global property. + +.. note:: + + If a target has multiple wrappers, either via its ``LINK_WRAPPERS`` and/or + the :prop_tgt:`INTERFACE_LINK_WRAPPERS` inherited from its dependents, the + wrappers will be deduplicated and ordered lexicographically based on their + name in the resulting link command(s). + +This property is supported only by :ref:`Makefile Generators` and +:ref:`Ninja Generators`, and is ignored by other generators. Further, it is +supported only when the target's language is one of: ``C``, ``CXX``, ``CUDA``, +``OBJC``, ``OBJCXX``, ``Fortran``, ``HIP``. + +Contents of ``LINK_WRAPPERS`` may use "generator expressions" with 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. + +Wrappers apply to the link command of executables, shared libraries, and +module libraries. As with :prop_tgt:`_LINKER_LAUNCHER`, they do not +apply to ``STATIC`` libraries, which are created by the archiver rather than +the linker. + +Interaction With Launchers +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Wrappers are placed *outside* of any :prop_tgt:`_LINKER_LAUNCHER`. +The resulting link command is: + +.. code-block:: shell + + + +The launcher used by :manual:`ctest(1)` (see :variable:`CTEST_USE_LAUNCHERS`) +remains outermost and runs the wrappers as part of the command it launches. + +See Also +^^^^^^^^ + +Related properties: + +* :prop_tgt:`COMPILE_WRAPPERS` +* :prop_tgt:`INTERFACE_LINK_WRAPPERS` +* :prop_tgt:`_LINKER_LAUNCHER` diff --git a/Help/release/dev/interface-compile-link-wrappers.rst b/Help/release/dev/interface-compile-link-wrappers.rst new file mode 100644 index 0000000000..e0b50f4884 --- /dev/null +++ b/Help/release/dev/interface-compile-link-wrappers.rst @@ -0,0 +1,11 @@ +interface-compile-link-wrappers +------------------------------- + +* The :prop_gbl:`CMAKE_COMPILE_WRAPPER_` and + :prop_gbl:`CMAKE_LINK_WRAPPER_` global properties were added alongside + the :prop_tgt:`COMPILE_WRAPPERS`, :prop_tgt:`LINK_WRAPPERS`, + :prop_tgt:`INTERFACE_COMPILE_WRAPPERS`, and + :prop_tgt:`INTERFACE_LINK_WRAPPERS` target properties. Together, for the + :ref:`Makefile Generators` and :ref:`Ninja Generators`, they support wrapping + compile and link commands for a given target or its consumers with arbitrary + command lines. diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index a1fa1fffa2..2ab4bdc336 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -8,13 +8,29 @@ debug output for when evaluating target properties. Currently it can only be used when evaluating: * :prop_tgt:`AUTOUIC_OPTIONS` + * :prop_tgt:`COMPILE_DEFINITIONS` + * :prop_tgt:`COMPILE_FEATURES` + * :prop_tgt:`COMPILE_OPTIONS` + +* :prop_tgt:`COMPILE_WRAPPERS` + + .. versionadded:: 4.5 + * :prop_tgt:`INCLUDE_DIRECTORIES` + * :prop_tgt:`LINK_DIRECTORIES` + * :prop_tgt:`LINK_OPTIONS` + +* :prop_tgt:`LINK_WRAPPERS` + + .. versionadded:: 4.5 + * :prop_tgt:`POSITION_INDEPENDENT_CODE` + * :prop_tgt:`SOURCES` target properties and any other property listed in diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ce6b1c1383..57126c16c0 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -336,6 +336,7 @@ add_library( cmGeneratorTarget_Options.cxx cmGeneratorTarget_Sources.cxx cmGeneratorTarget_TransitiveProperty.cxx + cmGeneratorTarget_Wrappers.cxx cmLinkItemGraphVisitor.cxx cmLinkItemGraphVisitor.h cmGetPipes.cxx diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index aca2f1dce5..a698df8826 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmGlobalCommonGenerator.h" #include "cmGlobalGenerator.h" #include "cmList.h" +#include "cmListFileCache.h" #include "cmLocalCommonGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -427,6 +428,21 @@ std::vector cmCommonTargetGenerator::GetCompilerLauncher( std::vector compilerLauncher; if (lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" || lang == "HIP" || lang == "ISPC" || lang == "OBJC" || lang == "OBJCXX") { + // FIXME(#27402,#28110): The FASTBuild generator's limitations w.r.t. + // shell escaping and command line ordering means we can't support + // wrappers for now. + std::string const generatorName = + this->GeneratorTarget->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetName(); + if (generatorName.find("FASTBuild") == std::string::npos) { + // Wrappers go outside of the launcher. + compilerLauncher = this->ParseWrappers( + this->GeneratorTarget->GetCompileWrappers(config, lang), + "CMAKE_COMPILE_WRAPPER_"_s, "COMPILE_WRAPPERS"_s, + this->GeneratorTarget->GetName(), config, lang); + } + std::string const propName = cmStrCat(lang, "_COMPILER_LAUNCHER"); cmValue cLauncherValue = this->GeneratorTarget->GetProperty(propName); std::string const evaluatedCLauncher = cmGeneratorExpression::Evaluate( @@ -647,6 +663,21 @@ std::vector cmCommonTargetGenerator::GetLinkerLauncher( { std::vector linkLauncher; std::string const lang = this->GeneratorTarget->GetLinkerLanguage(config); + + // FIXME(#27402,#28110): The FASTBuild generator's limitations w.r.t. + // shell escaping and command line ordering means we can't support + // wrappers for now. + std::string const generatorName = this->GeneratorTarget->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetName(); + if (generatorName.find("FASTBuild") == std::string::npos) { + // Wrappers go outside of the launcher. + linkLauncher = + this->ParseWrappers(this->GeneratorTarget->GetLinkWrappers(config, lang), + "CMAKE_LINK_WRAPPER_"_s, "LINK_WRAPPERS"_s, + this->GeneratorTarget->GetName(), config, lang); + } + std::string const propName = cmStrCat(lang, "_LINKER_LAUNCHER"); cmValue launcherProp = this->GeneratorTarget->GetProperty(propName); if (cmNonempty(launcherProp)) { @@ -735,3 +766,46 @@ void cmCommonTargetGenerator::ComputeRustFlagsForObjects( processObject(obj); } } + +std::vector cmCommonTargetGenerator::ParseWrappers( + std::vector> const& wrappers, cm::string_view prefix, + cm::string_view targetPropName, std::string const& targetName, + std::string const& config, std::string const& lang) const +{ + std::vector wrapperCommandLine; + if (wrappers.empty()) { + return wrapperCommandLine; + } + + cm::GenEx::Context context(this->LocalCommonGenerator, config, lang); + + for (BT const& wrapper : wrappers) { + std::string const wrapperPropName = cmStrCat(prefix, wrapper.Value); + cmValue globalPropValue = + this->Makefile->GetState()->GetGlobalProperty(wrapperPropName); + if (!globalPropValue.IsSet()) { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Specified wrapper \'", wrapper.Value, "\' for target \'", + targetName, "\' does not exist. Set the GLOBAL property \'", + wrapperPropName, "\'."), + wrapper.Backtrace); + return {}; + } + + cmGeneratorExpressionDAGChecker dagChecker{ this->GeneratorTarget, + std::string(targetPropName), + nullptr, nullptr, context }; + std::string const evaluatedWrapper = cmGeneratorExpression::Evaluate( + *globalPropValue, context.LG, context.Config, this->GeneratorTarget, + &dagChecker, this->GeneratorTarget, context.Language); + // An empty definition is a no-op wrapper, but empty arguments within a + // non-empty definition must reach the command line. + if (!evaluatedWrapper.empty()) { + cm::append(wrapperCommandLine, + cmList{ evaluatedWrapper, cmList::EmptyElements::Yes }); + } + } + + return wrapperCommandLine; +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 74c4604f89..7ce8d0142d 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -10,8 +10,12 @@ #include #include +#include + #include "cmValue.h" +template +class BT; class cmGeneratorTarget; class cmGlobalCommonGenerator; class cmLocalCommonGenerator; @@ -97,6 +101,11 @@ protected: std::string& nativeObjects, std::vector const& objects); + std::vector ParseWrappers( + std::vector> const& wrappers, cm::string_view prefix, + cm::string_view targetPropName, std::string const& targetName, + std::string const& config, std::string const& lang) const; + private: using ByLanguageMap = std::map; struct ByConfig diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 77946f3115..94c8f45686 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -159,7 +159,8 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileExpression() const cm::string_view property(this->Top->Property); return property == "INCLUDE_DIRECTORIES"_s || - property == "COMPILE_DEFINITIONS"_s || property == "COMPILE_OPTIONS"_s; + property == "COMPILE_DEFINITIONS"_s || property == "COMPILE_OPTIONS"_s || + property == "COMPILE_WRAPPERS"_s; } bool cmGeneratorExpressionDAGChecker::EvaluatingSources() const @@ -174,7 +175,7 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const return property == "LINK_DIRECTORIES"_s || property == "LINK_OPTIONS"_s || property == "LINK_DEPENDS"_s || property == "LINK_LIBRARY_OVERRIDE"_s || - property == "LINKER_TYPE"_s; + property == "LINKER_TYPE"_s || property == "LINK_WRAPPERS"_s; } bool cmGeneratorExpressionDAGChecker::EvaluatingLinkOptionsExpression() const diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 4d2f2d26aa..d23b9da099 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -3499,8 +3499,8 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode reportError( eval, content->GetOriginalExpression(), "$ may only be used to specify include " - "directories, compile definitions, compile options, and to evaluate " - "components of the file(GENERATE) command."); + "directories, compile definitions, compile options, compile wrappers, " + "and to evaluate components of the file(GENERATE) command."); return std::string(); } @@ -3549,9 +3549,9 @@ static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode eval, content->GetOriginalExpression(), "$ may only be used with binary " "targets " - "to specify include directories, compile definitions, and compile " - "options. It may not be used with the add_custom_command, " - "add_custom_target, or file(GENERATE) commands."); + "to specify include directories, compile definitions, compile " + "options, and compile wrappers. It may not be used with the " + "add_custom_command, add_custom_target, or file(GENERATE) commands."); return std::string(); } cmGlobalGenerator const* gg = eval->Context.LG->GetGlobalGenerator(); @@ -3597,8 +3597,8 @@ static const struct LinkLanguageNode : public cmGeneratorExpressionNode dagChecker->EvaluatingLinkerLauncher())) { reportError(eval, content->GetOriginalExpression(), "$ may only be used with binary targets " - "to specify link libraries, link directories, link options " - "and link depends."); + "to specify link libraries, link directories, link options, " + "link depends, and link wrappers."); return std::string(); } if (dagChecker->EvaluatingLinkLibraries() && parameters.empty()) { @@ -3693,9 +3693,8 @@ static const struct LinkLanguageAndIdNode : public cmGeneratorExpressionNode reportError( eval, content->GetOriginalExpression(), "$ may only be used with binary targets " - "to specify link libraries, link directories, link options, and " - "link " - "depends."); + "to specify link libraries, link directories, link options, link " + "depends, and link wrappers."); return std::string(); } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d03a8145ed..4f957181b5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -114,6 +114,10 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileDefinitionsEntries(), this->CompileDefinitionsEntries); + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetCompileWrappersEntries(), + this->CompileWrappersEntries); + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), t->GetLinkOptionsEntries(), this->LinkOptionsEntries); @@ -122,6 +126,10 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetLinkDirectoriesEntries(), this->LinkDirectoriesEntries); + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetLinkWrappersEntries(), + this->LinkWrappersEntries); + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), t->GetPrecompileHeadersEntries(), this->PrecompileHeadersEntries); @@ -544,9 +552,11 @@ void cmGeneratorTarget::ClearSourcesCache() this->LinkImplClosureForUsageMap.clear(); this->LinkImplMap.clear(); this->LinkImplUsageRequirementsOnlyMap.clear(); + this->LinkWrappersCache.clear(); this->IncludeDirectoriesCache.clear(); this->CompileOptionsCache.clear(); this->CompileDefinitionsCache.clear(); + this->CompileWrappersCache.clear(); this->CustomTransitiveBuildPropertiesMap.clear(); this->CustomTransitiveInterfacePropertiesMap.clear(); this->PrecompileHeadersCache.clear(); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2e7497d31b..8ea1a9e5ad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -673,11 +673,19 @@ private: mutable ConfigAndLanguageToBTStrings IncludeDirectoriesCache; mutable ConfigAndLanguageToBTStrings CompileOptionsCache; mutable ConfigAndLanguageToBTStrings CompileDefinitionsCache; + mutable ConfigAndLanguageToBTStrings CompileWrappersCache; mutable ConfigAndLanguageToBTStrings PrecompileHeadersCache; mutable ConfigAndLanguageToBTStrings LinkOptionsCache; mutable ConfigAndLanguageToBTStrings LinkDirectoriesCache; + mutable ConfigAndLanguageToBTStrings LinkWrappersCache; public: + /** Get the wrapper entries for this target. */ + std::vector> GetCompileWrappers( + std::string const& config, std::string const& lang) const; + std::vector> GetLinkWrappers(std::string const& config, + std::string const& lang) const; + /** Get the include directories for this target. */ std::vector> GetIncludeDirectories( std::string const& config, std::string const& lang) const; @@ -1383,8 +1391,10 @@ private: TargetPropertyEntryVector CompileOptionsEntries; TargetPropertyEntryVector CompileFeaturesEntries; TargetPropertyEntryVector CompileDefinitionsEntries; + TargetPropertyEntryVector CompileWrappersEntries; TargetPropertyEntryVector LinkOptionsEntries; TargetPropertyEntryVector LinkDirectoriesEntries; + TargetPropertyEntryVector LinkWrappersEntries; TargetPropertyEntryVector PrecompileHeadersEntries; TargetPropertyEntryVector SourceEntries; mutable std::set LinkImplicitNullProperties; @@ -1470,11 +1480,13 @@ private: mutable bool DebugCompileOptionsDone = false; mutable bool DebugCompileFeaturesDone = false; mutable bool DebugCompileDefinitionsDone = false; + mutable bool DebugCompileWrappersDone = false; mutable bool DebugLinkOptionsDone = false; mutable bool DebugLinkDirectoriesDone = false; mutable bool DebugPrecompileHeadersDone = false; mutable bool DebugSourcesDone = false; mutable bool UtilityItemsDone = false; + mutable bool DebugLinkWrappersDone = false; enum class Tribool { False = 0x0, diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index d20819b5c6..3a7c39a490 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -48,12 +48,15 @@ std::map const { "COMPILE_FEATURES"_s, { "INTERFACE_COMPILE_FEATURES"_s, UseTo::Compile } }, { "COMPILE_OPTIONS"_s, { "INTERFACE_COMPILE_OPTIONS"_s, UseTo::Compile } }, + { "COMPILE_WRAPPERS"_s, + { "INTERFACE_COMPILE_WRAPPERS"_s, UseTo::Compile } }, { "INCLUDE_DIRECTORIES"_s, { "INTERFACE_INCLUDE_DIRECTORIES"_s, UseTo::Compile } }, { "LINK_DEPENDS"_s, { "INTERFACE_LINK_DEPENDS"_s, UseTo::Link } }, { "LINK_DIRECTORIES"_s, { "INTERFACE_LINK_DIRECTORIES"_s, UseTo::Link } }, { "LINK_LIBRARIES"_s, { "INTERFACE_LINK_LIBRARIES"_s, UseTo::Link } }, { "LINK_OPTIONS"_s, { "INTERFACE_LINK_OPTIONS"_s, UseTo::Link } }, + { "LINK_WRAPPERS"_s, { "INTERFACE_LINK_WRAPPERS"_s, UseTo::Link } }, { "PRECOMPILE_HEADERS"_s, { "INTERFACE_PRECOMPILE_HEADERS"_s, UseTo::Compile } }, { "SOURCES"_s, { "INTERFACE_SOURCES"_s, UseTo::Compile } }, diff --git a/Source/cmGeneratorTarget_Wrappers.cxx b/Source/cmGeneratorTarget_Wrappers.cxx new file mode 100644 index 0000000000..c8556b4534 --- /dev/null +++ b/Source/cmGeneratorTarget_Wrappers.cxx @@ -0,0 +1,155 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file LICENSE.rst or https://cmake.org/licensing for details. */ +/* clang-format off */ +#include "cmGeneratorTarget.h" +/* clang-format on */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "cmEvaluatedTargetProperty.h" +#include "cmGenExContext.h" +#include "cmGeneratorExpressionDAGChecker.h" +#include "cmList.h" +#include "cmListFileCache.h" +#include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmMessageType.h" +#include "cmStringAlgorithms.h" +#include "cmUnreachable.h" +#include "cmValue.h" +#include "cmake.h" + +namespace { + +enum class WrapperType +{ + Compile, + Link, +}; + +std::string WrapperTypeToString(WrapperType type) +{ + switch (type) { + case WrapperType::Compile: + return "compile"; + case WrapperType::Link: + return "link"; + } + CM_UNREACHABLE; +} + +void ProcessWrappers(cmGeneratorTarget const* tgt, + cm::EvaluatedTargetPropertyEntries const& entries, + std::vector>& wrappers, + std::unordered_set& uniqueWrappers, + WrapperType wrapperType, bool debugWrapper) +{ + for (cm::EvaluatedTargetPropertyEntry const& entry : entries.Entries) { + std::string usedOptions; + for (std::string const& entryOption : entry.Values) { + if (uniqueWrappers.insert(entryOption).second) { + wrappers.emplace_back(entryOption, entry.Backtrace); + if (debugWrapper) { + usedOptions = + cmStrCat(std::move(usedOptions), " * ", entryOption, '\n'); + } + } + } + if (!usedOptions.empty()) { + tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage( + MessageType::LOG, + cmStrCat("Used ", WrapperTypeToString(wrapperType), + " wrappers for target ", tgt->GetName(), ":\n", usedOptions), + entry.Backtrace); + } + } + + // Order wrappers lexicographically based on their name. + std::sort(wrappers.begin(), wrappers.end(), + [](BT const& a, BT const& b) { + return a.Value < b.Value; + }); +} +} // namespace + +std::vector> cmGeneratorTarget::GetLinkWrappers( + std::string const& config, std::string const& lang) const +{ + ConfigAndLanguage cacheKey(config, lang); + { + auto it = this->LinkWrappersCache.find(cacheKey); + if (it != this->LinkWrappersCache.end()) { + return it->second; + } + } + + std::vector> wrappers; + std::unordered_set uniqueWrappers; + cm::GenEx::Context context(this->LocalGenerator, config, lang); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "LINK_WRAPPERS", nullptr, nullptr, context, + }; + + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; + bool debugWrappers = !this->DebugLinkWrappersDone && + cm::contains(debugProperties, "LINK_WRAPPERS"); + this->DebugLinkWrappersDone = true; + + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->LinkWrappersEntries); + AddInterfaceEntries(this, "INTERFACE_LINK_WRAPPERS", context, &dagChecker, + entries, cm::IncludeRuntimeInterface::Yes, UseTo::Link); + + ProcessWrappers(this, entries, wrappers, uniqueWrappers, WrapperType::Link, + debugWrappers); + + this->LinkWrappersCache.emplace(cacheKey, wrappers); + return wrappers; +} + +std::vector> cmGeneratorTarget::GetCompileWrappers( + std::string const& config, std::string const& lang) const +{ + ConfigAndLanguage cacheKey(config, lang); + { + auto it = this->CompileWrappersCache.find(cacheKey); + if (it != this->CompileWrappersCache.end()) { + return it->second; + } + } + + std::vector> wrappers; + std::unordered_set uniqueWrappers; + cm::GenEx::Context context(this->LocalGenerator, config, lang); + cmGeneratorExpressionDAGChecker dagChecker{ + this, "COMPILE_WRAPPERS", nullptr, nullptr, context, + }; + + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; + bool debugWrappers = !this->DebugCompileWrappersDone && + cm::contains(debugProperties, "COMPILE_WRAPPERS"); + this->DebugCompileWrappersDone = true; + + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->CompileWrappersEntries); + AddInterfaceEntries(this, "INTERFACE_COMPILE_WRAPPERS", context, &dagChecker, + entries, cm::IncludeRuntimeInterface::Yes, + UseTo::Compile); + + ProcessWrappers(this, entries, wrappers, uniqueWrappers, + WrapperType::Compile, debugWrappers); + + this->CompileWrappersCache.emplace(cacheKey, wrappers); + return wrappers; +} diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 67ecaf727d..5542374673 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -672,14 +672,18 @@ public: UsageRequirementProperty CompileOptions; UsageRequirementProperty CompileFeatures; UsageRequirementProperty CompileDefinitions; + UsageRequirementProperty CompileWrappers; UsageRequirementProperty PrecompileHeaders; UsageRequirementProperty Sources; UsageRequirementProperty LinkOptions; UsageRequirementProperty LinkDirectories; UsageRequirementProperty LinkLibraries; + UsageRequirementProperty LinkWrappers; + UsageRequirementProperty InterfaceCompileWrappers; UsageRequirementProperty InterfaceLinkLibraries; UsageRequirementProperty InterfaceLinkLibrariesDirect; UsageRequirementProperty InterfaceLinkLibrariesDirectExclude; + UsageRequirementProperty InterfaceLinkWrappers; UsageRequirementProperty ImportedCxxModulesIncludeDirectories; UsageRequirementProperty ImportedCxxModulesCompileDefinitions; UsageRequirementProperty ImportedCxxModulesCompileFeatures; @@ -734,15 +738,19 @@ cmTargetInternals::cmTargetInternals(std::string name, cm::TargetType type, , CompileOptions("COMPILE_OPTIONS"_s) , CompileFeatures("COMPILE_FEATURES"_s) , CompileDefinitions("COMPILE_DEFINITIONS"_s) + , CompileWrappers("COMPILE_WRAPPERS"_s) , PrecompileHeaders("PRECOMPILE_HEADERS"_s) , Sources("SOURCES"_s, UsageRequirementProperty::AppendEmpty::Yes) , LinkOptions("LINK_OPTIONS"_s) , LinkDirectories("LINK_DIRECTORIES"_s) , LinkLibraries("LINK_LIBRARIES"_s) + , LinkWrappers("LINK_WRAPPERS"_s) + , InterfaceCompileWrappers("INTERFACE_COMPILE_WRAPPERS"_s) , InterfaceLinkLibraries("INTERFACE_LINK_LIBRARIES"_s) , InterfaceLinkLibrariesDirect("INTERFACE_LINK_LIBRARIES_DIRECT"_s) , InterfaceLinkLibrariesDirectExclude( "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"_s) + , InterfaceLinkWrappers("INTERFACE_LINK_WRAPPERS"_s) , ImportedCxxModulesIncludeDirectories( "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES"_s) , ImportedCxxModulesCompileDefinitions( @@ -1784,6 +1792,11 @@ cmBTStringRange cmTarget::GetCompileDefinitionsEntries() const return cmMakeRange(this->impl->CompileDefinitions.Entries); } +cmBTStringRange cmTarget::GetCompileWrappersEntries() const +{ + return cmMakeRange(this->impl->CompileWrappers.Entries); +} + cmBTStringRange cmTarget::GetPrecompileHeadersEntries() const { return cmMakeRange(this->impl->PrecompileHeaders.Entries); @@ -1799,6 +1812,11 @@ cmBTStringRange cmTarget::GetLinkOptionsEntries() const return cmMakeRange(this->impl->LinkOptions.Entries); } +cmBTStringRange cmTarget::GetLinkWrappersEntries() const +{ + return cmMakeRange(this->impl->LinkWrappers.Entries); +} + cmBTStringRange cmTarget::GetLinkDirectoriesEntries() const { return cmMakeRange(this->impl->LinkDirectories.Entries); @@ -2082,6 +2100,7 @@ MAKE_PROP(OBJCXX_STANDARD); MAKE_PROP(COMPILE_DEFINITIONS); MAKE_PROP(COMPILE_FEATURES); MAKE_PROP(COMPILE_OPTIONS); +MAKE_PROP(COMPILE_WRAPPERS); MAKE_PROP(PRECOMPILE_HEADERS); MAKE_PROP(CUDA_CUBIN_COMPILATION); MAKE_PROP(CUDA_FATBIN_COMPILATION); @@ -2098,6 +2117,7 @@ MAKE_PROP(IMPORTED_CXX_MODULES_COMPILE_OPTIONS); MAKE_PROP(IMPORTED_CXX_MODULES_LINK_LIBRARIES); MAKE_PROP(LINK_DIRECTORIES); MAKE_PROP(LINK_LIBRARIES); +MAKE_PROP(LINK_WRAPPERS); MAKE_PROP(MANUALLY_ADDED_DEPENDENCIES); MAKE_PROP(NAME); MAKE_PROP(SOURCES); @@ -2107,9 +2127,11 @@ MAKE_PROP(BINARY_DIR); MAKE_PROP(SOURCE_DIR); MAKE_PROP(FALSE); MAKE_PROP(TRUE); +MAKE_PROP(INTERFACE_COMPILE_WRAPPERS); MAKE_PROP(INTERFACE_LINK_LIBRARIES); MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT); MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE); +MAKE_PROP(INTERFACE_LINK_WRAPPERS); #undef MAKE_PROP } @@ -2248,14 +2270,18 @@ void cmTarget::SetProperty(std::string const& prop, cmValue value) &this->impl->CompileOptions, &this->impl->CompileFeatures, &this->impl->CompileDefinitions, + &this->impl->CompileWrappers, &this->impl->PrecompileHeaders, &this->impl->Sources, &this->impl->LinkOptions, &this->impl->LinkDirectories, &this->impl->LinkLibraries, + &this->impl->LinkWrappers, + &this->impl->InterfaceCompileWrappers, &this->impl->InterfaceLinkLibraries, &this->impl->InterfaceLinkLibrariesDirect, &this->impl->InterfaceLinkLibrariesDirectExclude, + &this->impl->InterfaceLinkWrappers, &this->impl->ImportedCxxModulesIncludeDirectories, &this->impl->ImportedCxxModulesCompileDefinitions, &this->impl->ImportedCxxModulesCompileFeatures, @@ -2368,14 +2394,18 @@ void cmTarget::AppendProperty(std::string const& prop, &this->impl->CompileOptions, &this->impl->CompileFeatures, &this->impl->CompileDefinitions, + &this->impl->CompileWrappers, &this->impl->PrecompileHeaders, &this->impl->Sources, &this->impl->LinkOptions, &this->impl->LinkDirectories, &this->impl->LinkLibraries, + &this->impl->LinkWrappers, + &this->impl->InterfaceCompileWrappers, &this->impl->InterfaceLinkLibraries, &this->impl->InterfaceLinkLibrariesDirect, &this->impl->InterfaceLinkLibrariesDirectExclude, + &this->impl->InterfaceLinkWrappers, &this->impl->ImportedCxxModulesIncludeDirectories, &this->impl->ImportedCxxModulesCompileDefinitions, &this->impl->ImportedCxxModulesCompileFeatures, @@ -2755,9 +2785,11 @@ std::unordered_set const& cmTarget::GetSpecialPropertyNames() propCOMPILE_FEATURES, propCOMPILE_OPTIONS, propCOMPILE_DEFINITIONS, + propCOMPILE_WRAPPERS, propPRECOMPILE_HEADERS, propLINK_OPTIONS, propLINK_DIRECTORIES, + propLINK_WRAPPERS, propIMPORTED, propIMPORTED_GLOBAL, propMANUALLY_ADDED_DEPENDENCIES, @@ -2766,9 +2798,11 @@ std::unordered_set const& cmTarget::GetSpecialPropertyNames() propSOURCE_DIR, propSOURCES, propSYMBOLIC, + propINTERFACE_COMPILE_WRAPPERS, propINTERFACE_LINK_LIBRARIES, propINTERFACE_LINK_LIBRARIES_DIRECT, propINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE, + propINTERFACE_LINK_WRAPPERS, propIMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES, propIMPORTED_CXX_MODULES_COMPILE_DEFINITIONS, propIMPORTED_CXX_MODULES_COMPILE_FEATURES, @@ -2807,14 +2841,18 @@ cmValue cmTarget::GetProperty(std::string const& prop) const &this->impl->CompileOptions, &this->impl->CompileFeatures, &this->impl->CompileDefinitions, + &this->impl->CompileWrappers, &this->impl->PrecompileHeaders, &this->impl->Sources, &this->impl->LinkOptions, &this->impl->LinkDirectories, &this->impl->LinkLibraries, + &this->impl->LinkWrappers, + &this->impl->InterfaceCompileWrappers, &this->impl->InterfaceLinkLibraries, &this->impl->InterfaceLinkLibrariesDirect, &this->impl->InterfaceLinkLibrariesDirectExclude, + &this->impl->InterfaceLinkWrappers, &this->impl->ImportedCxxModulesIncludeDirectories, &this->impl->ImportedCxxModulesCompileDefinitions, &this->impl->ImportedCxxModulesCompileFeatures, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f8d0c5e4bf..81064911b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -338,6 +338,9 @@ public: cmBTStringRange GetImportedCxxModulesCompileOptionsEntries() const; cmBTStringRange GetCompileFeaturesEntries() const; + + cmBTStringRange GetCompileWrappersEntries() const; + cmBTStringRange GetImportedCxxModulesCompileFeaturesEntries() const; cmBTStringRange GetCompileDefinitionsEntries() const; @@ -348,6 +351,8 @@ public: cmBTStringRange GetLinkOptionsEntries() const; + cmBTStringRange GetLinkWrappersEntries() const; + cmBTStringRange GetLinkDirectoriesEntries() const; cmBTStringRange GetLinkImplementationEntries() const; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 65fdcc3199..52ee7461a8 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -1365,8 +1365,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild") endif() set(CompilerLauncher_ARGS ${LauncherCommon_ARGS}) set(LinkerLauncher_ARGS ${LauncherCommon_ARGS}) + set(ToolchainWrappers_ARGS ${LauncherCommon_ARGS} + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) if(DEFINED CMake_TEST_ISPC) list(APPEND CompilerLauncher_ARGS -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) + list(APPEND ToolchainWrappers_ARGS -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) endif() add_RunCMake_test(CompilerLauncher) set_property(TEST RunCMake.CompilerLauncher APPEND @@ -1374,6 +1377,13 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild") add_RunCMake_test(LinkerLauncher) set_property(TEST RunCMake.LinkerLauncher APPEND PROPERTY LABEL "CUDA" "HIP" "Fortran") + # FIXME(#27402,#28110): FASTBuild doesn't currently support this feature, but + # it should. + if (NOT "${CMAKE_GENERATOR}" STREQUAL "FASTBuild") + add_RunCMake_test(ToolchainWrappers) + set_property(TEST RunCMake.ToolchainWrappers APPEND + PROPERTY LABELS "CUDA" "HIP" "ISPC" "Fortran") + endif() endif() set(cpack_tests diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_command-stderr.txt index 3f64b6bbc3..1fdf9a3094 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_command-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_command-stderr.txt @@ -4,7 +4,7 @@ CMake Error at add_custom_command\.cmake:2 \(add_custom_command\): \$ \$ may only be used to specify include directories, - compile definitions, compile options, and to evaluate components of the - file\(GENERATE\) command\. + compile definitions, compile options, compile wrappers, and to evaluate + components of the file\(GENERATE\) command\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_target-stderr.txt index 389adaf919..22d4f806b8 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_target-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_custom_target-stderr.txt @@ -4,7 +4,7 @@ CMake Error at add_custom_target\.cmake:1 \(add_custom_target\): \$ \$ may only be used to specify include directories, - compile definitions, compile options, and to evaluate components of the - file\(GENERATE\) command\. + compile definitions, compile options, compile wrappers, and to evaluate + components of the file\(GENERATE\) command\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_executable-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_executable-stderr.txt index 00dcb6640c..ec3438f8c8 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_executable-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_executable-stderr.txt @@ -4,7 +4,7 @@ CMake Error at add_executable\.cmake:1 \(add_executable\): \$ \$ may only be used to specify include directories, - compile definitions, compile options, and to evaluate components of the - file\(GENERATE\) command\. + compile definitions, compile options, compile wrappers, and to evaluate + components of the file\(GENERATE\) command\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_library-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_library-stderr.txt index a9462b3261..160039d40f 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_library-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_library-stderr.txt @@ -4,7 +4,7 @@ CMake Error at add_library\.cmake:1 \(add_library\): \$ \$ may only be used to specify include directories, - compile definitions, compile options, and to evaluate components of the - file\(GENERATE\) command\. + compile definitions, compile options, compile wrappers, and to evaluate + components of the file\(GENERATE\) command\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_test-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_test-stderr.txt index 2b7b9bd51a..c11171289e 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_test-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/add_test-stderr.txt @@ -4,7 +4,7 @@ CMake Error at add_test\.cmake:5 \(add_test\): \$ \$ may only be used to specify include directories, - compile definitions, compile options, and to evaluate components of the - file\(GENERATE\) command\. + compile definitions, compile options, compile wrappers, and to evaluate + components of the file\(GENERATE\) command\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/install-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/install-stderr.txt index ba4110035f..1f7448324f 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/install-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/install-stderr.txt @@ -4,5 +4,5 @@ CMake Error: \$ \$ may only be used to specify include directories, - compile definitions, compile options, and to evaluate components of the - file\(GENERATE\) command\. + compile definitions, compile options, compile wrappers, and to evaluate + components of the file\(GENERATE\) command\. diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/target_sources-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/target_sources-stderr.txt index 23d79dd29f..3781eaf6f2 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/target_sources-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/target_sources-stderr.txt @@ -4,7 +4,7 @@ CMake Error at target_sources\.cmake:2 \(target_sources\): \$ \$ may only be used to specify include directories, - compile definitions, compile options, and to evaluate components of the - file\(GENERATE\) command\. + compile definitions, compile options, compile wrappers, and to evaluate + components of the file\(GENERATE\) command\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_custom_target-stderr.txt index d515474a13..3d1e9fa1c9 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_custom_target-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_custom_target-stderr.txt @@ -4,8 +4,8 @@ CMake Error at add_custom_target\.cmake:2 \(add_custom_target\): \$ \$ may only be used with binary targets to - specify include directories, compile definitions, and compile options\. It - may not be used with the add_custom_command, add_custom_target, or - file\(GENERATE\) commands\. + specify include directories, compile definitions, compile options, and + compile wrappers\. It may not be used with the add_custom_command, + add_custom_target, or file\(GENERATE\) commands\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_executable-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_executable-stderr.txt index 73dc558a21..783bbd6494 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_executable-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_executable-stderr.txt @@ -4,8 +4,8 @@ CMake Error at add_executable\.cmake:1 \(add_executable\): \$ \$ may only be used with binary targets to - specify include directories, compile definitions, and compile options\. It - may not be used with the add_custom_command, add_custom_target, or - file\(GENERATE\) commands\. + specify include directories, compile definitions, compile options, and + compile wrappers\. It may not be used with the add_custom_command, + add_custom_target, or file\(GENERATE\) commands\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_library-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_library-stderr.txt index fb76f89b58..010acc6402 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_library-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_library-stderr.txt @@ -4,8 +4,8 @@ CMake Error at add_library\.cmake:2 \(add_library\): \$ \$ may only be used with binary targets to - specify include directories, compile definitions, and compile options\. It - may not be used with the add_custom_command, add_custom_target, or - file\(GENERATE\) commands\. + specify include directories, compile definitions, compile options, and + compile wrappers\. It may not be used with the add_custom_command, + add_custom_target, or file\(GENERATE\) commands\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_test-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_test-stderr.txt index 11a3eea644..0455ba08c3 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_test-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/add_test-stderr.txt @@ -4,8 +4,8 @@ CMake Error at add_test\.cmake:5 \(add_test\): \$ \$ may only be used with binary targets to - specify include directories, compile definitions, and compile options\. It - may not be used with the add_custom_command, add_custom_target, or - file\(GENERATE\) commands\. + specify include directories, compile definitions, compile options, and + compile wrappers\. It may not be used with the add_custom_command, + add_custom_target, or file\(GENERATE\) commands\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/install-stderr.txt b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/install-stderr.txt index 41de84ea05..91877ba4fb 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/install-stderr.txt +++ b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/install-stderr.txt @@ -4,6 +4,6 @@ CMake Error: \$ \$ may only be used with binary targets to - specify include directories, compile definitions, and compile options\. It - may not be used with the add_custom_command, add_custom_target, or - file\(GENERATE\) commands\. + specify include directories, compile definitions, compile options, and + compile wrappers\. It may not be used with the add_custom_command, + add_custom_target, or file\(GENERATE\) commands\. diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_command-stderr.txt index da09837744..b1ecfd803e 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_command-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_command-stderr.txt @@ -4,6 +4,6 @@ CMake Error at add_custom_command\.cmake:2 \(add_custom_command\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_target-stderr.txt index 772929c5f6..44a172cfea 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_target-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_custom_target-stderr.txt @@ -4,6 +4,6 @@ CMake Error at add_custom_target\.cmake:1 \(add_custom_target\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_executable-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_executable-stderr.txt index 7045a806da..b4b9ad8bd1 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_executable-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_executable-stderr.txt @@ -4,6 +4,6 @@ CMake Error at add_executable\.cmake:1 \(add_executable\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_library-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_library-stderr.txt index acafea69d6..00a359d258 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_library-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_library-stderr.txt @@ -4,6 +4,6 @@ CMake Error at add_library\.cmake:1 \(add_library\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_test-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_test-stderr.txt index c0c0f8ffd2..02d8ce6d29 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_test-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/add_test-stderr.txt @@ -4,6 +4,6 @@ CMake Error at add_test\.cmake:5 \(add_test\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/file_generate-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/file_generate-stderr.txt index e143df4028..a758d79440 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/file_generate-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/file_generate-stderr.txt @@ -4,6 +4,6 @@ CMake Error at file_generate\.cmake:3 \(file\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/install-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/install-stderr.txt index 4b96538320..282a40222d 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/install-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/install-stderr.txt @@ -4,7 +4,7 @@ CMake Error: \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. CMake Generate step failed\. Build files cannot be regenerated correctly\. diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/target_sources-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/target_sources-stderr.txt index a2abd4e496..0295b54137 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/target_sources-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/target_sources-stderr.txt @@ -4,6 +4,6 @@ CMake Error at target_sources\.cmake:2 \(target_sources\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage1-stderr.txt index f70860d51d..1426c34457 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage1-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage1-stderr.txt @@ -4,6 +4,6 @@ CMake Error at wrong-usage1\.cmake:4 \(target_compile_definitions\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage2-stderr.txt index 97423ed993..db3256d478 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage2-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage2-stderr.txt @@ -4,6 +4,6 @@ CMake Error at wrong-usage2\.cmake:4 \(target_compile_options\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage3-stderr.txt index d3c795ee03..ab02144805 100644 --- a/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage3-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANGUAGE/wrong-usage3-stderr.txt @@ -4,6 +4,6 @@ CMake Error at wrong-usage3\.cmake:4 \(target_include_directories\): \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_command-stderr.txt index 3a4175745e..1db68adb64 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_command-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_command-stderr.txt @@ -4,6 +4,7 @@ CMake Error at add_custom_command\.cmake:2 \(add_custom_command\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_target-stderr.txt index 58932c077b..366bee7f97 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_target-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_custom_target-stderr.txt @@ -4,6 +4,7 @@ CMake Error at add_custom_target\.cmake:2 \(add_custom_target\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_executable-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_executable-stderr.txt index 0a4fa591fd..12a6ce340f 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_executable-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_executable-stderr.txt @@ -4,6 +4,7 @@ CMake Error at add_executable\.cmake:1 \(add_executable\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_library-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_library-stderr.txt index d26840fba1..212d6c6c2a 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_library-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_library-stderr.txt @@ -4,6 +4,7 @@ CMake Error at add_library\.cmake:2 \(add_library\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_test-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_test-stderr.txt index 171ce0e2ba..33586d39ff 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_test-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/add_test-stderr.txt @@ -4,6 +4,7 @@ CMake Error at add_test\.cmake:5 \(add_test\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/file_generate-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/file_generate-stderr.txt index c87fb146e3..bf12be3f16 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/file_generate-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/file_generate-stderr.txt @@ -4,6 +4,7 @@ CMake Error at file_generate\.cmake:3 \(file\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/install-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/install-stderr.txt index 273f3e6646..9ef0638d6d 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/install-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/install-stderr.txt @@ -4,7 +4,8 @@ CMake Error: \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. CMake Generate step failed\. Build files cannot be regenerated correctly\. diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage1-stderr.txt index e55bf3ae5b..149860fadd 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage1-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage1-stderr.txt @@ -4,6 +4,7 @@ CMake Error at wrong-usage1\.cmake:4 \(target_compile_definitions\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage2-stderr.txt index cd60bf1919..b106bf49a5 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage2-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage2-stderr.txt @@ -4,6 +4,7 @@ CMake Error at wrong-usage2\.cmake:4 \(target_compile_options\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage3-stderr.txt index 8c5e785e00..f7688d716e 100644 --- a/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage3-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LANG_AND_ID/wrong-usage3-stderr.txt @@ -4,6 +4,7 @@ CMake Error at wrong-usage3\.cmake:4 \(target_include_directories\): \$ \$ may only be used with binary targets to specify - link libraries, link directories, link options, and link depends\. + link libraries, link directories, link options, link depends, and link + wrappers\. Call Stack \(most recent call first\): CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/INSTALL_OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt b/Tests/RunCMake/INSTALL_OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt index 4b96538320..282a40222d 100644 --- a/Tests/RunCMake/INSTALL_OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt +++ b/Tests/RunCMake/INSTALL_OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt @@ -4,7 +4,7 @@ CMake Error: \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. CMake Generate step failed\. Build files cannot be regenerated correctly\. diff --git a/Tests/RunCMake/OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt b/Tests/RunCMake/OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt index 4b96538320..282a40222d 100644 --- a/Tests/RunCMake/OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt +++ b/Tests/RunCMake/OBJECT_NAME/UnsupportedGeneratorExpressionLinkLanguage-stderr.txt @@ -4,7 +4,7 @@ CMake Error: \$ \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. + libraries, link directories, link options, link depends, and link wrappers\. CMake Generate step failed\. Build files cannot be regenerated correctly\. diff --git a/Tests/RunCMake/ToolchainWrappers/C-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/C-build-stdout.txt new file mode 100644 index 0000000000..6f9859c37d --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/C-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.c['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/C.cmake b/Tests/RunCMake/ToolchainWrappers/C.cmake new file mode 100644 index 0000000000..7c939029a1 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/C.cmake @@ -0,0 +1,3 @@ +include(common.cmake) +enable_language(C) +example_exe(main.c) diff --git a/Tests/RunCMake/ToolchainWrappers/CMakeLists.txt b/Tests/RunCMake/ToolchainWrappers/CMakeLists.txt new file mode 100644 index 0000000000..0ceb19a24c --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 4.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ToolchainWrappers/CTestLaunch-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/CTestLaunch-build-stdout.txt new file mode 100644 index 0000000000..2a07e3598d --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/CTestLaunch-build-stdout.txt @@ -0,0 +1,15 @@ +.*ctest(\.exe)?"? --launch [^ +]*--language C[^ +]* -- [^ +]*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*-E env CL_LAUNCH=1 [^ +]*[/\\]main\.c['" + ].*ctest(\.exe)?"? --launch [^ +]*--language C[^ +]* -- [^ +]*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*-E env LL_LAUNCH=1 [^ +]*([ /\\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/CTestLaunch.cmake b/Tests/RunCMake/ToolchainWrappers/CTestLaunch.cmake new file mode 100644 index 0000000000..2c267cd2bb --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/CTestLaunch.cmake @@ -0,0 +1,9 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(common.cmake) +enable_language(C) + +# The `ctest --launch` launcher is outside of wrappers and launchers. +set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;CL_LAUNCH=1") +set(CMAKE_C_LINKER_LAUNCHER "${CMAKE_COMMAND};-E;env;LL_LAUNCH=1") +example_exe(main.c) diff --git a/Tests/RunCMake/ToolchainWrappers/CUDA-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/CUDA-build-stdout.txt new file mode 100644 index 0000000000..180313865f --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/CUDA-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.cu['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*[ /\:]main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/CUDA.cmake b/Tests/RunCMake/ToolchainWrappers/CUDA.cmake new file mode 100644 index 0000000000..5955c593fc --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/CUDA.cmake @@ -0,0 +1,3 @@ +include(common.cmake) +enable_language(CUDA) +example_exe(main.cu) diff --git a/Tests/RunCMake/ToolchainWrappers/CXX-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/CXX-build-stdout.txt new file mode 100644 index 0000000000..02b6808edd --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/CXX-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.cxx['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/CXX.cmake b/Tests/RunCMake/ToolchainWrappers/CXX.cmake new file mode 100644 index 0000000000..d7eba2b7e4 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/CXX.cmake @@ -0,0 +1,3 @@ +include(common.cmake) +enable_language(CXX) +example_exe(main.cxx) diff --git a/Tests/RunCMake/ToolchainWrappers/DNE-result.txt b/Tests/RunCMake/ToolchainWrappers/DNE-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/DNE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ToolchainWrappers/DNE-stderr.txt b/Tests/RunCMake/ToolchainWrappers/DNE-stderr.txt new file mode 100644 index 0000000000..8509535833 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/DNE-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at DNE\.cmake:[0-9]+ \(set_target_properties\): + Specified wrapper 'NOT_A_COMPILE_WRAPPER' for target 'main' does not exist\. + Set the GLOBAL property 'CMAKE_COMPILE_WRAPPER_NOT_A_COMPILE_WRAPPER'\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at DNE\.cmake:[0-9]+ \(set_target_properties\): + Specified wrapper 'NOT_A_LINK_WRAPPER' for target 'main' does not exist\. + Set the GLOBAL property 'CMAKE_LINK_WRAPPER_NOT_A_LINK_WRAPPER'\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ToolchainWrappers/DNE.cmake b/Tests/RunCMake/ToolchainWrappers/DNE.cmake new file mode 100644 index 0000000000..306a37cf28 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/DNE.cmake @@ -0,0 +1,9 @@ +include(common.cmake) +enable_language(C) + +add_executable(main main.c) +target_link_libraries(main PRIVATE iface) +set_target_properties(main PROPERTIES + COMPILE_WRAPPERS NOT_A_COMPILE_WRAPPER + LINK_WRAPPERS NOT_A_LINK_WRAPPER +) diff --git a/Tests/RunCMake/ToolchainWrappers/DebugProps-stderr.txt b/Tests/RunCMake/ToolchainWrappers/DebugProps-stderr.txt new file mode 100644 index 0000000000..a18ad3fc7e --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/DebugProps-stderr.txt @@ -0,0 +1,27 @@ +CMake Debug Log at common\.cmake:[0-9]+ \(set_target_properties\): + Used compile wrappers for target main: + + \* EXAMPLE_1 + \* EXAMPLE_2 + +Call Stack \(most recent call first\): + DebugProps\.cmake:[0-9]+ \(example_exe\) + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Debug Log at common\.cmake:[0-9]+ \(set_target_properties\): + Used link wrappers for target main: + + \* EXAMPLE_2 + +Call Stack \(most recent call first\): + DebugProps\.cmake:[0-9]+ \(example_exe\) + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Debug Log at common\.cmake:[0-9]+ \(target_link_libraries\): + Used link wrappers for target main: + + \* EXAMPLE_1 + +Call Stack \(most recent call first\): + DebugProps\.cmake:[0-9]+ \(example_exe\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ToolchainWrappers/DebugProps.cmake b/Tests/RunCMake/ToolchainWrappers/DebugProps.cmake new file mode 100644 index 0000000000..ea1cdc8535 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/DebugProps.cmake @@ -0,0 +1,4 @@ +set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_WRAPPERS LINK_WRAPPERS) +include(common.cmake) +enable_language(C) +example_exe(main.c) diff --git a/Tests/RunCMake/ToolchainWrappers/Fortran-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/Fortran-build-stdout.txt new file mode 100644 index 0000000000..cd70672d60 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/Fortran-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.f90['" + .-].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*[ /\:]main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/Fortran.cmake b/Tests/RunCMake/ToolchainWrappers/Fortran.cmake new file mode 100644 index 0000000000..e8e28f75e8 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/Fortran.cmake @@ -0,0 +1,3 @@ +include(common.cmake) +enable_language(Fortran) +example_exe(main.f90) diff --git a/Tests/RunCMake/ToolchainWrappers/HIP-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/HIP-build-stdout.txt new file mode 100644 index 0000000000..02d993c000 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/HIP-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.hip['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*[ /\:]main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/HIP.cmake b/Tests/RunCMake/ToolchainWrappers/HIP.cmake new file mode 100644 index 0000000000..4fc003fc6c --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/HIP.cmake @@ -0,0 +1,3 @@ +include(common.cmake) +enable_language(HIP) +example_exe(main.hip) diff --git a/Tests/RunCMake/ToolchainWrappers/ISPC-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/ISPC-build-stdout.txt new file mode 100644 index 0000000000..b6e9930eb1 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/ISPC-build-stdout.txt @@ -0,0 +1,16 @@ +.*(-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.cxx['" + ].*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]test\.ispc['" + ]|-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]test\.ispc['" + ].*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.cxx['" + ]).*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*[ /\:]main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/ISPC.cmake b/Tests/RunCMake/ToolchainWrappers/ISPC.cmake new file mode 100644 index 0000000000..b6b54731ab --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/ISPC.cmake @@ -0,0 +1,6 @@ +include(common.cmake) +enable_language(CXX ISPC) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() +example_exe(main.cxx test.ispc) diff --git a/Tests/RunCMake/ToolchainWrappers/InterfaceDNE-result.txt b/Tests/RunCMake/ToolchainWrappers/InterfaceDNE-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/InterfaceDNE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ToolchainWrappers/InterfaceDNE-stderr.txt b/Tests/RunCMake/ToolchainWrappers/InterfaceDNE-stderr.txt new file mode 100644 index 0000000000..b4a580c11f --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/InterfaceDNE-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at InterfaceDNE\.cmake:[0-9]+ \(target_link_libraries\): + Specified wrapper 'NOT_A_COMPILE_WRAPPER' for target 'main' does not exist\. + Set the GLOBAL property 'CMAKE_COMPILE_WRAPPER_NOT_A_COMPILE_WRAPPER'\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at InterfaceDNE\.cmake:[0-9]+ \(target_link_libraries\): + Specified wrapper 'NOT_A_LINK_WRAPPER' for target 'main' does not exist\. + Set the GLOBAL property 'CMAKE_LINK_WRAPPER_NOT_A_LINK_WRAPPER'\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ToolchainWrappers/InterfaceDNE.cmake b/Tests/RunCMake/ToolchainWrappers/InterfaceDNE.cmake new file mode 100644 index 0000000000..de000a6131 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/InterfaceDNE.cmake @@ -0,0 +1,11 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +add_library(iface INTERFACE) +set_target_properties(iface PROPERTIES + INTERFACE_COMPILE_WRAPPERS NOT_A_COMPILE_WRAPPER + INTERFACE_LINK_WRAPPERS NOT_A_LINK_WRAPPER +) + +add_executable(main main.c) +target_link_libraries(main PRIVATE iface) diff --git a/Tests/RunCMake/ToolchainWrappers/InterfaceGenex-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/InterfaceGenex-build-stdout.txt new file mode 100644 index 0000000000..34ebd8a8a4 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/InterfaceGenex-build-stdout.txt @@ -0,0 +1,5 @@ +.*-E env CW_IFACE_GENEX=1 [^ +]*[/\]main\.c['" + ].*-E env LW_IFACE_GENEX=1 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/InterfaceGenex.cmake b/Tests/RunCMake/ToolchainWrappers/InterfaceGenex.cmake new file mode 100644 index 0000000000..5d9f6c3168 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/InterfaceGenex.cmake @@ -0,0 +1,27 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}") + +# INTERFACE_{COMPILE,LINK}_WRAPPERS values may themselves use +# $/$ generator expressions. + +set_property(GLOBAL PROPERTY + CMAKE_COMPILE_WRAPPER_IFACE_GENEX + "${CMAKE_COMMAND};-E;env;CW_IFACE_GENEX=1" +) +set_property(GLOBAL PROPERTY + CMAKE_LINK_WRAPPER_IFACE_GENEX + "${CMAKE_COMMAND};-E;env;LW_IFACE_GENEX=1" +) + +add_library(iface_genex INTERFACE) +set_target_properties(iface_genex PROPERTIES + INTERFACE_COMPILE_WRAPPERS "$<$:IFACE_GENEX>" + INTERFACE_LINK_WRAPPERS "$<$:IFACE_GENEX>" +) + +add_executable(main main.c) +target_link_libraries(main PRIVATE iface_genex) diff --git a/Tests/RunCMake/ToolchainWrappers/Launcher-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/Launcher-build-stdout.txt new file mode 100644 index 0000000000..d8990a0fb8 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/Launcher-build-stdout.txt @@ -0,0 +1,9 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*-E env CL_LAUNCH=1 [^ +]*[/\\]main\.c['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*-E env LL_LAUNCH=1 [^ +]*([ /\\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/Launcher.cmake b/Tests/RunCMake/ToolchainWrappers/Launcher.cmake new file mode 100644 index 0000000000..b9a51fb14a --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/Launcher.cmake @@ -0,0 +1,7 @@ +include(common.cmake) +enable_language(C) + +# Wrappers go outside of launchers. +set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;CL_LAUNCH=1") +set(CMAKE_C_LINKER_LAUNCHER "${CMAKE_COMMAND};-E;env;LL_LAUNCH=1") +example_exe(main.c) diff --git a/Tests/RunCMake/ToolchainWrappers/LauncherEmpty-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/LauncherEmpty-build-stdout.txt new file mode 100644 index 0000000000..6f9859c37d --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/LauncherEmpty-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.c['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/LauncherEmpty.cmake b/Tests/RunCMake/ToolchainWrappers/LauncherEmpty.cmake new file mode 100644 index 0000000000..26c9c41032 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/LauncherEmpty.cmake @@ -0,0 +1,7 @@ +include(common.cmake) +enable_language(C) + +# Launchers that evaluate to nothing must not disturb the wrappers. +set(CMAKE_C_COMPILER_LAUNCHER "$<0:unused>") +set(CMAKE_C_LINKER_LAUNCHER "$<0:unused>") +example_exe(main.c) diff --git a/Tests/RunCMake/ToolchainWrappers/LauncherLint-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/LauncherLint-build-stdout.txt new file mode 100644 index 0000000000..c19f92239c --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/LauncherLint-build-stdout.txt @@ -0,0 +1,7 @@ +.*__run_co_compile --launcher=[^ +]*-E;env;CW_OUTER=1;[^ +]*-E;env;CW_INNER=2;[^ +]*-E;env;CL_LAUNCH=1[^ +]* --cppcheck=[^ +]*-E;true[^ +]* --source= diff --git a/Tests/RunCMake/ToolchainWrappers/LauncherLint.cmake b/Tests/RunCMake/ToolchainWrappers/LauncherLint.cmake new file mode 100644 index 0000000000..d5aca5b317 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/LauncherLint.cmake @@ -0,0 +1,8 @@ +include(common.cmake) +enable_language(C) + +set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;CL_LAUNCH=1") +# Lint tools run the wrappers and launcher via `__run_co_compile --launcher=`. +# `cmake -E true` ignores the arguments it is given. +set(CMAKE_C_CPPCHECK "${CMAKE_COMMAND};-E;true") +example_exe(main.c) diff --git a/Tests/RunCMake/ToolchainWrappers/LinkOnly-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/LinkOnly-build-stdout.txt new file mode 100644 index 0000000000..42372fbebb --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/LinkOnly-build-stdout.txt @@ -0,0 +1,3 @@ +.*-E env LW_OUTER=1 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/LinkOnly.cmake b/Tests/RunCMake/ToolchainWrappers/LinkOnly.cmake new file mode 100644 index 0000000000..131041efca --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/LinkOnly.cmake @@ -0,0 +1,16 @@ +include(common.cmake) +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}") + +# `$` dependencies contribute only their link usage +# requirements, so `iface`'s INTERFACE_LINK_WRAPPERS apply to `main` +# but its INTERFACE_COMPILE_WRAPPERS do not. +add_library(link_only INTERFACE) +target_link_libraries(link_only INTERFACE "$") + +add_executable(main main.c) +target_link_libraries(main PRIVATE link_only) diff --git a/Tests/RunCMake/ToolchainWrappers/NoWrappers.cmake b/Tests/RunCMake/ToolchainWrappers/NoWrappers.cmake new file mode 100644 index 0000000000..93b2bd627a --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/NoWrappers.cmake @@ -0,0 +1,21 @@ +include(common.cmake) +enable_language(C) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +set_property(GLOBAL PROPERTY + CMAKE_COMPILE_WRAPPER_EXAMPLE_1 + definitely-not-a-command +) +set_property(GLOBAL PROPERTY + CMAKE_LINK_WRAPPER_EXAMPLE_1 + definitely-not-a-command +) + +add_executable(main main.c) +set_target_properties(main PROPERTIES + # Use the $<0:...> genexp to validate (a) genexp support and (b) handling of + # no wrappers. + COMPILE_WRAPPERS "$<0:EXAMPLE_1>" + LINK_WRAPPERS "$<0:EXAMPLE_1>" +) diff --git a/Tests/RunCMake/ToolchainWrappers/OBJC-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/OBJC-build-stdout.txt new file mode 100644 index 0000000000..ee65a80efd --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/OBJC-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.m['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*[ /\:]main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/OBJC.cmake b/Tests/RunCMake/ToolchainWrappers/OBJC.cmake new file mode 100644 index 0000000000..b0c5515149 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/OBJC.cmake @@ -0,0 +1,3 @@ +include(common.cmake) +enable_language(OBJC) +example_exe(main.m) diff --git a/Tests/RunCMake/ToolchainWrappers/OBJCXX-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/OBJCXX-build-stdout.txt new file mode 100644 index 0000000000..d4020561da --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/OBJCXX-build-stdout.txt @@ -0,0 +1,7 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\]main\.mm['" + ].*-E env LW_OUTER=1 [^ +]*-E env LW_INNER=2 [^ +]*[ /\:]main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/OBJCXX.cmake b/Tests/RunCMake/ToolchainWrappers/OBJCXX.cmake new file mode 100644 index 0000000000..889d650701 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/OBJCXX.cmake @@ -0,0 +1,3 @@ +include(common.cmake) +enable_language(OBJCXX) +example_exe(main.mm) diff --git a/Tests/RunCMake/ToolchainWrappers/PerConfig-Debug-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/PerConfig-Debug-build-stdout.txt new file mode 100644 index 0000000000..e2f6ce9ef8 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/PerConfig-Debug-build-stdout.txt @@ -0,0 +1,5 @@ +.*-E env CW_INNER=2 [^ +]*[/\]main\.c['" + ].*-E env LW_INNER=2 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/PerConfig-Release-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/PerConfig-Release-build-stdout.txt new file mode 100644 index 0000000000..f9496b3776 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/PerConfig-Release-build-stdout.txt @@ -0,0 +1,5 @@ +.*-E env CW_OUTER=1 [^ +]*[/\]main\.c['" + ].*-E env LW_OUTER=1 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/PerConfig.cmake b/Tests/RunCMake/ToolchainWrappers/PerConfig.cmake new file mode 100644 index 0000000000..d4aa5ba663 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/PerConfig.cmake @@ -0,0 +1,17 @@ +include(common.cmake) +enable_language(C) + +# EXAMPLE_1 is inherited only in Release, EXAMPLE_2 is set only in Debug. + +add_library(iface_config INTERFACE) +set_target_properties(iface_config PROPERTIES + INTERFACE_COMPILE_WRAPPERS "$<$:EXAMPLE_1>" + INTERFACE_LINK_WRAPPERS "$<$:EXAMPLE_1>" +) + +add_executable(main main.c) +target_link_libraries(main PRIVATE iface_config) +set_target_properties(main PROPERTIES + COMPILE_WRAPPERS "$<$:EXAMPLE_2>" + LINK_WRAPPERS "$<$:EXAMPLE_2>" +) diff --git a/Tests/RunCMake/ToolchainWrappers/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainWrappers/RunCMakeTest.cmake new file mode 100644 index 0000000000..7c933f529d --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/RunCMakeTest.cmake @@ -0,0 +1,120 @@ +include(RunCMake) + +function(run_toolchain_wrappers case) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${case}-build") + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OUTPUT_MERGE 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(${case}) + + if(RunCMake_GENERATOR MATCHES "Ninja") + set(verbose_args -- -v) + endif() + run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . ${verbose_args}) +endfunction() + +set(langs C CXX) +if(CMake_TEST_CUDA) + list(APPEND langs CUDA) +endif() +if(CMake_TEST_Fortran) + list(APPEND langs Fortran) +endif() +if(CMake_TEST_HIP) + list(APPEND langs HIP) +endif() +if(CMake_TEST_ISPC) + list(APPEND langs ISPC) +endif() +if(CMake_TEST_OBJC) + list(APPEND langs OBJC OBJCXX) +endif() + +foreach(lang ${langs}) + run_toolchain_wrappers(${lang}) +endforeach() + +run_cmake(DNE) +run_cmake(InterfaceDNE) +run_cmake(DebugProps) +run_toolchain_wrappers(NoWrappers) + +# $/$ generator expressions. +run_toolchain_wrappers(WrapperGenex) +run_toolchain_wrappers(InterfaceGenex) +block() + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/SelectorGenex-build") + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OUTPUT_MERGE 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(SelectorGenex) + + if(RunCMake_GENERATOR MATCHES "Ninja") + set(verbose_args -- -v) + endif() + + set(RunCMake_TEST_NOT_EXPECT_stdout "SELECTOR") + run_cmake_command(SelectorGenex-build-mainc + ${CMAKE_COMMAND} --build . --target mainc ${verbose_args}) + unset(RunCMake_TEST_NOT_EXPECT_stdout) + + run_cmake_command(SelectorGenex-build-maincxx + ${CMAKE_COMMAND} --build . --target maincxx ${verbose_args}) +endblock() + +# Compile wrappers of a `$` dependency must not be used. +set(RunCMake_TEST_NOT_EXPECT_stdout "CW_") +run_toolchain_wrappers(LinkOnly) +unset(RunCMake_TEST_NOT_EXPECT_stdout) + +run_toolchain_wrappers(SpecialArgs) + +# Wrappers are placed outside of launchers. +run_toolchain_wrappers(Launcher) +run_toolchain_wrappers(LauncherEmpty) +run_toolchain_wrappers(LauncherLint) +if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_toolchain_wrappers(CTestLaunch) +endif() + +# On most compilers, static libraries are created by an archiver, so link +# wrappers and the linker launcher do not apply. A few toolchains instead +# define CMAKE__CREATE_STATIC_LIBRARY to invoke the compiler driver +# directly, in which case static library creation goes through the normal +# link-command path and link wrappers/launcher *do* apply. +if(NOT CMAKE_C_COMPILER_ID STREQUAL "OrangeC" AND + NOT (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")) + set(RunCMake_TEST_NOT_EXPECT_stdout "(LW|LL)_") +endif() +run_toolchain_wrappers(StaticLibrary) +unset(RunCMake_TEST_NOT_EXPECT_stdout) + +function(run_toolchain_wrappers_per_config case) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OUTPUT_MERGE 1) + + if(RunCMake_GENERATOR MATCHES "Ninja") + set(verbose_args -- -v) + endif() + + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${case}-build") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${case}) + + set(marker_Debug "(CW|LW)_OUTER=1") + set(marker_Release "(CW|LW)_INNER=2") + foreach(config IN ITEMS Debug Release) + # Wrappers for the other config must not leak into this config's commands. + set(RunCMake_TEST_NOT_EXPECT_stdout "${marker_${config}}") + run_cmake_command(${case}-${config}-build + ${CMAKE_COMMAND} --build . --config ${config} ${verbose_args}) + endforeach() +endfunction() +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + run_toolchain_wrappers_per_config(PerConfig) +endif() diff --git a/Tests/RunCMake/ToolchainWrappers/SelectorGenex-build-mainc-stdout.txt b/Tests/RunCMake/ToolchainWrappers/SelectorGenex-build-mainc-stdout.txt new file mode 100644 index 0000000000..98d6f03b24 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/SelectorGenex-build-mainc-stdout.txt @@ -0,0 +1,3 @@ +.*[/\]main\.c['" + ].*([ /\:]|-e)mainc(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/SelectorGenex-build-maincxx-stdout.txt b/Tests/RunCMake/ToolchainWrappers/SelectorGenex-build-maincxx-stdout.txt new file mode 100644 index 0000000000..83949166a5 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/SelectorGenex-build-maincxx-stdout.txt @@ -0,0 +1,5 @@ +.*-E env CW_SELECTOR=1 [^ +]*[/\]main\.cxx['" + ].*-E env LW_SELECTOR=1 [^ +]*([ /\:]|-e)maincxx(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/SelectorGenex.cmake b/Tests/RunCMake/ToolchainWrappers/SelectorGenex.cmake new file mode 100644 index 0000000000..4fcbd94dae --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/SelectorGenex.cmake @@ -0,0 +1,32 @@ +enable_language(C CXX) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +foreach(lang IN ITEMS C CXX) + string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_${lang}_COMPILE_OBJECT "${CMAKE_${lang}_COMPILE_OBJECT}") + string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_${lang}_COMPILE_OBJECT "${CMAKE_${lang}_COMPILE_OBJECT}") + string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_${lang}_LINK_EXECUTABLE "${CMAKE_${lang}_LINK_EXECUTABLE}") + string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_${lang}_LINK_EXECUTABLE "${CMAKE_${lang}_LINK_EXECUTABLE}") +endforeach() + +# {COMPILE,LINK}_WRAPPERS lists themselves may be selected with +# $/$. + +set_property(GLOBAL PROPERTY + CMAKE_COMPILE_WRAPPER_SELECTOR + "${CMAKE_COMMAND};-E;env;CW_SELECTOR=1" +) +set_property(GLOBAL PROPERTY + CMAKE_LINK_WRAPPER_SELECTOR + "${CMAKE_COMMAND};-E;env;LW_SELECTOR=1" +) + +add_executable(mainc main.c) +set_target_properties(mainc PROPERTIES + COMPILE_WRAPPERS "$<$:SELECTOR>" + LINK_WRAPPERS "$<$:SELECTOR>" +) + +add_executable(maincxx main.cxx) +set_target_properties(maincxx PROPERTIES + COMPILE_WRAPPERS "$<$:SELECTOR>" + LINK_WRAPPERS "$<$:SELECTOR>" +) diff --git a/Tests/RunCMake/ToolchainWrappers/SpecialArgs-build-check.cmake b/Tests/RunCMake/ToolchainWrappers/SpecialArgs-build-check.cmake new file mode 100644 index 0000000000..eda1925cab --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/SpecialArgs-build-check.cmake @@ -0,0 +1,12 @@ +# Wrapper invocations cannot be reliably verified via stdout, so both record to +# a log file instead. Verify both phases ran by checking its content. +set(log_file "${RunCMake_TEST_BINARY_DIR}/special-args.log") +if(NOT EXISTS "${log_file}") + set(RunCMake_TEST_FAILED "special-args.log was not created by the wrapper") +else() + file(READ "${log_file}" log_content) + if(NOT (log_content MATCHES "compile" AND log_content MATCHES "link")) + set(RunCMake_TEST_FAILED + "special-args.log does not show both the compile and link wrappers ran:\n${log_content}") + endif() +endif() diff --git a/Tests/RunCMake/ToolchainWrappers/SpecialArgs.cmake b/Tests/RunCMake/ToolchainWrappers/SpecialArgs.cmake new file mode 100644 index 0000000000..ed1bdd7783 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/SpecialArgs.cmake @@ -0,0 +1,18 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +set(check "${CMAKE_CURRENT_LIST_DIR}/check-special-args.cmake") +set_property(GLOBAL PROPERTY + CMAKE_COMPILE_WRAPPER_SPECIAL + "${CMAKE_COMMAND};-P;${check};--;compile;;semi\\;colon;with space" +) +set_property(GLOBAL PROPERTY + CMAKE_LINK_WRAPPER_SPECIAL + "${CMAKE_COMMAND};-P;${check};--;link;;semi\\;colon;with space" +) + +add_executable(main main.c) +set_target_properties(main PROPERTIES + COMPILE_WRAPPERS SPECIAL + LINK_WRAPPERS SPECIAL +) diff --git a/Tests/RunCMake/ToolchainWrappers/StaticLibrary-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/StaticLibrary-build-stdout.txt new file mode 100644 index 0000000000..95162add11 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/StaticLibrary-build-stdout.txt @@ -0,0 +1,4 @@ +.*-E env CW_OUTER=1 [^ +]*-E env CW_INNER=2 [^ +]*[/\\]main\.c['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/StaticLibrary.cmake b/Tests/RunCMake/ToolchainWrappers/StaticLibrary.cmake new file mode 100644 index 0000000000..21946c0ab6 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/StaticLibrary.cmake @@ -0,0 +1,15 @@ +include(common.cmake) +enable_language(C) +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_STATIC_LIBRARY "${CMAKE_C_CREATE_STATIC_LIBRARY}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_STATIC_LIBRARY "${CMAKE_C_CREATE_STATIC_LIBRARY}") + +# Static libraries are created by the archiver: compile wrappers apply, but +# link wrappers and linker launchers do not. +set(CMAKE_C_LINKER_LAUNCHER "${CMAKE_COMMAND};-E;env;LL_LAUNCH=1") +add_library(main STATIC main.c) +set_target_properties(main PROPERTIES + COMPILE_WRAPPERS "EXAMPLE_1;EXAMPLE_2" + LINK_WRAPPERS "EXAMPLE_1;EXAMPLE_2" +) diff --git a/Tests/RunCMake/ToolchainWrappers/WrapperGenex-build-stdout.txt b/Tests/RunCMake/ToolchainWrappers/WrapperGenex-build-stdout.txt new file mode 100644 index 0000000000..2758dcda91 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/WrapperGenex-build-stdout.txt @@ -0,0 +1,5 @@ +.*-E env CW_GENEX=1 [^ +]*[/\]main\.c['" + ].*-E env LW_GENEX=1 [^ +]*([ /\:]|-e)main(\.exe)?['" + ] diff --git a/Tests/RunCMake/ToolchainWrappers/WrapperGenex.cmake b/Tests/RunCMake/ToolchainWrappers/WrapperGenex.cmake new file mode 100644 index 0000000000..a082604ef6 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/WrapperGenex.cmake @@ -0,0 +1,24 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}") + +# The command line held by CMAKE_{COMPILE,LINK}_WRAPPER_ may itself use +# generator expressions such as $/$. + +set_property(GLOBAL PROPERTY + CMAKE_COMPILE_WRAPPER_GENEX + "$<$:${CMAKE_COMMAND};-E;env;CW_GENEX=1>" +) +set_property(GLOBAL PROPERTY + CMAKE_LINK_WRAPPER_GENEX + "$<$:${CMAKE_COMMAND};-E;env;LW_GENEX=1>" +) + +add_executable(main main.c) +set_target_properties(main PROPERTIES + COMPILE_WRAPPERS GENEX + LINK_WRAPPERS GENEX +) diff --git a/Tests/RunCMake/ToolchainWrappers/check-special-args.cmake b/Tests/RunCMake/ToolchainWrappers/check-special-args.cmake new file mode 100644 index 0000000000..a1e1856087 --- /dev/null +++ b/Tests/RunCMake/ToolchainWrappers/check-special-args.cmake @@ -0,0 +1,42 @@ +# Verifies that the wrapper's own arguments arrive intact, then runs the +# wrapped command. + +set(base 4) # CMAKE_ARGV0..3 are: cmake -P