Add property EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>

Allow EXCLUDE_FROM_DEFAULT_BUILD to be specified per configuration.
This commit is contained in:
Petr Kmoch 2012-10-11 21:57:22 +02:00 committed by Brad King
parent b777272b0b
commit d1f8828cc8
7 changed files with 65 additions and 42 deletions

View File

@ -273,9 +273,10 @@ void cmGlobalVisualStudio71Generator
// Write a dsp file into the SLN file, Note, that dependencies from // Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here // executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name, ::WriteProjectConfigurations(
bool partOfDefaultBuild, std::ostream& fout, const char* name,
const char* platformMapping) const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping)
{ {
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::iterator i = this->Configurations.begin();
@ -284,7 +285,9 @@ void cmGlobalVisualStudio71Generator
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|" << ".ActiveCfg = " << *i << "|"
<< (platformMapping ? platformMapping : "Win32") << std::endl; << (platformMapping ? platformMapping : "Win32") << std::endl;
if(partOfDefaultBuild) std::set<std::string>::const_iterator
ci = configsPartOfDefaultBuild.find(*i);
if(!(ci == configsPartOfDefaultBuild.end()))
{ {
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< ".Build.0 = " << *i << "|" << ".Build.0 = " << *i << "|"

View File

@ -61,10 +61,10 @@ protected:
const char* name, const char* path, cmTarget &t); const char* name, const char* path, cmTarget &t);
virtual void WriteProjectDepends(std::ostream& fout, virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t); const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout, virtual void WriteProjectConfigurations(
const char* name, std::ostream& fout, const char* name,
bool partOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping = NULL); const char* platformMapping = NULL);
virtual void WriteExternalProject(std::ostream& fout, virtual void WriteExternalProject(std::ostream& fout,
const char* name, const char* name,
const char* path, const char* path,

View File

@ -10,6 +10,7 @@
See the License for more information. See the License for more information.
============================================================================*/ ============================================================================*/
#include "windows.h" // this must be first to define GetCurrentDirectory #include "windows.h" // this must be first to define GetCurrentDirectory
#include <assert.h>
#include "cmGlobalVisualStudio7Generator.h" #include "cmGlobalVisualStudio7Generator.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmLocalVisualStudio7Generator.h" #include "cmLocalVisualStudio7Generator.h"
@ -243,20 +244,23 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
if(expath) if(expath)
{ {
std::set<std::string> allConfigurations(this->Configurations.begin(),
this->Configurations.end());
this->WriteProjectConfigurations( this->WriteProjectConfigurations(
fout, target->GetName(), fout, target->GetName(),
true, target->GetProperty("VS_PLATFORM_MAPPING")); allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING"));
} }
else else
{ {
bool partOfDefaultBuild = this->IsPartOfDefaultBuild( const std::set<std::string>& configsPartOfDefaultBuild =
root->GetMakefile()->GetProjectName(), target); this->IsPartOfDefaultBuild(root->GetMakefile()->GetProjectName(),
target);
const char *vcprojName = const char *vcprojName =
target->GetProperty("GENERATOR_FILE_NAME"); target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName) if (vcprojName)
{ {
this->WriteProjectConfigurations(fout, vcprojName, this->WriteProjectConfigurations(fout, vcprojName,
partOfDefaultBuild); configsPartOfDefaultBuild);
} }
} }
} }
@ -579,9 +583,10 @@ cmGlobalVisualStudio7Generator
// Write a dsp file into the SLN file, Note, that dependencies from // Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here // executables to the libraries it uses are also done here
void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name, ::WriteProjectConfigurations(
bool partOfDefaultBuild, std::ostream& fout, const char* name,
const char* platformMapping) const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping)
{ {
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::iterator i = this->Configurations.begin();
@ -590,7 +595,9 @@ void cmGlobalVisualStudio7Generator
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|" << ".ActiveCfg = " << *i << "|"
<< (platformMapping ? platformMapping : "Win32") << "\n"; << (platformMapping ? platformMapping : "Win32") << "\n";
if(partOfDefaultBuild) std::set<std::string>::const_iterator
ci = configsPartOfDefaultBuild.find(*i);
if(!(ci == configsPartOfDefaultBuild.end()))
{ {
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< ".Build.0 = " << *i << "|" << ".Build.0 = " << *i << "|"
@ -763,26 +770,34 @@ cmGlobalVisualStudio7Generator
} }
} }
bool cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, std::set<std::string>
cmTarget* target) cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
cmTarget* target)
{ {
if(target->GetPropertyAsBool("EXCLUDE_FROM_DEFAULT_BUILD")) std::set<std::string> activeConfigs;
{
return false;
}
// if it is a utilitiy target then only make it part of the // if it is a utilitiy target then only make it part of the
// default build if another target depends on it // default build if another target depends on it
int type = target->GetType(); int type = target->GetType();
if (type == cmTarget::GLOBAL_TARGET) if (type == cmTarget::GLOBAL_TARGET)
{ {
return false; return activeConfigs;
} }
if(type == cmTarget::UTILITY) if(type == cmTarget::UTILITY && !this->IsDependedOn(project, target))
{ {
return this->IsDependedOn(project, target); return activeConfigs;
} }
// default is to be part of the build // inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
return true; for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
const char* propertyValue =
target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
if(cmSystemTools::IsOff(propertyValue))
{
activeConfigs.insert(*i);
}
}
return activeConfigs;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -105,10 +105,10 @@ protected:
const char* name, const char* path, cmTarget &t); const char* name, const char* path, cmTarget &t);
virtual void WriteProjectDepends(std::ostream& fout, virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t); const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout, virtual void WriteProjectConfigurations(
const char* name, std::ostream& fout, const char* name,
bool partOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping = NULL); const char* platformMapping = NULL);
virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target); virtual std::string WriteUtilityDepend(cmTarget* target);
@ -136,8 +136,8 @@ protected:
std::string ConvertToSolutionPath(const char* path); std::string ConvertToSolutionPath(const char* path);
bool IsPartOfDefaultBuild(const char* project, std::set<std::string> IsPartOfDefaultBuild(const char* project,
cmTarget* target); cmTarget* target);
std::vector<std::string> Configurations; std::vector<std::string> Configurations;
std::map<cmStdString, cmStdString> GUIDMap; std::map<cmStdString, cmStdString> GUIDMap;

View File

@ -258,9 +258,10 @@ cmGlobalVisualStudio8Generator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGlobalVisualStudio8Generator cmGlobalVisualStudio8Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name, ::WriteProjectConfigurations(
bool partOfDefaultBuild, std::ostream& fout, const char* name,
const char* platformMapping) const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping)
{ {
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::iterator i = this->Configurations.begin();
@ -270,7 +271,9 @@ cmGlobalVisualStudio8Generator
<< "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
<< (platformMapping ? platformMapping : this->GetPlatformName()) << (platformMapping ? platformMapping : this->GetPlatformName())
<< "\n"; << "\n";
if(partOfDefaultBuild) std::set<std::string>::const_iterator
ci = configsPartOfDefaultBuild.find(*i);
if(!(ci == configsPartOfDefaultBuild.end()))
{ {
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|" << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|"

View File

@ -74,10 +74,10 @@ protected:
static cmIDEFlagTable const* GetExtraFlagTableVS8(); static cmIDEFlagTable const* GetExtraFlagTableVS8();
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(std::ostream& fout, virtual void WriteProjectConfigurations(
const char* name, std::ostream& fout, const char* name,
bool partOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
const char* platformMapping = NULL); const char* platformMapping = NULL);
virtual bool ComputeTargetDepends(); virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name, virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t); const char* path, cmTarget &t);

View File

@ -156,7 +156,9 @@ public:
"\n" "\n"
"The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual " "The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual "
"studio generators. If it is set to 1 the target will not be " "studio generators. If it is set to 1 the target will not be "
"part of the default build when you select \"Build Solution\"." "part of the default build when you select \"Build Solution\". "
"This can also be set on a per-configuration basis using "
"EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>."
; ;
} }