diff options
9 files changed, 63 insertions, 1 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 155efde..dec0858 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1294,6 +1294,14 @@ bool cmGlobalVisualStudio10Generator::IsInSolution( gt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET); } +bool cmGlobalVisualStudio10Generator::IsDepInSolution( + const std::string& targetName) const +{ + return !targetName.empty() && + !(this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 && + targetName == CMAKE_CHECK_BUILD_SYSTEM_TARGET); +} + bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) { if (this->DefaultPlatformToolset == "v100") { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 2203f71..12fd7a8 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -120,6 +120,8 @@ public: bool IsInSolution(const cmGeneratorTarget* gt) const override; + bool IsDepInSolution(const std::string& targetName) const override; + /** Return true if building for WindowsCE */ bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index ce943a2..758ce83 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -180,7 +180,7 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject( fout << "\tProjectSection(ProjectDependencies) = postProject\n"; for (BT<std::pair<std::string, bool>> const& it : depends) { std::string const& dep = it.Value.first; - if (!dep.empty()) { + if (this->IsDepInSolution(dep)) { fout << "\t\t{" << this->GetGUID(dep) << "} = {" << this->GetGUID(dep) << "}\n"; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index cddaaa4..c6af20a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -843,6 +843,12 @@ bool cmGlobalVisualStudioGenerator::IsInSolution( return gt->IsInBuildSystem(); } +bool cmGlobalVisualStudioGenerator::IsDepInSolution( + const std::string& targetName) const +{ + return !targetName.empty(); +} + bool cmGlobalVisualStudioGenerator::TargetCompare::operator()( cmGeneratorTarget const* l, cmGeneratorTarget const* r) const { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 4f5f100..f45b4d4 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -101,6 +101,9 @@ public: // return true if target should be included in solution. virtual bool IsInSolution(const cmGeneratorTarget* gt) const; + // return true if project dependency should be included in solution. + virtual bool IsDepInSolution(const std::string& targetName) const; + /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); diff --git a/Tests/RunCMake/include_external_msproject/Program.cs b/Tests/RunCMake/include_external_msproject/Program.cs new file mode 100644 index 0000000..5ed58c8 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/Program.cs @@ -0,0 +1,9 @@ +namespace ConsoleApp +{ + internal class Program + { + static void Main(string[] args) + { + } + } +} diff --git a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake index cb0eb18..4fbf147 100644 --- a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake @@ -10,3 +10,14 @@ if(RunCMake_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])") run_cmake(SkipGetTargetFrameworkProperties) run_cmake(VSCSharpReference) endif() + +if(RunCMake_GENERATOR MATCHES "^Visual Studio (1[6-9]|[2-9][0-9])") + function(run_VSCSharpOnlyProject) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VSCSharpOnlyProject-build) + run_cmake(VSCSharpOnlyProject) + set(RunCMake_TEST_NO_CLEAN 1) + set(build_flags /restore) + run_cmake_command(VSCSharpOnlyProject-build ${CMAKE_COMMAND} --build . -- ${build_flags}) + endfunction() + run_VSCSharpOnlyProject() +endif() diff --git a/Tests/RunCMake/include_external_msproject/VSCSharpOnlyProject.cmake b/Tests/RunCMake/include_external_msproject/VSCSharpOnlyProject.cmake new file mode 100644 index 0000000..e7e0b99 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/VSCSharpOnlyProject.cmake @@ -0,0 +1,9 @@ +project(VSCSharpOnlyProject) + +file(COPY + ${CMAKE_CURRENT_SOURCE_DIR}/Program.cs + ${CMAKE_CURRENT_SOURCE_DIR}/consoleapp.csproj + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + +include_external_msproject( + test "${CMAKE_CURRENT_BINARY_DIR}/consoleapp.csproj") diff --git a/Tests/RunCMake/include_external_msproject/consoleapp.csproj b/Tests/RunCMake/include_external_msproject/consoleapp.csproj new file mode 100644 index 0000000..2894848 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/consoleapp.csproj @@ -0,0 +1,14 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net472</TargetFramework> + <RootNamespace>ConsoleApp</RootNamespace> + <AssemblyName>ConsoleApp</AssemblyName> + <PlatformTarget>x64</PlatformTarget> + <EnableDefaultItems>false</EnableDefaultItems> + </PropertyGroup> + + <ItemGroup> + <Compile Include="Program.cs" /> + </ItemGroup> +</Project> |