diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index c6b6184bbf..cac60e14a8 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -3,9 +3,10 @@ #include "cmExportTryCompileFileGenerator.h" #include -#include #include +#include + #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 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( + tgt, "LINK_OPTIONS", nullptr, nullptr); + } + cmGeneratorExpressionDAGChecker dagChecker(tgt, propName, nullptr, + parentDagChecker.get()); std::unique_ptr cge = ge.Parse(*prop); diff --git a/Tests/RunCMake/GenEx-DEVICE_LINK/DEVICE_LINK-try_compile.cmake b/Tests/RunCMake/GenEx-DEVICE_LINK/DEVICE_LINK-try_compile.cmake new file mode 100644 index 0000000000..281f8aa3ab --- /dev/null +++ b/Tests/RunCMake/GenEx-DEVICE_LINK/DEVICE_LINK-try_compile.cmake @@ -0,0 +1,9 @@ + +enable_language(C) + +add_library(demo INTERFACE IMPORTED) +set_property(TARGET demo PROPERTY INTERFACE_LINK_OPTIONS "$") + +set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) +try_compile(result "${CMAKE_CURRENT_BINARY_DIR}/tc" "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" + LINK_LIBRARIES demo) diff --git a/Tests/RunCMake/GenEx-DEVICE_LINK/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-DEVICE_LINK/RunCMakeTest.cmake index 1e44601462..80633e2580 100644 --- a/Tests/RunCMake/GenEx-DEVICE_LINK/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-DEVICE_LINK/RunCMakeTest.cmake @@ -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() diff --git a/Tests/RunCMake/GenEx-HOST_LINK/HOST_LINK-try_compile.cmake b/Tests/RunCMake/GenEx-HOST_LINK/HOST_LINK-try_compile.cmake new file mode 100644 index 0000000000..f221ff1b6a --- /dev/null +++ b/Tests/RunCMake/GenEx-HOST_LINK/HOST_LINK-try_compile.cmake @@ -0,0 +1,9 @@ + +enable_language(C) + +add_library(demo INTERFACE IMPORTED) +set_property(TARGET demo PROPERTY INTERFACE_LINK_OPTIONS "$") + +set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) +try_compile(result "${CMAKE_CURRENT_BINARY_DIR}/tc" "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" + LINK_LIBRARIES demo) diff --git a/Tests/RunCMake/GenEx-HOST_LINK/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-HOST_LINK/RunCMakeTest.cmake index 329a7c6bc1..9e3eeec416 100644 --- a/Tests/RunCMake/GenEx-HOST_LINK/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-HOST_LINK/RunCMakeTest.cmake @@ -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()