Genex: $<HOST_LINK:> and $<DEVICE_LINK:> must be usable in try_compile
Fixes: #22007
This commit is contained in:
parent
36f1f7c449
commit
6cf81efe7d
@ -3,9 +3,10 @@
|
||||
#include "cmExportTryCompileFileGenerator.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <cm/memory>
|
||||
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorExpressionDAGChecker.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
@ -66,7 +67,15 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
|
||||
|
||||
cmGeneratorExpression ge;
|
||||
|
||||
cmGeneratorExpressionDAGChecker dagChecker(tgt, propName, nullptr, nullptr);
|
||||
std::unique_ptr<cmGeneratorExpressionDAGChecker> parentDagChecker;
|
||||
if (propName == "INTERFACE_LINK_OPTIONS") {
|
||||
// To please constraint checks of DAGChecker, this property must have
|
||||
// LINK_OPTIONS property as parent
|
||||
parentDagChecker = cm::make_unique<cmGeneratorExpressionDAGChecker>(
|
||||
tgt, "LINK_OPTIONS", nullptr, nullptr);
|
||||
}
|
||||
cmGeneratorExpressionDAGChecker dagChecker(tgt, propName, nullptr,
|
||||
parentDagChecker.get());
|
||||
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*prop);
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
|
||||
enable_language(C)
|
||||
|
||||
add_library(demo INTERFACE IMPORTED)
|
||||
set_property(TARGET demo PROPERTY INTERFACE_LINK_OPTIONS "$<DEVICE_LINK:>")
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
|
||||
try_compile(result "${CMAKE_CURRENT_BINARY_DIR}/tc" "${CMAKE_CURRENT_SOURCE_DIR}/empty.c"
|
||||
LINK_LIBRARIES demo)
|
@ -12,6 +12,7 @@ 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)
|
||||
run_cmake(DEVICE_LINK-try_compile)
|
||||
if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
|
||||
run_cmake(DEVICE_LINK-link_depends)
|
||||
endif()
|
||||
|
@ -0,0 +1,9 @@
|
||||
|
||||
enable_language(C)
|
||||
|
||||
add_library(demo INTERFACE IMPORTED)
|
||||
set_property(TARGET demo PROPERTY INTERFACE_LINK_OPTIONS "$<HOST_LINK:>")
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
|
||||
try_compile(result "${CMAKE_CURRENT_BINARY_DIR}/tc" "${CMAKE_CURRENT_SOURCE_DIR}/empty.c"
|
||||
LINK_LIBRARIES demo)
|
@ -12,6 +12,7 @@ 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)
|
||||
run_cmake(HOST_LINK-try_compile)
|
||||
if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
|
||||
run_cmake(HOST_LINK-link_depends)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user