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.
This commit is contained in:
Marc Chevrier
2020-04-05 17:21:57 +02:00
parent 38332fc4fa
commit 3fdae5acaa
94 changed files with 572 additions and 11 deletions

View File

@@ -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
===================================

View File

@@ -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.

View File

@@ -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
{

View File

@@ -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;

View File

@@ -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 }
};

View File

@@ -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.

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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.

View File

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

View File

@@ -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.

View File

@@ -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>)

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

@@ -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>)

View File

@@ -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\)

View File

@@ -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>)

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

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

View File

@@ -0,0 +1 @@
1

View File

@@ -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.

View File

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

View File

@@ -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.

View File

@@ -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>)

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

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

View File

@@ -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\)

View File

@@ -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>)

View File

@@ -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\)

View File

@@ -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>)

View File

@@ -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\)

View File

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

View File

@@ -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)

View File

@@ -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()

View File

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

View File

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

View File

@@ -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()

View File

@@ -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}>)