From 53aabe9817dfad76869c41c2eeb46fb874bf188b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 29 Jul 2021 11:21:13 -0400 Subject: VS: Fix assertion failure on INCLUDE_DIRECTORIES in INTERFACE libraries Since commit 4391913133 (Add INTERFACE libraries to generated buildsystem if they have SOURCES, 2020-07-20, v3.19.0-rc1~346^2~1), the VS generator may process INTERFACE libraries. Avoid code paths in the generator that process include directories because they should not be used by INTERFACE libraries since they do not compile anything. Fixes: #22494 --- Source/cmVisualStudio10TargetGenerator.cxx | 3 +++ Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake | 7 +++++++ Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake | 1 + 3 files changed, 11 insertions(+) create mode 100644 Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 11a8b1f..bda2f91 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -4093,6 +4093,9 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions( if (this->ProjectType == csproj) { return; } + if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) { + return; + } // This processes *any* of the .idl files specified in the project's file // list (and passed as the item metadata %(Filename) expressing the rule diff --git a/Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake b/Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake new file mode 100644 index 0000000..b94eac0 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0076 NEW) +include_directories(Inc1 Inc2) +add_library(iface INTERFACE) +target_sources(iface PRIVATE iface.c) +# Ensure the INCLUDE_DIRECTORIES property is populated. +# Since interface libraries do not actually compile anything, this should be ignored. +set_property(TARGET iface APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Inc3 ${CMAKE_CURRENT_SOURCE_DIR}/Inc4) diff --git a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake index 834b3c8..10a2d51 100644 --- a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake @@ -34,3 +34,4 @@ run_WithSources(ConfigSources "build1:iface") run_WithSources(EmptySources "build1:iface" "build2:iface2,merge") run_WithSources(ExcludeFromAll "build1" "build2:iface" "build3:iface2,merge") run_WithSources(PublicSources "build1" "build2:iface" "build3:iface2,merge") +run_WithSources(IncludeDirectories "build1:iface") -- cgit v0.12