VS: Add support for per-config sources

Since commit 97cc29c766 (VS: Teach generators how to mark per-config
source files, 2017-04-10, v3.9.0-rc1~268^2~2) the VS generators have
known how to generate per-config sources.  We've now converted most
other code paths to support per-config sources, so drop the check
that disallows it.

This leaves only per-config support for precompiled headers and unity
build transformations, but those are optional features that can be
addressed later.

Fixes: #18233
Issue: #19789
This commit is contained in:
Brad King
2019-10-02 13:59:15 -04:00
parent bcaecf6bcd
commit 55a0bebdd3
4 changed files with 12 additions and 12 deletions
@@ -0,0 +1,5 @@
vs-per-config-sources
---------------------
* :ref:`Visual Studio Generators` learned to support per-config sources.
Previously only :ref:`Command-Line Build Tool Generators` supported them.
-9
View File
@@ -799,15 +799,6 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
cmGeneratorTarget const* gt) cmGeneratorTarget const* gt)
{ {
// check to see if this is a fortran build
{
// Issue diagnostic if the source files depend on the config.
std::vector<cmSourceFile*> sources;
if (!gt->GetConfigCommonSourceFiles(sources)) {
return false;
}
}
// If there's only one source language, Fortran has to be used // If there's only one source language, Fortran has to be used
// in order for the sources to compile. // in order for the sources to compile.
std::set<std::string> languages = gt->GetAllConfigCompileLanguages(); std::set<std::string> languages = gt->GetAllConfigCompileLanguages();
+6 -2
View File
@@ -451,8 +451,12 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(StagingPrefix StagingPrefix) ADD_TEST_MACRO(StagingPrefix StagingPrefix)
ADD_TEST_MACRO(ImportedSameName ImportedSameName) ADD_TEST_MACRO(ImportedSameName ImportedSameName)
ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
if(NOT _isMultiConfig) if(NOT CMAKE_GENERATOR STREQUAL "Xcode")
set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>) if(_isMultiConfig)
set(ConfigSources_CTEST_OPTIONS --build-config $<CONFIGURATION>)
else()
set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>)
endif()
ADD_TEST_MACRO(ConfigSources ConfigSources) ADD_TEST_MACRO(ConfigSources ConfigSources)
endif() endif()
ADD_TEST_MACRO(SourcesProperty SourcesProperty) ADD_TEST_MACRO(SourcesProperty SourcesProperty)
@@ -1,6 +1,6 @@
include(RunCMake) include(RunCMake)
if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") if(RunCMake_GENERATOR STREQUAL "Xcode")
run_cmake(ConfigNotAllowed) run_cmake(ConfigNotAllowed)
endif() endif()