瀏覽代碼

Genex: Add generator expressions $<DEVICE_LINK> and $<HOST_LINK>

These generator expressions can only be used in link options properties.
These expressions return the arguments respectively for device and host link
step, otherwise return an empty string.
Marc Chevrier 5 年之前
父節點
當前提交
3fdae5acaa
共有 94 個文件被更改,包括 572 次插入11 次删除
  1. 12 0
      Help/manual/cmake-generator-expressions.7.rst
  2. 6 0
      Help/release/dev/genex-DEVICE_LINK-HOST_LINK.rst
  3. 7 0
      Source/cmGeneratorExpressionDAGChecker.cxx
  4. 1 0
      Source/cmGeneratorExpressionDAGChecker.h
  5. 68 0
      Source/cmGeneratorExpressionNode.cxx
  6. 14 10
      Source/cmGeneratorTarget.cxx
  7. 19 0
      Source/cmGeneratorTarget.h
  8. 1 1
      Source/cmStringAlgorithms.h
  9. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_command-result.txt
  10. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_command-stderr.txt
  11. 4 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_command.cmake
  12. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_target-result.txt
  13. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_target-stderr.txt
  14. 3 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_target.cmake
  15. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_executable-result.txt
  16. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_executable-stderr.txt
  17. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_executable.cmake
  18. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_library-result.txt
  19. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_library-stderr.txt
  20. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_library.cmake
  21. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_test-result.txt
  22. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_test-stderr.txt
  23. 5 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_test.cmake
  24. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-install-result.txt
  25. 7 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-install-stderr.txt
  26. 5 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-install.cmake
  27. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-link_depends-result.txt
  28. 7 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-link_depends-stderr.txt
  29. 7 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-link_depends.cmake
  30. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_definitions-result.txt
  31. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_definitions-stderr.txt
  32. 4 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_definitions.cmake
  33. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_options-result.txt
  34. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_options-stderr.txt
  35. 4 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_options.cmake
  36. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_include_directories-result.txt
  37. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_include_directories-stderr.txt
  38. 4 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_include_directories.cmake
  39. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_directories-result.txt
  40. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_directories-stderr.txt
  41. 7 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_directories.cmake
  42. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_libraries-result.txt
  43. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_libraries-stderr.txt
  44. 7 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_libraries.cmake
  45. 1 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_sources-result.txt
  46. 9 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_sources-stderr.txt
  47. 2 0
      Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_sources.cmake
  48. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_command-result.txt
  49. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_command-stderr.txt
  50. 4 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_command.cmake
  51. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_target-result.txt
  52. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_target-stderr.txt
  53. 3 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_target.cmake
  54. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_executable-result.txt
  55. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_executable-stderr.txt
  56. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_executable.cmake
  57. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_library-result.txt
  58. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_library-stderr.txt
  59. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_library.cmake
  60. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_test-result.txt
  61. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_test-stderr.txt
  62. 5 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-add_test.cmake
  63. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-install-result.txt
  64. 7 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-install-stderr.txt
  65. 5 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-install.cmake
  66. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-link_depends-result.txt
  67. 7 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-link_depends-stderr.txt
  68. 7 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-link_depends.cmake
  69. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_definitions-result.txt
  70. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_definitions-stderr.txt
  71. 4 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_definitions.cmake
  72. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_options-result.txt
  73. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_options-stderr.txt
  74. 4 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_options.cmake
  75. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_include_directories-result.txt
  76. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_include_directories-stderr.txt
  77. 4 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_include_directories.cmake
  78. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_directories-result.txt
  79. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_directories-stderr.txt
  80. 7 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_directories.cmake
  81. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_libraries-result.txt
  82. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_libraries-stderr.txt
  83. 7 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_libraries.cmake
  84. 1 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_sources-result.txt
  85. 9 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_sources-stderr.txt
  86. 2 0
      Tests/RunCMake/GeneratorExpression/HOST_LINK-target_sources.cmake
  87. 30 0
      Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
  88. 5 0
      Tests/RunCMake/target_link_options/RunCMakeTest.cmake
  89. 3 0
      Tests/RunCMake/target_link_options/genex_DEVICE_LINK-interface-check.cmake
  90. 1 0
      Tests/RunCMake/target_link_options/genex_DEVICE_LINK-interface-result.txt
  91. 3 0
      Tests/RunCMake/target_link_options/genex_DEVICE_LINK-private-check.cmake
  92. 1 0
      Tests/RunCMake/target_link_options/genex_DEVICE_LINK-private-result.txt
  93. 22 0
      Tests/RunCMake/target_link_options/genex_DEVICE_LINK-validation.cmake
  94. 19 0
      Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake

+ 12 - 0
Help/manual/cmake-generator-expressions.7.rst

@@ -362,6 +362,18 @@ Variable Queries
     evaluation will give ``C`` as link language, so the second pass will
     correctly add target ``libother`` as link dependency.
 
+``$<DEVICE_LINK:list>``
+  Returns the list if it is the device link step, an empty list otherwise.
+  The device link step is controlled by :prop_tgt:`CUDA_SEPARABLE_COMPILATION`
+  and :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties. This expression can
+  only be used to specify link options.
+
+``$<HOST_LINK:list>``
+  Returns the list if it is the normal link step, an empty list otherwise.
+  This expression is mainly useful when a device link step is also involved
+  (see ``$<DEVICE_LINK:list>`` generator expression). This expression can only
+  be used to specify link options.
+
 String-Valued Generator Expressions
 ===================================
 

+ 6 - 0
Help/release/dev/genex-DEVICE_LINK-HOST_LINK.rst

@@ -0,0 +1,6 @@
+genex-DEVICE_LINK-HOST_LINK
+---------------------------
+
+* To manage device and host link steps, the ``$<DEVICE_LINK:...>`` and
+  ``$<HOST_LINK:...>``
+  :manual:`generator expressions <cmake-generator-expressions(7)>` were added.

+ 7 - 0
Source/cmGeneratorExpressionDAGChecker.cxx

@@ -163,6 +163,13 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const
     property == "LINK_DEPENDS"_s;
 }
 
+bool cmGeneratorExpressionDAGChecker::EvaluatingLinkOptionsExpression() const
+{
+  cm::string_view property(this->Top()->Property);
+
+  return property == "LINK_OPTIONS"_s;
+}
+
 bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
   cmGeneratorTarget const* tgt) const
 {

+ 1 - 0
Source/cmGeneratorExpressionDAGChecker.h

@@ -69,6 +69,7 @@ struct cmGeneratorExpressionDAGChecker
   bool EvaluatingGenexExpression() const;
   bool EvaluatingPICExpression() const;
   bool EvaluatingLinkExpression() const;
+  bool EvaluatingLinkOptionsExpression() const;
 
   bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr) const;
 

+ 68 - 0
Source/cmGeneratorExpressionNode.cxx

@@ -15,6 +15,7 @@
 
 #include <cm/iterator>
 #include <cm/string_view>
+#include <cm/vector>
 #include <cmext/algorithm>
 
 #include "cmsys/RegularExpression.hxx"
@@ -1187,6 +1188,70 @@ static const struct LinkLanguageAndIdNode : public cmGeneratorExpressionNode
   }
 } linkLanguageAndIdNode;
 
+static const struct HostLinkNode : public cmGeneratorExpressionNode
+{
+  HostLinkNode() {} // NOLINT(modernize-use-equals-default)
+
+  int NumExpectedParameters() const override { return ZeroOrMoreParameters; }
+
+  std::string Evaluate(
+    const std::vector<std::string>& parameters,
+    cmGeneratorExpressionContext* context,
+    const GeneratorExpressionContent* content,
+    cmGeneratorExpressionDAGChecker* dagChecker) const override
+  {
+    if (!context->HeadTarget || !dagChecker ||
+        !dagChecker->EvaluatingLinkOptionsExpression()) {
+      reportError(context, content->GetOriginalExpression(),
+                  "$<HOST_LINK:...> may only be used with binary targets "
+                  "to specify link options.");
+      return std::string();
+    }
+
+    return context->HeadTarget->IsDeviceLink() ? std::string()
+                                               : cmJoin(parameters, ";");
+  }
+} hostLinkNode;
+
+static const struct DeviceLinkNode : public cmGeneratorExpressionNode
+{
+  DeviceLinkNode() {} // NOLINT(modernize-use-equals-default)
+
+  int NumExpectedParameters() const override { return ZeroOrMoreParameters; }
+
+  std::string Evaluate(
+    const std::vector<std::string>& parameters,
+    cmGeneratorExpressionContext* context,
+    const GeneratorExpressionContent* content,
+    cmGeneratorExpressionDAGChecker* dagChecker) const override
+  {
+    if (!context->HeadTarget || !dagChecker ||
+        !dagChecker->EvaluatingLinkOptionsExpression()) {
+      reportError(context, content->GetOriginalExpression(),
+                  "$<DEVICE_LINK:...> may only be used with binary targets "
+                  "to specify link options.");
+      return std::string();
+    }
+
+    if (context->HeadTarget->IsDeviceLink()) {
+      std::vector<std::string> list;
+      cmExpandLists(parameters.begin(), parameters.end(), list);
+      const auto DL_BEGIN = "<DEVICE_LINK>"_s;
+      const auto DL_END = "</DEVICE_LINK>"_s;
+      cm::erase_if(list, [&](const std::string& item) {
+        return item == DL_BEGIN || item == DL_END;
+      });
+
+      list.insert(list.begin(), static_cast<std::string>(DL_BEGIN));
+      list.push_back(static_cast<std::string>(DL_END));
+
+      return cmJoin(list, ";");
+    }
+
+    return std::string();
+  }
+} deviceLinkNode;
+
 std::string getLinkedTargetsContent(
   cmGeneratorTarget const* target, std::string const& prop,
   cmGeneratorExpressionContext* context,
@@ -1304,6 +1369,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
           context, content->GetOriginalExpression(),
           "$<TARGET_PROPERTY:prop>  may only be used with binary targets.  "
           "It may not be used with add_custom_command or add_custom_target.  "
+          " "
           "Specify the target to read a property from using the "
           "$<TARGET_PROPERTY:tgt,prop> signature instead.");
         return std::string();
@@ -2464,6 +2530,8 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
     { "COMPILE_LANGUAGE", &languageNode },
     { "LINK_LANG_AND_ID", &linkLanguageAndIdNode },
     { "LINK_LANGUAGE", &linkLanguageNode },
+    { "HOST_LINK", &hostLinkNode },
+    { "DEVICE_LINK", &deviceLinkNode },
     { "SHELL_PATH", &shellPathNode }
   };
 

+ 14 - 10
Source/cmGeneratorTarget.cxx

@@ -5532,6 +5532,13 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
   return propContent;
 }
 
+bool cmGeneratorTarget::SetDeviceLink(bool deviceLink)
+{
+  bool previous = this->DeviceLink;
+  this->DeviceLink = deviceLink;
+  return previous;
+}
+
 bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty(
   const std::string& p, const std::string& config) const
 {
@@ -5955,7 +5962,6 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
   }
 
   // Lookup any existing link interface for this configuration.
-  std::string CONFIG = cmSystemTools::UpperCase(config);
   cmHeadToLinkInterfaceMap& hm =
     (usage_requirements_only
        ? this->GetHeadToLinkInterfaceUsageRequirementsMap(config)
@@ -6377,7 +6383,6 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
     return nullptr;
   }
 
-  std::string CONFIG = cmSystemTools::UpperCase(config);
   cmHeadToLinkInterfaceMap& hm =
     (usage_requirements_only
        ? this->GetHeadToLinkInterfaceUsageRequirementsMap(config)
@@ -6591,16 +6596,15 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
 cmHeadToLinkInterfaceMap& cmGeneratorTarget::GetHeadToLinkInterfaceMap(
   const std::string& config) const
 {
-  std::string CONFIG = cmSystemTools::UpperCase(config);
-  return this->LinkInterfaceMap[CONFIG];
+  return this->LinkInterfaceMap[cmSystemTools::UpperCase(config)];
 }
 
 cmHeadToLinkInterfaceMap&
 cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap(
   const std::string& config) const
 {
-  std::string CONFIG = cmSystemTools::UpperCase(config);
-  return this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG];
+  return this
+    ->LinkInterfaceUsageRequirementsOnlyMap[cmSystemTools::UpperCase(config)];
 }
 
 const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
@@ -6617,8 +6621,8 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
     return nullptr;
   }
 
-  std::string CONFIG = cmSystemTools::UpperCase(config);
-  cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this];
+  cmOptionalLinkImplementation& impl =
+    this->LinkImplMap[cmSystemTools::UpperCase(config)][this];
   if (secondPass) {
     impl = cmOptionalLinkImplementation();
   }
@@ -6877,8 +6881,8 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
   }
 
   // Populate the link implementation libraries for this configuration.
-  std::string CONFIG = cmSystemTools::UpperCase(config);
-  HeadToLinkImplementationMap& hm = this->LinkImplMap[CONFIG];
+  HeadToLinkImplementationMap& hm =
+    this->LinkImplMap[cmSystemTools::UpperCase(config)];
 
   // If the link implementation does not depend on the head target
   // then return the one we computed first.

+ 19 - 0
Source/cmGeneratorTarget.h

@@ -204,6 +204,24 @@ public:
   const char* GetLinkInterfaceDependentNumberMaxProperty(
     const std::string& p, const std::string& config) const;
 
+  class DeviceLinkSetter
+  {
+  public:
+    DeviceLinkSetter(cmGeneratorTarget& target)
+      : Target(target)
+    {
+      this->PreviousState = target.SetDeviceLink(true);
+    }
+    ~DeviceLinkSetter() { this->Target.SetDeviceLink(this->PreviousState); };
+
+  private:
+    cmGeneratorTarget& Target;
+    bool PreviousState;
+  };
+
+  bool SetDeviceLink(bool deviceLink);
+  bool IsDeviceLink() const { return this->DeviceLink; }
+
   cmLinkInterface const* GetLinkInterface(
     const std::string& config, const cmGeneratorTarget* headTarget) const;
   void ComputeLinkInterface(const std::string& config,
@@ -829,6 +847,7 @@ private:
   mutable std::string LinkerLanguage;
   using LinkClosureMapType = std::map<std::string, LinkClosure>;
   mutable LinkClosureMapType LinkClosureMap;
+  bool DeviceLink = false;
 
   // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
   const char* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const;

+ 1 - 1
Source/cmStringAlgorithms.h

@@ -87,7 +87,7 @@ void cmExpandLists(InputIt first, InputIt last,
                    std::vector<std::string>& argsOut)
 {
   for (; first != last; ++first) {
-    ExpandList(*first, argsOut);
+    cmExpandList(*first, argsOut);
   }
 }
 

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_command-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_command-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-add_custom_command.cmake:[0-9]+ \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_command.cmake

@@ -0,0 +1,4 @@
+add_custom_target(drive)
+add_custom_command(TARGET drive PRE_BUILD
+  COMMAND ${CMAKE_COMMAND} -E echo $<DEVICE_LINK>
+)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_target-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_target-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-add_custom_target.cmake:[0-9]+ \(add_custom_target\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 3 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_custom_target.cmake

@@ -0,0 +1,3 @@
+add_custom_target(drive
+  COMMAND ${CMAKE_COMMAND} -E echo $<DEVICE_LINK>
+)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_executable-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_executable-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-add_executable.cmake:[0-9]+ \(add_executable\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:empty.c>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_executable.cmake

@@ -0,0 +1 @@
+add_executable(empty $<DEVICE_LINK:empty.c>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_library-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_library-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-add_library.cmake:[0-9]+ \(add_library\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:empty.c>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_library.cmake

@@ -0,0 +1 @@
+add_library(empty $<DEVICE_LINK:empty.c>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_test-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_test-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-add_test.cmake:[0-9]+ \(add_test\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 5 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-add_test.cmake

@@ -0,0 +1,5 @@
+
+include(CTest)
+enable_testing()
+
+add_test(NAME dummy COMMAND ${CMAKE_COMMAND} -E echo $<DEVICE_LINK>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-install-result.txt

@@ -0,0 +1 @@
+1

+ 7 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-install-stderr.txt

@@ -0,0 +1,7 @@
+CMake Error:
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:empty>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.

+ 5 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-install.cmake

@@ -0,0 +1,5 @@
+
+install(FILES
+  $<DEVICE_LINK:empty>
+  DESTINATION src
+)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-link_depends-result.txt

@@ -0,0 +1 @@
+1

+ 7 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-link_depends-stderr.txt

@@ -0,0 +1,7 @@
+CMake Error:
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:lib>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.

+ 7 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-link_depends.cmake

@@ -0,0 +1,7 @@
+
+enable_language(C)
+
+add_library(lib empty.c)
+
+add_executable(empty empty.c)
+set_property(TARGET empty PROPERTY LINK_DEPENDS $<DEVICE_LINK:lib>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_definitions-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_definitions-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-target_compile_definitions.cmake:[0-9]+ \(target_compile_definitions\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:DEF>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_definitions.cmake

@@ -0,0 +1,4 @@
+
+enable_language(C)
+add_executable(empty empty.c)
+target_compile_definitions(empty PRIVATE $<DEVICE_LINK:DEF>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_options-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_options-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-target_compile_options.cmake:[0-9]+ \(target_compile_options\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:-OPT>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_compile_options.cmake

@@ -0,0 +1,4 @@
+
+enable_language(C)
+add_executable(empty empty.c)
+target_compile_options(empty PRIVATE $<DEVICE_LINK:-OPT>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_include_directories-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_include_directories-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-target_include_directories.cmake:[0-9]+ \(target_include_directories\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:/DIR>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_include_directories.cmake

@@ -0,0 +1,4 @@
+
+enable_language(C)
+add_executable(empty empty.c)
+target_include_directories(empty PRIVATE $<DEVICE_LINK:/DIR>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_directories-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_directories-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-target_link_directories.cmake:[0-9]+ \(target_link_directories\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:/DIR>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 7 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_directories.cmake

@@ -0,0 +1,7 @@
+
+enable_language(C)
+
+add_library(lib empty.c)
+
+add_executable(empty empty.c)
+target_link_directories(empty PRIVATE $<DEVICE_LINK:/DIR>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_libraries-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_libraries-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-target_link_libraries.cmake:[0-9]+ \(target_link_libraries\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:lib>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 7 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_link_libraries.cmake

@@ -0,0 +1,7 @@
+
+enable_language(C)
+
+add_library(lib empty.c)
+
+add_executable(empty empty.c)
+target_link_libraries(empty PRIVATE $<DEVICE_LINK:lib>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_sources-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_sources-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at DEVICE_LINK-target_sources.cmake:[0-9]+ \(target_sources\):
+  Error evaluating generator expression:
+
+    \$<DEVICE_LINK:empty.c>
+
+  \$<DEVICE_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 2 - 0
Tests/RunCMake/GeneratorExpression/DEVICE_LINK-target_sources.cmake

@@ -0,0 +1,2 @@
+add_library(empty)
+target_sources(empty PRIVATE $<DEVICE_LINK:empty.c>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_command-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_command-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-add_custom_command.cmake:[0-9]+ \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_command.cmake

@@ -0,0 +1,4 @@
+add_custom_target(drive)
+add_custom_command(TARGET drive PRE_BUILD
+  COMMAND ${CMAKE_COMMAND} -E echo $<HOST_LINK>
+)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_target-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_target-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-add_custom_target.cmake:[0-9]+ \(add_custom_target\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 3 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_custom_target.cmake

@@ -0,0 +1,3 @@
+add_custom_target(drive
+  COMMAND ${CMAKE_COMMAND} -E echo $<HOST_LINK>
+)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_executable-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_executable-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-add_executable.cmake:[0-9]+ \(add_executable\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:empty.c>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_executable.cmake

@@ -0,0 +1 @@
+add_executable(empty $<HOST_LINK:empty.c>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_library-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_library-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-add_library.cmake:[0-9]+ \(add_library\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:empty.c>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_library.cmake

@@ -0,0 +1 @@
+add_library(empty $<HOST_LINK:empty.c>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_test-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_test-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-add_test.cmake:[0-9]+ \(add_test\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 5 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-add_test.cmake

@@ -0,0 +1,5 @@
+
+include(CTest)
+enable_testing()
+
+add_test(NAME dummy COMMAND ${CMAKE_COMMAND} -E echo $<HOST_LINK>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-install-result.txt

@@ -0,0 +1 @@
+1

+ 7 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-install-stderr.txt

@@ -0,0 +1,7 @@
+CMake Error:
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:empty>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.

+ 5 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-install.cmake

@@ -0,0 +1,5 @@
+
+install(FILES
+  $<HOST_LINK:empty>
+  DESTINATION src
+)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-link_depends-result.txt

@@ -0,0 +1 @@
+1

+ 7 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-link_depends-stderr.txt

@@ -0,0 +1,7 @@
+CMake Error:
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:lib>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.

+ 7 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-link_depends.cmake

@@ -0,0 +1,7 @@
+
+enable_language(C)
+
+add_library(lib empty.c)
+
+add_executable(empty empty.c)
+set_property(TARGET empty PROPERTY LINK_DEPENDS $<HOST_LINK:lib>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_definitions-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_definitions-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-target_compile_definitions.cmake:[0-9]+ \(target_compile_definitions\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:DEF>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_definitions.cmake

@@ -0,0 +1,4 @@
+
+enable_language(C)
+add_executable(empty empty.c)
+target_compile_definitions(empty PRIVATE $<HOST_LINK:DEF>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_options-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_options-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-target_compile_options.cmake:[0-9]+ \(target_compile_options\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:-OPT>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_compile_options.cmake

@@ -0,0 +1,4 @@
+
+enable_language(C)
+add_executable(empty empty.c)
+target_compile_options(empty PRIVATE $<HOST_LINK:-OPT>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_include_directories-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_include_directories-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-target_include_directories.cmake:[0-9]+ \(target_include_directories\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:/DIR>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_include_directories.cmake

@@ -0,0 +1,4 @@
+
+enable_language(C)
+add_executable(empty empty.c)
+target_include_directories(empty PRIVATE $<HOST_LINK:/DIR>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_directories-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_directories-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-target_link_directories.cmake:[0-9]+ \(target_link_directories\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:/DIR>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 7 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_directories.cmake

@@ -0,0 +1,7 @@
+
+enable_language(C)
+
+add_library(lib empty.c)
+
+add_executable(empty empty.c)
+target_link_directories(empty PRIVATE $<HOST_LINK:/DIR>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_libraries-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_libraries-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-target_link_libraries.cmake:[0-9]+ \(target_link_libraries\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:lib>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 7 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_link_libraries.cmake

@@ -0,0 +1,7 @@
+
+enable_language(C)
+
+add_library(lib empty.c)
+
+add_executable(empty empty.c)
+target_link_libraries(empty PRIVATE $<HOST_LINK:lib>)

+ 1 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_sources-result.txt

@@ -0,0 +1 @@
+1

+ 9 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_sources-stderr.txt

@@ -0,0 +1,9 @@
+CMake Error at HOST_LINK-target_sources.cmake:[0-9]+ \(target_sources\):
+  Error evaluating generator expression:
+
+    \$<HOST_LINK:empty.c>
+
+  \$<HOST_LINK:...> may only be used with binary targets to specify link
+  options.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)

+ 2 - 0
Tests/RunCMake/GeneratorExpression/HOST_LINK-target_sources.cmake

@@ -0,0 +1,2 @@
+add_library(empty)
+target_sources(empty PRIVATE $<HOST_LINK:empty.c>)

+ 30 - 0
Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake

@@ -64,6 +64,36 @@ run_cmake(LINK_LANG_AND_ID-wrong-usage1)
 run_cmake(LINK_LANG_AND_ID-wrong-usage2)
 run_cmake(LINK_LANG_AND_ID-wrong-usage3)
 run_cmake(LINK_LANG_AND_ID-file_generate)
+run_cmake(HOST_LINK-add_custom_target)
+run_cmake(HOST_LINK-add_custom_command)
+run_cmake(HOST_LINK-install)
+run_cmake(HOST_LINK-add_executable)
+run_cmake(HOST_LINK-add_library)
+run_cmake(HOST_LINK-add_test)
+run_cmake(HOST_LINK-target_sources)
+run_cmake(HOST_LINK-target_compile_definitions)
+run_cmake(HOST_LINK-target_compile_options)
+run_cmake(HOST_LINK-target_include_directories)
+run_cmake(HOST_LINK-target_link_libraries)
+run_cmake(HOST_LINK-target_link_directories)
+if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
+  run_cmake(HOST_LINK-link_depends)
+endif()
+run_cmake(DEVICE_LINK-add_custom_target)
+run_cmake(DEVICE_LINK-add_custom_command)
+run_cmake(DEVICE_LINK-install)
+run_cmake(DEVICE_LINK-add_executable)
+run_cmake(DEVICE_LINK-add_library)
+run_cmake(DEVICE_LINK-add_test)
+run_cmake(DEVICE_LINK-target_sources)
+run_cmake(DEVICE_LINK-target_compile_definitions)
+run_cmake(DEVICE_LINK-target_compile_options)
+run_cmake(DEVICE_LINK-target_include_directories)
+run_cmake(DEVICE_LINK-target_link_libraries)
+run_cmake(DEVICE_LINK-target_link_directories)
+if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
+  run_cmake(DEVICE_LINK-link_depends)
+endif()
 run_cmake(TARGET_FILE-recursion)
 run_cmake(OUTPUT_NAME-recursion)
 run_cmake(TARGET_FILE_PREFIX)

+ 5 - 0
Tests/RunCMake/target_link_options/RunCMakeTest.cmake

@@ -44,6 +44,11 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
   run_cmake_target(genex_LINK_LANG_AND_ID mod LinkOptions_mod --config Release)
   run_cmake_target(genex_LINK_LANG_AND_ID exe LinkOptions_exe --config Release)
 
+  run_cmake(genex_DEVICE_LINK)
+
+  run_cmake_target(genex_DEVICE_LINK interface LinkOptions_shared_interface --config Release)
+  run_cmake_target(genex_DEVICE_LINK private LinkOptions_private --config Release)
+
   unset(RunCMake_TEST_OPTIONS)
   unset(RunCMake_TEST_OUTPUT_MERGE)
 endif()

+ 3 - 0
Tests/RunCMake/target_link_options/genex_DEVICE_LINK-interface-check.cmake

@@ -0,0 +1,3 @@
+set (DEVICE_LINK FALSE)
+
+include ("${CMAKE_CURRENT_LIST_DIR}/genex_DEVICE_LINK-validation.cmake")

+ 1 - 0
Tests/RunCMake/target_link_options/genex_DEVICE_LINK-interface-result.txt

@@ -0,0 +1 @@
+.*

+ 3 - 0
Tests/RunCMake/target_link_options/genex_DEVICE_LINK-private-check.cmake

@@ -0,0 +1,3 @@
+set (DEVICE_LINK FALSE)
+
+include ("${CMAKE_CURRENT_LIST_DIR}/genex_DEVICE_LINK-validation.cmake")

+ 1 - 0
Tests/RunCMake/target_link_options/genex_DEVICE_LINK-private-result.txt

@@ -0,0 +1 @@
+.*

+ 22 - 0
Tests/RunCMake/target_link_options/genex_DEVICE_LINK-validation.cmake

@@ -0,0 +1,22 @@
+
+if (NOT DEFINED DEVICE_LINK)
+  set (DEVICE_LINK FALSE)
+endif()
+
+if (DEVICE_LINK)
+  set (VALID_ID DEVICE_LINK)
+  set (INVALID_ID NORMAL_LINK)
+else()
+  set (VALID_ID NORMAL_LINK)
+  set (INVALID_ID DEVICE_LINK)
+endif()
+
+if (NOT actual_stdout MATCHES "BADFLAG_${VALID_ID}")
+  set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_${VALID_ID}'.")
+endif()
+if (actual_stdout MATCHES "BADFLAG_${INVALID_ID}")
+  if (RunCMake_TEST_FAILED)
+    string (APPEND RunCMake_TEST_FAILED "\n")
+  endif()
+  string (APPEND RunCMake_TEST_FAILED "Found unexpected 'BADFLAG_${INVALID_ID}'.")
+endif()

+ 19 - 0
Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake

@@ -0,0 +1,19 @@
+
+enable_language(C)
+
+set (obj "${CMAKE_C_OUTPUT_EXTENSION}")
+if(BORLAND)
+  set(pre -)
+endif()
+
+add_library(LinkOptions_interface INTERFACE)
+target_link_options (LinkOptions_interface INTERFACE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>
+                                                     $<HOST_LINK:${pre}BADFLAG_NORMAL_LINK${obj}>)
+
+add_library(LinkOptions_shared_interface SHARED LinkOptionsLib.c)
+target_link_libraries (LinkOptions_shared_interface PRIVATE LinkOptions_interface)
+
+
+add_library(LinkOptions_private SHARED LinkOptionsLib.c)
+target_link_options (LinkOptions_private PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>
+                                                 $<HOST_LINK:${pre}BADFLAG_NORMAL_LINK${obj}>)