diff options
32 files changed, 629 insertions, 563 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b0a7f64..c034126 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 0) -set(CMake_VERSION_PATCH 20140718) +set(CMake_VERSION_PATCH 20140721) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 7c72cba..109905c 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -225,8 +225,8 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, std::string upload_as = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); - struct stat st; - if ( ::stat(local_file.c_str(), &st) ) + + if ( !cmSystemTools::FileExists(local_file.c_str()) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " << local_file << std::endl); @@ -234,6 +234,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, ::curl_global_cleanup(); return false; } + unsigned long filelen = cmSystemTools::FileLength(local_file.c_str()); ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); *this->LogFile << "\tUpload file: " << local_file << " to " @@ -252,7 +253,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, // and give the size of the upload (optional) ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, - static_cast<long>(st.st_size)); + static_cast<long>(filelen)); // and give curl the buffer for errors ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); @@ -466,8 +467,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, upload_as += md5; } - struct stat st; - if ( ::stat(local_file.c_str(), &st) ) + if( !cmSystemTools::FileExists(local_file.c_str()) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " << local_file << std::endl); @@ -475,11 +475,12 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, ::curl_global_cleanup(); return false; } + unsigned long filelen = cmSystemTools::FileLength(local_file.c_str()); ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file << " to " - << upload_as << " Size: " << st.st_size << std::endl); + << upload_as << " Size: " << filelen << std::endl); // specify target ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str()); @@ -489,7 +490,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, // and give the size of the upload (optional) ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, - static_cast<long>(st.st_size)); + static_cast<long>(filelen)); // and give curl the buffer for errors ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 36932aa..6d737b1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -448,6 +448,14 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, mf->ReadListFile(0,fpath.c_str()); } + // Tell the generator about the target system. + std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); + if(!this->SetSystemName(system, mf)) + { + cmSystemTools::SetFatalErrorOccured(); + return; + } + // Tell the generator about the toolset, if any. std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET"); if(!toolset.empty() && diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 5e6c03e..ee3f269 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -61,6 +61,10 @@ public: virtual bool MatchesGeneratorName(const std::string& name) const { return this->GetName() == name; } + /** Tell the generator about the target system. */ + virtual bool SetSystemName(std::string const&, cmMakefile*) + { return true; } + /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a6d1c31..c1b087a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -51,19 +51,19 @@ public: if(!*p) { return new cmGlobalVisualStudio10Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio10Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "IA64") == 0) { return new cmGlobalVisualStudio10Generator( - genName, "Itanium", "CMAKE_FORCE_IA64"); + genName, "Itanium"); } return 0; } @@ -90,10 +90,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio8Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio8Generator(name, platformName) { std::string vc10Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( @@ -127,10 +125,18 @@ cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts, } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf) +bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, + cmMakefile* mf) { - cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf); + if(this->PlatformName == "Itanium" || this->PlatformName == "x64") + { + if(this->IsExpressEdition() && !this->Find64BitTools(mf)) + { + return false; + } + } this->AddVSPlatformToolsetDefinition(mf); + return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); } //---------------------------------------------------------------------------- @@ -162,7 +168,6 @@ cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS10); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } @@ -204,14 +209,6 @@ void cmGlobalVisualStudio10Generator ::EnableLanguage(std::vector<std::string>const & lang, cmMakefile *mf, bool optional) { - if(this->PlatformName == "Itanium" || this->PlatformName == "x64") - { - if(this->IsExpressEdition() && !this->Find64BitTools(mf)) - { - return; - } - } - for(std::vector<std::string>::const_iterator it = lang.begin(); it != lang.end(); ++it) { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index b4dcc7e..cb639dd 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -25,13 +25,13 @@ class cmGlobalVisualStudio10Generator : { public: cmGlobalVisualStudio10Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); + virtual bool SetSystemName(std::string const& s, cmMakefile* mf); virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, @@ -44,8 +44,6 @@ public: std::vector<std::string> const& makeOptions = std::vector<std::string>() ); - virtual void AddPlatformDefinitions(cmMakefile* mf); - ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index fa134fc..e5a159b 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -46,19 +46,19 @@ public: if(!*p) { return new cmGlobalVisualStudio11Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio11Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio11Generator( - genName, "ARM", ""); + genName, "ARM"); } std::set<std::string> installedSDKs = @@ -70,7 +70,7 @@ public: } cmGlobalVisualStudio11Generator* ret = - new cmGlobalVisualStudio11Generator(name, p, NULL); + new cmGlobalVisualStudio11Generator(name, p); ret->WindowsCEVersion = "8.00"; return ret; } @@ -105,10 +105,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio10Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio10Generator(name, platformName) { std::string vc11Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( @@ -149,7 +147,6 @@ cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 48ea489..3d89a94 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -21,8 +21,7 @@ class cmGlobalVisualStudio11Generator: { public: cmGlobalVisualStudio11Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 698624d..4235cbc 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -46,19 +46,19 @@ public: if(!*p) { return new cmGlobalVisualStudio12Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio12Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio12Generator( - genName, "ARM", ""); + genName, "ARM"); } return 0; } @@ -85,10 +85,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio11Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio11Generator(name, platformName) { std::string vc12Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( @@ -129,7 +127,6 @@ cmLocalGenerator *cmGlobalVisualStudio12Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS12); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 4557f28..8ac2d1d 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -21,8 +21,7 @@ class cmGlobalVisualStudio12Generator: { public: cmGlobalVisualStudio12Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 9bde0ad..d001f93 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -31,19 +31,19 @@ public: if(!*p) { return new cmGlobalVisualStudio14Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio14Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio14Generator( - genName, "ARM", ""); + genName, "ARM"); } return 0; } @@ -70,10 +70,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio12Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio12Generator(name, platformName) { std::string vc14Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( @@ -110,7 +108,6 @@ cmLocalGenerator *cmGlobalVisualStudio14Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS14); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 7074119..3fd60a0 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -21,8 +21,7 @@ class cmGlobalVisualStudio14Generator: { public: cmGlobalVisualStudio14Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 7397bbb..455a7a2 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -41,7 +41,6 @@ void cmGlobalVisualStudio6Generator cmMakefile *mf, bool optional) { - cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); this->GenerateConfigurations(mf); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a918d1d..602d678 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -80,7 +80,6 @@ void cmGlobalVisualStudio7Generator { mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - this->AddPlatformDefinitions(mf); if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) { mf->AddCacheDefinition( @@ -260,12 +259,21 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) +bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, + cmMakefile* mf) { - cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); + if(this->PlatformName == "x64") + { + mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); + } + else if(this->PlatformName == "Itanium") + { + mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); + } mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", this->GetIntelProjectVersion()); + return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); } void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 291d297..bd84433 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -44,7 +44,7 @@ public: ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); - virtual void AddPlatformDefinitions(cmMakefile* mf); + virtual bool SetSystemName(std::string const& s, cmMakefile* mf); /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e6672a8..9fd3d5a 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -36,7 +36,7 @@ public: if(p[0] == '\0') { return new cmGlobalVisualStudio8Generator( - name, "", ""); + name, ""); } if(p[0] != ' ') @@ -49,7 +49,7 @@ public: if(!strcmp(p, "Win64")) { return new cmGlobalVisualStudio8Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + name, "x64"); } cmVisualStudioWCEPlatformParser parser(p); @@ -60,7 +60,7 @@ public: } cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator( - name, p, ""); + name, p); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -93,17 +93,11 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) + const std::string& name, const std::string& platformName) : cmGlobalVisualStudio71Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; - - if (!additionalPlatformDefinition.empty()) - { - this->AdditionalPlatformDefinition = additionalPlatformDefinition; - } } //---------------------------------------------------------------------------- @@ -132,17 +126,23 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8); - lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) +void cmGlobalVisualStudio8Generator +::EnableLanguage(std::vector<std::string>const & lang, + cmMakefile *mf, bool optional) { - cmGlobalVisualStudio71Generator::AddPlatformDefinitions(mf); + this->AddPlatformDefinitions(mf); + cmGlobalVisualStudio7Generator::EnableLanguage(lang, mf, optional); +} +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) +{ if(this->TargetsWindowsCE()) { mf->AddDefinition("CMAKE_VS_WINCE_VERSION", diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 2459c05..aea2f01 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -24,8 +24,7 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: cmGlobalVisualStudio8Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. @@ -37,6 +36,8 @@ public: ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); + virtual void EnableLanguage(std::vector<std::string>const& languages, + cmMakefile *, bool optional); virtual void AddPlatformDefinitions(cmMakefile* mf); /** diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index c0051c7..1d73b5c 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -34,7 +34,7 @@ public: if(p[0] == '\0') { return new cmGlobalVisualStudio9Generator( - name, "", ""); + name, ""); } if(p[0] != ' ') @@ -47,13 +47,13 @@ public: if(!strcmp(p, "IA64")) { return new cmGlobalVisualStudio9Generator( - name, "Itanium", "CMAKE_FORCE_IA64"); + name, "Itanium"); } if(!strcmp(p, "Win64")) { return new cmGlobalVisualStudio9Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + name, "x64"); } cmVisualStudioWCEPlatformParser parser(p); @@ -64,7 +64,7 @@ public: } cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator( - name, p, NULL); + name, p); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -98,10 +98,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio8Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio8Generator(name, platformName) { } @@ -117,21 +115,12 @@ cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); - lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Generator -::EnableLanguage(std::vector<std::string>const & lang, - cmMakefile *mf, bool optional) -{ - cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); -} - -//---------------------------------------------------------------------------- std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory() { std::string base; diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index fb87bbe..c24d5fe 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -25,8 +25,7 @@ class cmGlobalVisualStudio9Generator : { public: cmGlobalVisualStudio9Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator @@ -36,8 +35,6 @@ public: * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); virtual void WriteSLNHeader(std::ostream& fout); /** diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c5a0e29..2dab23c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -23,7 +23,6 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { - this->AdditionalPlatformDefinition = ""; } //---------------------------------------------------------------------------- @@ -478,15 +477,6 @@ void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) -{ - if(!this->AdditionalPlatformDefinition.empty()) - { - mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); - } -} - -//---------------------------------------------------------------------------- std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target) { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 1ab8990..05dbb11 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -97,8 +97,6 @@ protected: virtual const char* GetIDEVersion() = 0; - virtual void AddPlatformDefinitions(cmMakefile* mf); - virtual bool ComputeTargetDepends(); class VSDependSet: public std::set<std::string> {}; class VSDependMap: public std::map<cmTarget const*, VSDependSet> {}; @@ -111,7 +109,6 @@ protected: std::string GetUtilityDepend(cmTarget const* target); typedef std::map<cmTarget const*, std::string> UtilityDependsMap; UtilityDependsMap UtilityDepends; - std::string AdditionalPlatformDefinition; private: virtual std::string GetVSMakeProgram() = 0; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index a6c6e8d..e0fe0fd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -48,7 +48,6 @@ extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[]; cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(VSVersion v): cmLocalVisualStudioGenerator(v) { - this->PlatformName = "Win32"; this->ExtraFlagTable = 0; this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } @@ -647,8 +646,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { mfcFlag = "0"; } + cmGlobalVisualStudio7Generator* gg = + static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator); fout << "\t\t<Configuration\n" - << "\t\t\tName=\"" << configName << "|" << this->PlatformName << "\"\n" + << "\t\t\tName=\"" << configName + << "|" << gg->GetPlatformName() << "\"\n" << "\t\t\tOutputDirectory=\"" << configName << "\"\n"; // This is an internal type to Visual Studio, it seems that: // 4 == static library @@ -896,11 +898,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } fout << "\"\n"; fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n"; - if( this->PlatformName == "x64" ) + if( gg->GetPlatformName() == "x64" ) { fout << "\t\t\t\tTargetEnvironment=\"3\"\n"; } - else if( this->PlatformName == "ia64" ) + else if( gg->GetPlatformName() == "ia64" ) { fout << "\t\t\t\tTargetEnvironment=\"2\"\n"; } @@ -1640,6 +1642,8 @@ bool cmLocalVisualStudio7Generator std::ostream &fout, const std::string& libName, std::vector<std::string> *configs) { + cmGlobalVisualStudio7Generator* gg = + static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); const std::vector<const cmSourceFile *> &sourceFiles = sg->GetSourceFiles(); std::vector<cmSourceGroup> const& children = sg->GetGroupChildren(); @@ -1730,7 +1734,7 @@ bool cmLocalVisualStudio7Generator cmLVS7GFileConfig const& fc = fci->second; fout << "\t\t\t\t<FileConfiguration\n" << "\t\t\t\t\tName=\"" << fci->first - << "|" << this->PlatformName << "\""; + << "|" << gg->GetPlatformName() << "\""; if(fc.ExcludedFromBuild) { fout << " ExcludedFromBuild=\"true\""; @@ -1800,6 +1804,9 @@ WriteCustomRule(std::ostream& fout, const cmCustomCommand& command, FCInfo& fcinfo) { + cmGlobalVisualStudio7Generator* gg = + static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); + // Write the rule for each configuration. std::vector<std::string>::iterator i; std::vector<std::string> *configs = @@ -1820,7 +1827,8 @@ WriteCustomRule(std::ostream& fout, cmCustomCommandGenerator ccg(command, *i, this->Makefile); cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; fout << "\t\t\t\t<FileConfiguration\n"; - fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n"; + fout << "\t\t\t\t\tName=\"" << *i << "|" + << gg->GetPlatformName() << "\">\n"; if(!fc.CompileFlags.empty()) { fout << "\t\t\t\t\t<Tool\n" @@ -2030,7 +2038,7 @@ cmLocalVisualStudio7Generator fout<< "\tKeyword=\"" << keyword << "\">\n" << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n" << "\t<Platforms>\n" - << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n" + << "\t\t<Platform\n\t\t\tName=\"" << gg->GetPlatformName() << "\"/>\n" << "\t</Platforms>\n"; } @@ -2085,7 +2093,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, } fout << "\tKeyword=\"" << keyword << "\">\n" << "\t<Platforms>\n" - << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n" + << "\t\t<Platform\n\t\t\tName=\"" << gg->GetPlatformName() << "\"/>\n" << "\t</Platforms>\n"; } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 6c04559..c2caa26 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -53,8 +53,6 @@ public: */ void SetBuildType(BuildType,const std::string& name); - void SetPlatformName(const std::string& n) { this->PlatformName = n;} - void SetExtraFlagTable(cmVS7FlagTable const* table) { this->ExtraFlagTable = table; } virtual std::string GetTargetDirectory(cmTarget const&) const; @@ -124,7 +122,6 @@ private: std::string ModuleDefinitionFile; bool FortranProject; bool WindowsCEProject; - std::string PlatformName; // Win32 or x64 cmLocalVisualStudio7GeneratorInternals* Internal; }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 29029eb..07f08de 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -25,6 +25,12 @@ #include <stdlib.h> // required for atof #include <assert.h> #include <errno.h> +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include <cmsys/hash_set.hxx> +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif const char* cmTarget::GetTargetTypeName(TargetType targetType) { @@ -190,10 +196,11 @@ public: public: TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, cmLinkImplItem const& item = NoLinkImplItem) - : ge(cge), LinkImplItem(item) + : ge(cge), Cached(false), LinkImplItem(item) {} const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; std::vector<std::string> CachedEntries; + bool Cached; cmLinkImplItem const& LinkImplItem; }; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; @@ -228,7 +235,7 @@ public: cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; //---------------------------------------------------------------------------- -void deleteAndClear( +static void deleteAndClear( std::vector<cmTargetInternals::TargetPropertyEntry*> &entries) { for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator @@ -242,7 +249,7 @@ void deleteAndClear( } //---------------------------------------------------------------------------- -void deleteAndClear( +static void deleteAndClear( std::map<std::string, std::vector<cmTargetInternals::TargetPropertyEntry*> > &entries) { @@ -339,7 +346,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->IsApple = this->Makefile->IsOn("APPLE"); // Setup default property values. - if (this->GetType() != INTERFACE_LIBRARY) + if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) { this->SetPropertyDefault("INSTALL_NAME_DIR", 0); this->SetPropertyDefault("INSTALL_RPATH", ""); @@ -380,41 +387,44 @@ void cmTarget::SetMakefile(cmMakefile* mf) mf->GetConfigurations(configNames); // Setup per-configuration property default values. - const char* configProps[] = { - "ARCHIVE_OUTPUT_DIRECTORY_", - "LIBRARY_OUTPUT_DIRECTORY_", - "RUNTIME_OUTPUT_DIRECTORY_", - "PDB_OUTPUT_DIRECTORY_", - "COMPILE_PDB_OUTPUT_DIRECTORY_", - "MAP_IMPORTED_CONFIG_", - 0}; - for(std::vector<std::string>::iterator ci = configNames.begin(); - ci != configNames.end(); ++ci) - { - std::string configUpper = cmSystemTools::UpperCase(*ci); - for(const char** p = configProps; *p; ++p) - { - if (this->TargetTypeValue == INTERFACE_LIBRARY - && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) + if (this->GetType() != UTILITY) + { + const char* configProps[] = { + "ARCHIVE_OUTPUT_DIRECTORY_", + "LIBRARY_OUTPUT_DIRECTORY_", + "RUNTIME_OUTPUT_DIRECTORY_", + "PDB_OUTPUT_DIRECTORY_", + "COMPILE_PDB_OUTPUT_DIRECTORY_", + "MAP_IMPORTED_CONFIG_", + 0}; + for(std::vector<std::string>::iterator ci = configNames.begin(); + ci != configNames.end(); ++ci) + { + std::string configUpper = cmSystemTools::UpperCase(*ci); + for(const char** p = configProps; *p; ++p) { - continue; + if (this->TargetTypeValue == INTERFACE_LIBRARY + && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) + { + continue; + } + std::string property = *p; + property += configUpper; + this->SetPropertyDefault(property, 0); } - std::string property = *p; - property += configUpper; - this->SetPropertyDefault(property, 0); - } - // Initialize per-configuration name postfix property from the - // variable only for non-executable targets. This preserves - // compatibility with previous CMake versions in which executables - // did not support this variable. Projects may still specify the - // property directly. - if(this->TargetTypeValue != cmTarget::EXECUTABLE - && this->TargetTypeValue != cmTarget::INTERFACE_LIBRARY) - { - std::string property = cmSystemTools::UpperCase(*ci); - property += "_POSTFIX"; - this->SetPropertyDefault(property, 0); + // Initialize per-configuration name postfix property from the + // variable only for non-executable targets. This preserves + // compatibility with previous CMake versions in which executables + // did not support this variable. Projects may still specify the + // property directly. + if(this->TargetTypeValue != cmTarget::EXECUTABLE + && this->TargetTypeValue != cmTarget::INTERFACE_LIBRARY) + { + std::string property = cmSystemTools::UpperCase(*ci); + property += "_POSTFIX"; + this->SetPropertyDefault(property, 0); + } } } @@ -453,7 +463,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } - if (this->GetType() != INTERFACE_LIBRARY) + if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) { this->SetPropertyDefault("C_VISIBILITY_PRESET", 0); this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0); @@ -465,7 +475,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } - if (this->GetType() != INTERFACE_LIBRARY) + if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) { this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); } @@ -487,8 +497,11 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->PolicyStatusCMP0022 = cmPolicies::NEW; } - this->SetPropertyDefault("JOB_POOL_COMPILE", 0); - this->SetPropertyDefault("JOB_POOL_LINK", 0); + if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) + { + this->SetPropertyDefault("JOB_POOL_COMPILE", 0); + this->SetPropertyDefault("JOB_POOL_LINK", 0); + } } //---------------------------------------------------------------------------- @@ -646,7 +659,7 @@ bool cmTarget::IsBundleOnApple() const static bool processSources(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &srcs, - std::set<std::string> &uniqueSrcs, + UNORDERED_SET<std::string> &uniqueSrcs, cmGeneratorExpressionDAGChecker *dagChecker, std::string const& config, bool debugSources) { @@ -788,7 +801,7 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files, cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES", 0, 0); - std::set<std::string> uniqueSrcs; + UNORDERED_SET<std::string> uniqueSrcs; bool contextDependentDirectSources = processSources(this, this->Internal->SourceEntries, files, @@ -1302,7 +1315,7 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, = (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; - std::set<std::string> emitted; + UNORDERED_SET<std::string> emitted; for(std::vector<cmListFileBacktrace>::iterator it = sigs.begin(); it != sigs.end(); ++it) { @@ -1721,22 +1734,20 @@ static bool whiteListedInterfaceProperty(const std::string& prop) { return true; } - static const char* builtIns[] = { - // ###: This must remain sorted. It is processed with a binary search. - "COMPATIBLE_INTERFACE_BOOL", - "COMPATIBLE_INTERFACE_NUMBER_MAX", - "COMPATIBLE_INTERFACE_NUMBER_MIN", - "COMPATIBLE_INTERFACE_STRING", - "EXPORT_NAME", - "IMPORTED", - "NAME", - "TYPE" - }; + static UNORDERED_SET<std::string> builtIns; + if (builtIns.empty()) + { + builtIns.insert("COMPATIBLE_INTERFACE_BOOL"); + builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX"); + builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MIN"); + builtIns.insert("COMPATIBLE_INTERFACE_STRING"); + builtIns.insert("EXPORT_NAME"); + builtIns.insert("IMPORTED"); + builtIns.insert("NAME"); + builtIns.insert("TYPE"); + } - if (std::binary_search(cmArrayBegin(builtIns), - cmArrayEnd(builtIns), - prop.c_str(), - cmStrCmp(prop))) + if (builtIns.count(prop)) { return true; } @@ -1761,15 +1772,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - - if (prop == "NAME") + else if (prop == "NAME") { cmOStringStream e; e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if(prop == "INCLUDE_DIRECTORIES") + else if(prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); @@ -1777,9 +1787,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->IncludeDirectoriesEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); - return; } - if(prop == "COMPILE_OPTIONS") + else if(prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); @@ -1787,9 +1796,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->CompileOptionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); - return; } - if(prop == "COMPILE_FEATURES") + else if(prop == "COMPILE_FEATURES") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); @@ -1797,9 +1805,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->CompileFeaturesEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); - return; } - if(prop == "COMPILE_DEFINITIONS") + else if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); @@ -1807,25 +1814,22 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->CompileDefinitionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); - return; } - if(prop == "EXPORT_NAME" && this->IsImported()) + else if(prop == "EXPORT_NAME" && this->IsImported()) { cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; } - if (prop == "LINK_LIBRARIES") + else if (prop == "LINK_LIBRARIES") { this->Internal->LinkImplementationPropertyEntries.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmValueWithOrigin entry(value, lfbt); this->Internal->LinkImplementationPropertyEntries.push_back(entry); - return; } - if (prop == "SOURCES") + else if (prop == "SOURCES") { if(this->IsImported()) { @@ -1842,10 +1846,12 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->SourceEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); - return; } - this->Properties.SetProperty(prop, value, cmProperty::TARGET); - this->MaybeInvalidatePropertyCache(prop); + else + { + this->Properties.SetProperty(prop, value, cmProperty::TARGET); + this->MaybeInvalidatePropertyCache(prop); + } } //---------------------------------------------------------------------------- @@ -1861,61 +1867,55 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if (prop == "NAME") + else if (prop == "NAME") { cmOStringStream e; e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if(prop == "INCLUDE_DIRECTORIES") + else if(prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); this->Internal->IncludeDirectoriesEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); - return; } - if(prop == "COMPILE_OPTIONS") + else if(prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); this->Internal->CompileOptionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); - return; } - if(prop == "COMPILE_FEATURES") + else if(prop == "COMPILE_FEATURES") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); this->Internal->CompileFeaturesEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); - return; } - if(prop == "COMPILE_DEFINITIONS") + else if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(&lfbt); this->Internal->CompileDefinitionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); - return; } - if(prop == "EXPORT_NAME" && this->IsImported()) + else if(prop == "EXPORT_NAME" && this->IsImported()) { cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; } - if (prop == "LINK_LIBRARIES") + else if (prop == "LINK_LIBRARIES") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmValueWithOrigin entry(value, lfbt); this->Internal->LinkImplementationPropertyEntries.push_back(entry); - return; } - if (prop == "SOURCES") + else if (prop == "SOURCES") { if(this->IsImported()) { @@ -1931,10 +1931,12 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); this->Internal->SourceEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); - return; } - this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); - this->MaybeInvalidatePropertyCache(prop); + else + { + this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); + this->MaybeInvalidatePropertyCache(prop); + } } //---------------------------------------------------------------------------- @@ -2030,7 +2032,7 @@ void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry) static void processIncludeDirectories(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &includes, - std::set<std::string> &uniqueIncludes, + UNORDERED_SET<std::string> &uniqueIncludes, cmGeneratorExpressionDAGChecker *dagChecker, const std::string& config, bool debugIncludes) { @@ -2179,7 +2181,7 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const std::string& config) const { std::vector<std::string> includes; - std::set<std::string> uniqueIncludes; + UNORDERED_SET<std::string> uniqueIncludes; cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "INCLUDE_DIRECTORIES", 0, 0); @@ -2271,7 +2273,7 @@ cmTarget::GetIncludeDirectories(const std::string& config) const static void processCompileOptionsInternal(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, - std::set<std::string> &uniqueOptions, + UNORDERED_SET<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, const std::string& config, bool debugOptions, const char *logName) { @@ -2280,27 +2282,35 @@ static void processCompileOptionsInternal(cmTarget const* tgt, for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { - bool cacheOptions = false; - std::vector<std::string> entryOptions = (*it)->CachedEntries; - if(entryOptions.empty()) + std::vector<std::string>& entriesRef = (*it)->CachedEntries; + std::vector<std::string> localEntries; + std::vector<std::string>* entryOptions = &entriesRef; + if(!(*it)->Cached) { cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, config, false, tgt, dagChecker), - entryOptions); + localEntries); if (mf->IsGeneratingBuildSystem() && !(*it)->ge->GetHadContextSensitiveCondition()) { - cacheOptions = true; + // Cache the result. + *entryOptions = localEntries; + (*it)->Cached = true; + } + else + { + // Use the context-sensitive results here. + entryOptions = &localEntries; } } std::string usedOptions; for(std::vector<std::string>::iterator - li = entryOptions.begin(); li != entryOptions.end(); ++li) + li = entryOptions->begin(); li != entryOptions->end(); ++li) { - std::string opt = *li; + std::string const& opt = *li; if(uniqueOptions.insert(opt).second) { @@ -2311,10 +2321,6 @@ static void processCompileOptionsInternal(cmTarget const* tgt, } } } - if (cacheOptions) - { - (*it)->CachedEntries = entryOptions; - } if (!usedOptions.empty()) { mf->GetCMakeInstance()->IssueMessage(cmake::LOG, @@ -2330,7 +2336,7 @@ static void processCompileOptionsInternal(cmTarget const* tgt, static void processCompileOptions(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, - std::set<std::string> &uniqueOptions, + UNORDERED_SET<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, const std::string& config, bool debugOptions) { @@ -2367,7 +2373,7 @@ void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, void cmTarget::GetCompileOptions(std::vector<std::string> &result, const std::string& config) const { - std::set<std::string> uniqueOptions; + UNORDERED_SET<std::string> uniqueOptions; cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "COMPILE_OPTIONS", 0, 0); @@ -2428,7 +2434,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, static void processCompileDefinitions(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, - std::set<std::string> &uniqueOptions, + UNORDERED_SET<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, const std::string& config, bool debugOptions) { @@ -2441,7 +2447,7 @@ static void processCompileDefinitions(cmTarget const* tgt, void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, const std::string& config) const { - std::set<std::string> uniqueOptions; + UNORDERED_SET<std::string> uniqueOptions; cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "COMPILE_DEFINITIONS", 0, 0); @@ -2539,7 +2545,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, static void processCompileFeatures(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, - std::set<std::string> &uniqueOptions, + UNORDERED_SET<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, const std::string& config, bool debugOptions) { @@ -2551,7 +2557,7 @@ static void processCompileFeatures(cmTarget const* tgt, void cmTarget::GetCompileFeatures(std::vector<std::string> &result, const std::string& config) const { - std::set<std::string> uniqueFeatures; + UNORDERED_SET<std::string> uniqueFeatures; cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "COMPILE_FEATURES", @@ -3014,6 +3020,22 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const } //---------------------------------------------------------------------------- +static void MakePropertyList(std::string& output, + std::vector<cmTargetInternals::TargetPropertyEntry*> const& values) +{ + output = ""; + std::string sep; + for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator + it = values.begin(), end = values.end(); + it != end; ++it) + { + output += sep; + output += (*it)->ge->GetInput(); + sep = ";"; + } +} + +//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const std::string& prop) const { return this->GetProperty(prop, this->Makefile); @@ -3033,11 +3055,6 @@ const char *cmTarget::GetProperty(const std::string& prop, return 0; } - if (prop == "NAME") - { - return this->GetName().c_str(); - } - // Watch for special "computed" properties that are dependent on // other properties or variables. Always recompute them. if(this->GetType() == cmTarget::EXECUTABLE || @@ -3046,7 +3063,8 @@ const char *cmTarget::GetProperty(const std::string& prop, this->GetType() == cmTarget::MODULE_LIBRARY || this->GetType() == cmTarget::UNKNOWN_LIBRARY) { - if(prop == "LOCATION") + static const std::string propLOCATION = "LOCATION"; + if(prop == propLOCATION) { if (!this->HandleLocationPropertyPolicy(context)) { @@ -3062,12 +3080,12 @@ const char *cmTarget::GetProperty(const std::string& prop, // cannot take into account the per-configuration name of the // target because the configuration type may not be known at // CMake time. - this->Properties.SetProperty("LOCATION", this->GetLocationForBuild(), + this->Properties.SetProperty(propLOCATION, this->GetLocationForBuild(), cmProperty::TARGET); } // Support "LOCATION_<CONFIG>". - if(cmHasLiteralPrefix(prop, "LOCATION_")) + else if(cmHasLiteralPrefix(prop, "LOCATION_")) { if (!this->HandleLocationPropertyPolicy(context)) { @@ -3079,7 +3097,7 @@ const char *cmTarget::GetProperty(const std::string& prop, cmProperty::TARGET); } // Support "<CONFIG>_LOCATION". - if(cmHasLiteralSuffix(prop, "_LOCATION")) + else if(cmHasLiteralSuffix(prop, "_LOCATION")) { std::string configName(prop.c_str(), prop.size() - 9); if(configName != "IMPORTED") @@ -3094,228 +3112,210 @@ const char *cmTarget::GetProperty(const std::string& prop, } } } - if(prop == "INCLUDE_DIRECTORIES") - { - if (this->Internal->IncludeDirectoriesEntries.empty()) - { - return 0; - } + static UNORDERED_SET<std::string> specialProps; +#define MAKE_STATIC_PROP(PROP) \ + static const std::string prop##PROP = #PROP + MAKE_STATIC_PROP(LINK_LIBRARIES); + MAKE_STATIC_PROP(TYPE); + MAKE_STATIC_PROP(INCLUDE_DIRECTORIES); + MAKE_STATIC_PROP(COMPILE_FEATURES); + MAKE_STATIC_PROP(COMPILE_OPTIONS); + MAKE_STATIC_PROP(COMPILE_DEFINITIONS); + MAKE_STATIC_PROP(IMPORTED); + MAKE_STATIC_PROP(NAME); + MAKE_STATIC_PROP(SOURCES); +#undef MAKE_STATIC_PROP + if(specialProps.empty()) + { + specialProps.insert(propLINK_LIBRARIES); + specialProps.insert(propTYPE); + specialProps.insert(propINCLUDE_DIRECTORIES); + specialProps.insert(propCOMPILE_FEATURES); + specialProps.insert(propCOMPILE_OPTIONS); + specialProps.insert(propCOMPILE_DEFINITIONS); + specialProps.insert(propIMPORTED); + specialProps.insert(propNAME); + specialProps.insert(propSOURCES); + } + if(specialProps.count(prop)) + { + if(prop == propLINK_LIBRARIES) + { + if (this->Internal->LinkImplementationPropertyEntries.empty()) + { + return 0; + } - static std::string output; - output = ""; - std::string sep; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for (std::vector<TargetPropertyEntry*>::const_iterator - it = this->Internal->IncludeDirectoriesEntries.begin(), - end = this->Internal->IncludeDirectoriesEntries.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; + static std::string output; + output = ""; + std::string sep; + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); + it != end; ++it) + { + output += sep; + output += it->Value; + sep = ";"; + } + return output.c_str(); } - return output.c_str(); - } - if(prop == "COMPILE_OPTIONS") - { - if (this->Internal->CompileOptionsEntries.empty()) + // the type property returns what type the target is + else if (prop == propTYPE) { - return 0; + return cmTarget::GetTargetTypeName(this->GetType()); } - - static std::string output; - output = ""; - std::string sep; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for (std::vector<TargetPropertyEntry*>::const_iterator - it = this->Internal->CompileOptionsEntries.begin(), - end = this->Internal->CompileOptionsEntries.end(); - it != end; ++it) + else if(prop == propINCLUDE_DIRECTORIES) { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; + if (this->Internal->IncludeDirectoriesEntries.empty()) + { + return 0; + } + + static std::string output; + MakePropertyList(output, this->Internal->IncludeDirectoriesEntries); + return output.c_str(); } - return output.c_str(); - } - if(prop == "COMPILE_FEATURES") - { - if (this->Internal->CompileFeaturesEntries.empty()) + else if(prop == propCOMPILE_FEATURES) { - return 0; - } + if (this->Internal->CompileFeaturesEntries.empty()) + { + return 0; + } - static std::string output; - output = ""; - std::string sep; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for (std::vector<TargetPropertyEntry*>::const_iterator - it = this->Internal->CompileFeaturesEntries.begin(), - end = this->Internal->CompileFeaturesEntries.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; + static std::string output; + MakePropertyList(output, this->Internal->CompileFeaturesEntries); + return output.c_str(); } - return output.c_str(); - } - if(prop == "COMPILE_DEFINITIONS") - { - if (this->Internal->CompileDefinitionsEntries.empty()) + else if(prop == propCOMPILE_OPTIONS) { - return 0; - } + if (this->Internal->CompileOptionsEntries.empty()) + { + return 0; + } - static std::string output; - output = ""; - std::string sep; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for (std::vector<TargetPropertyEntry*>::const_iterator - it = this->Internal->CompileDefinitionsEntries.begin(), - end = this->Internal->CompileDefinitionsEntries.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; + static std::string output; + MakePropertyList(output, this->Internal->CompileOptionsEntries); + return output.c_str(); } - return output.c_str(); - } - if(prop == "LINK_LIBRARIES") - { - if (this->Internal->LinkImplementationPropertyEntries.empty()) + else if(prop == propCOMPILE_DEFINITIONS) { - return 0; - } + if (this->Internal->CompileDefinitionsEntries.empty()) + { + return 0; + } - static std::string output; - output = ""; - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->Internal->LinkImplementationPropertyEntries.begin(), - end = this->Internal->LinkImplementationPropertyEntries.end(); - it != end; ++it) + static std::string output; + MakePropertyList(output, this->Internal->CompileDefinitionsEntries); + return output.c_str(); + } + else if (prop == propIMPORTED) { - output += sep; - output += it->Value; - sep = ";"; + return this->IsImported()?"TRUE":"FALSE"; } - return output.c_str(); - } - - if (prop == "IMPORTED") - { - return this->IsImported()?"TRUE":"FALSE"; - } - - if(prop == "SOURCES") - { - if (this->Internal->SourceEntries.empty()) + else if (prop == propNAME) { - return 0; + return this->GetName().c_str(); } - - cmOStringStream ss; - const char* sep = ""; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector<TargetPropertyEntry*>::const_iterator - i = this->Internal->SourceEntries.begin(); - i != this->Internal->SourceEntries.end(); ++i) + else if(prop == propSOURCES) { - std::string entry = (*i)->ge->GetInput(); + if (this->Internal->SourceEntries.empty()) + { + return 0; + } - std::vector<std::string> files; - cmSystemTools::ExpandListArgument(entry, files); - for (std::vector<std::string>::const_iterator - li = files.begin(); li != files.end(); ++li) + cmOStringStream ss; + const char* sep = ""; + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for(std::vector<TargetPropertyEntry*>::const_iterator + i = this->Internal->SourceEntries.begin(); + i != this->Internal->SourceEntries.end(); ++i) { - if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && - (*li)[li->size() - 1] == '>') - { - std::string objLibName = li->substr(17, li->size()-18); + std::string entry = (*i)->ge->GetInput(); - if (cmGeneratorExpression::Find(objLibName) != std::string::npos) + std::vector<std::string> files; + cmSystemTools::ExpandListArgument(entry, files); + for (std::vector<std::string>::const_iterator + li = files.begin(); li != files.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && + (*li)[li->size() - 1] == '>') { - ss << sep; - sep = ";"; - ss << *li; - continue; - } + std::string objLibName = li->substr(17, li->size()-18); - bool addContent = false; - bool noMessage = true; - cmOStringStream e; - cmake::MessageType messageType = cmake::AUTHOR_WARNING; - switch(context->GetPolicyStatus(cmPolicies::CMP0051)) - { - case cmPolicies::WARN: - e << (this->Makefile->GetPolicies() - ->GetPolicyWarning(cmPolicies::CMP0051)) << "\n"; - noMessage = false; - case cmPolicies::OLD: - break; - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::NEW: - addContent = true; - } - if (!noMessage) - { - e << "Target \"" << this->Name << "\" contains $<TARGET_OBJECTS> " - "generator expression in its sources list. This content was not " - "previously part of the SOURCES property when that property was " - "read at configure time. Code reading that property needs to be " - "adapted to ignore the generator expression using the " - "string(GENEX_STRIP) command."; - context->IssueMessage(messageType, e.str()); + if (cmGeneratorExpression::Find(objLibName) != std::string::npos) + { + ss << sep; + sep = ";"; + ss << *li; + continue; + } + + bool addContent = false; + bool noMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(context->GetPolicyStatus(cmPolicies::CMP0051)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0051)) << "\n"; + noMessage = false; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + addContent = true; + } + if (!noMessage) + { + e << "Target \"" << this->Name << "\" contains " + "$<TARGET_OBJECTS> generator expression in its sources list. " + "This content was not previously part of the SOURCES property " + "when that property was read at configure time. Code reading " + "that property needs to be adapted to ignore the generator " + "expression using the string(GENEX_STRIP) command."; + context->IssueMessage(messageType, e.str()); + } + if (addContent) + { + ss << sep; + sep = ";"; + ss << *li; + } } - if (addContent) + else if (cmGeneratorExpression::Find(*li) == std::string::npos) { ss << sep; sep = ";"; ss << *li; } - } - else if (cmGeneratorExpression::Find(*li) == std::string::npos) - { - ss << sep; - sep = ";"; - ss << *li; - } - else - { - cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li); - // Construct what is known about this source file location. - cmSourceFileLocation const& location = sf->GetLocation(); - std::string sname = location.GetDirectory(); - if(!sname.empty()) + else { - sname += "/"; - } - sname += location.GetName(); + cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li); + // Construct what is known about this source file location. + cmSourceFileLocation const& location = sf->GetLocation(); + std::string sname = location.GetDirectory(); + if(!sname.empty()) + { + sname += "/"; + } + sname += location.GetName(); - ss << sep; - sep = ";"; - // Append this list entry. - ss << sname; + ss << sep; + sep = ";"; + // Append this list entry. + ss << sname; + } } } + this->Properties.SetProperty("SOURCES", ss.str().c_str(), + cmProperty::TARGET); } - this->Properties.SetProperty("SOURCES", ss.str().c_str(), - cmProperty::TARGET); } - // the type property returns what type the target is - if (prop == "TYPE") - { - return cmTarget::GetTargetTypeName(this->GetType()); - } bool chain = false; const char *retVal = this->Properties.GetPropertyValue(prop, cmProperty::TARGET, chain); @@ -3338,7 +3338,7 @@ class cmTargetCollectLinkLanguages public: cmTargetCollectLinkLanguages(cmTarget const* target, const std::string& config, - std::set<std::string>& languages, + UNORDERED_SET<std::string>& languages, cmTarget const* head): Config(config), Languages(languages), HeadTarget(head), Makefile(target->GetMakefile()), Target(target) @@ -3408,7 +3408,7 @@ public: } private: std::string Config; - std::set<std::string>& Languages; + UNORDERED_SET<std::string>& Languages; cmTarget const* HeadTarget; cmMakefile* Makefile; const cmTarget* Target; @@ -3445,7 +3445,7 @@ class cmTargetSelectLinker cmTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GG; - std::set<std::string> Preferred; + UNORDERED_SET<std::string> Preferred; public: cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) { @@ -3477,7 +3477,7 @@ public: e << "Target " << this->Target->GetName() << " contains multiple languages with the highest linker preference" << " (" << this->Preference << "):\n"; - for(std::set<std::string>::const_iterator + for(UNORDERED_SET<std::string>::const_iterator li = this->Preferred.begin(); li != this->Preferred.end(); ++li) { e << " " << *li << "\n"; @@ -3496,7 +3496,7 @@ void cmTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc) const { // Get languages built in this target. - std::set<std::string> languages; + UNORDERED_SET<std::string> languages; LinkImplementation const* impl = this->GetLinkImplementation(config); for(std::vector<std::string>::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -3514,7 +3514,7 @@ void cmTarget::ComputeLinkClosure(const std::string& config, } // Store the transitive closure of languages. - for(std::set<std::string>::const_iterator li = languages.begin(); + for(UNORDERED_SET<std::string>::const_iterator li = languages.begin(); li != languages.end(); ++li) { lc.Languages.push_back(*li); @@ -3542,7 +3542,7 @@ void cmTarget::ComputeLinkClosure(const std::string& config, } // Now consider languages that propagate from linked targets. - for(std::set<std::string>::const_iterator sit = languages.begin(); + for(UNORDERED_SET<std::string>::const_iterator sit = languages.begin(); sit != languages.end(); ++sit) { std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; @@ -4836,12 +4836,13 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- template<typename PropertyType> -PropertyType getTypedProperty(cmTarget const* tgt, const char *prop, +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop, PropertyType *); //---------------------------------------------------------------------------- template<> -bool getTypedProperty<bool>(cmTarget const* tgt, const char *prop, bool *) +bool getTypedProperty<bool>(cmTarget const* tgt, const std::string& prop, + bool *) { return tgt->GetPropertyAsBool(prop); } @@ -4849,7 +4850,7 @@ bool getTypedProperty<bool>(cmTarget const* tgt, const char *prop, bool *) //---------------------------------------------------------------------------- template<> const char *getTypedProperty<const char *>(cmTarget const* tgt, - const char *prop, + const std::string& prop, const char **) { return tgt->GetProperty(prop); @@ -5088,7 +5089,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(), + PropertyType propContent = getTypedProperty<PropertyType>(tgt, p, 0); const bool explicitlySet = tgt->GetProperties() .find(p) @@ -5124,6 +5125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, report += "\" property not set.\n"; } + std::string interfaceProperty = "INTERFACE_" + p; for(std::vector<cmTarget const*>::const_iterator li = deps.begin(); li != deps.end(); ++li) @@ -5137,11 +5139,11 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, cmTarget const* theTarget = *li; const bool ifaceIsSet = theTarget->GetProperties() - .find("INTERFACE_" + p) + .find(interfaceProperty) != theTarget->GetProperties().end(); PropertyType ifacePropContent = getTypedProperty<PropertyType>(theTarget, - ("INTERFACE_" + p).c_str(), 0); + interfaceProperty, 0); std::string reportEntry; if (ifaceIsSet) @@ -6169,7 +6171,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. std::vector<cmLinkItem> ifaceLibs; - std::string newProp = "INTERFACE_LINK_LIBRARIES"; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) { thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, @@ -6237,7 +6239,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. - std::set<std::string> emitted; + UNORDERED_SET<std::string> emitted; for(std::vector<cmLinkItem>::const_iterator li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) { @@ -6755,9 +6757,13 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); std::set<std::string> emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; std::set<std::string> emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; std::set<std::string> emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; std::set<std::string> emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; for(cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin(); @@ -6769,14 +6775,14 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } checkPropertyConsistency<bool>(this, li->Target, - std::string("COMPATIBLE_INTERFACE_BOOL"), + strBool, emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char *>(this, li->Target, - std::string("COMPATIBLE_INTERFACE_STRING"), + strString, emittedStrings, config, StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) @@ -6784,7 +6790,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, return; } checkPropertyConsistency<const char *>(this, li->Target, - std::string("COMPATIBLE_INTERFACE_NUMBER_MIN"), + strNumMin, emittedMinNumbers, config, NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) @@ -6792,7 +6798,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, return; } checkPropertyConsistency<const char *>(this, li->Target, - std::string("COMPATIBLE_INTERFACE_NUMBER_MAX"), + strNumMax, emittedMaxNumbers, config, NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) @@ -6808,26 +6814,27 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, if (!prop.empty()) { + // Use a std::set to keep the error message sorted. std::set<std::string> props; std::set<std::string>::const_iterator i = emittedBools.find(prop); if (i != emittedBools.end()) { - props.insert("COMPATIBLE_INTERFACE_BOOL"); + props.insert(strBool); } i = emittedStrings.find(prop); if (i != emittedStrings.end()) { - props.insert("COMPATIBLE_INTERFACE_STRING"); + props.insert(strString); } i = emittedMinNumbers.find(prop); if (i != emittedMinNumbers.end()) { - props.insert("COMPATIBLE_INTERFACE_NUMBER_MIN"); + props.insert(strNumMin); } i = emittedMaxNumbers.find(prop); if (i != emittedMaxNumbers.end()) { - props.insert("COMPATIBLE_INTERFACE_NUMBER_MAX"); + props.insert(strNumMax); } std::string propsString = *props.begin(); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 486315e..b4c8a0f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -18,6 +18,9 @@ #include "cmListFileCache.h" #include <cmsys/auto_ptr.hxx> +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include <cmsys/hash_map.hxx> +#endif #define CM_FOR_EACH_TARGET_POLICY(F) \ F(CMP0003) \ @@ -844,7 +847,11 @@ private: mutable bool LinkImplementationLanguageIsContextDependent; }; +#ifdef CMAKE_BUILD_WITH_CMAKE +typedef cmsys::hash_map<std::string,cmTarget> cmTargets; +#else typedef std::map<std::string,cmTarget> cmTargets; +#endif class cmTargetSet: public std::set<std::string> {}; class cmTargetManifest: public std::map<std::string, cmTargetSet> {}; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 0458bd6..15439f6 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -41,58 +41,74 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const { - cmLocalVisualStudioGenerator::VSVersion - v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) - { return cmVS14CLFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) - { return cmVS12CLFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) - { return cmVS11CLFlagTable; } - else - { return cmVS10CLFlagTable; } + if(this->MSTools) + { + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS14) + { return cmVS14CLFlagTable; } + else if(v >= cmLocalVisualStudioGenerator::VS12) + { return cmVS12CLFlagTable; } + else if(v == cmLocalVisualStudioGenerator::VS11) + { return cmVS11CLFlagTable; } + else + { return cmVS10CLFlagTable; } + } + return 0; } cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetRcFlagTable() const { - cmLocalVisualStudioGenerator::VSVersion - v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) - { return cmVS14RCFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) - { return cmVS12RCFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) - { return cmVS11RCFlagTable; } - else - { return cmVS10RCFlagTable; } + if(this->MSTools) + { + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS14) + { return cmVS14RCFlagTable; } + else if(v >= cmLocalVisualStudioGenerator::VS12) + { return cmVS12RCFlagTable; } + else if(v == cmLocalVisualStudioGenerator::VS11) + { return cmVS11RCFlagTable; } + else + { return cmVS10RCFlagTable; } + } + return 0; } cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const { - cmLocalVisualStudioGenerator::VSVersion - v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) - { return cmVS14LibFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) - { return cmVS12LibFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) - { return cmVS11LibFlagTable; } - else - { return cmVS10LibFlagTable; } + if(this->MSTools) + { + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS14) + { return cmVS14LibFlagTable; } + else if(v >= cmLocalVisualStudioGenerator::VS12) + { return cmVS12LibFlagTable; } + else if(v == cmLocalVisualStudioGenerator::VS11) + { return cmVS11LibFlagTable; } + else + { return cmVS10LibFlagTable; } + } + return 0; } cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const { - cmLocalVisualStudioGenerator::VSVersion - v = this->LocalGenerator->GetVersion(); - if(v >= cmLocalVisualStudioGenerator::VS14) - { return cmVS14LinkFlagTable; } - else if(v >= cmLocalVisualStudioGenerator::VS12) - { return cmVS12LinkFlagTable; } - else if(v == cmLocalVisualStudioGenerator::VS11) - { return cmVS11LinkFlagTable; } - else - { return cmVS10LinkFlagTable; } + if(this->MSTools) + { + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS14) + { return cmVS14LinkFlagTable; } + else if(v >= cmLocalVisualStudioGenerator::VS12) + { return cmVS12LinkFlagTable; } + else if(v == cmLocalVisualStudioGenerator::VS11) + { return cmVS11LinkFlagTable; } + else + { return cmVS10LinkFlagTable; } + } + return 0; } static std::string cmVS10EscapeXML(std::string arg) @@ -142,6 +158,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->GlobalGenerator->CreateGUID(this->Name.c_str()); this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str()); this->Platform = gg->GetPlatformName(); + this->MSTools = true; this->BuildFileStream = 0; } @@ -532,7 +549,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "</ConfigurationType>\n"; this->WriteString(configType.c_str(), 2); - this->WriteMSToolConfigurationValues(*i); + if(this->MSTools) + { + this->WriteMSToolConfigurationValues(*i); + } this->WriteString("</PropertyGroup>\n", 1); } @@ -1447,17 +1467,23 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( // Get preprocessor definitions for this directory. std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags(); - clOptions.FixExceptionHandlingDefault(); - clOptions.AddFlag("PrecompiledHeader", "NotUsing"); - std::string asmLocation = configName + "/"; - clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); + if(this->MSTools) + { + clOptions.FixExceptionHandlingDefault(); + clOptions.AddFlag("PrecompiledHeader", "NotUsing"); + std::string asmLocation = configName + "/"; + clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); + } clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); std::vector<std::string> targetDefines; this->Target->GetCompileDefinitions(targetDefines, configName.c_str()); clOptions.AddDefines(targetDefines); - clOptions.SetVerboseMakefile( - this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); + if(this->MSTools) + { + clOptions.SetVerboseMakefile( + this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); + } // Add a definition for the configuration name. std::string configDefine = "CMAKE_INTDIR=\""; @@ -1486,24 +1512,27 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "CXX"); - this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); - - // If not in debug mode, write the DebugInformationFormat field - // without value so PDBs don't get generated uselessly. - if(!clOptions.IsDebug()) + if(this->MSTools) { - this->WriteString("<DebugInformationFormat>" - "</DebugInformationFormat>\n", 3); - } + this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); - // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); - if(!pdb.empty()) - { - this->ConvertToWindowsSlash(pdb); - this->WriteString("<ProgramDataBaseFileName>", 3); - *this->BuildFileStream << cmVS10EscapeXML(pdb) - << "</ProgramDataBaseFileName>\n"; + // If not in debug mode, write the DebugInformationFormat field + // without value so PDBs don't get generated uselessly. + if(!clOptions.IsDebug()) + { + this->WriteString("<DebugInformationFormat>" + "</DebugInformationFormat>\n", 3); + } + + // Specify the compiler program database file if configured. + std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + if(!pdb.empty()) + { + this->ConvertToWindowsSlash(pdb); + this->WriteString("<ProgramDataBaseFileName>", 3); + *this->BuildFileStream << cmVS10EscapeXML(pdb) + << "</ProgramDataBaseFileName>\n"; + } } this->WriteString("</ClCompile>\n", 2); @@ -1567,6 +1596,10 @@ void cmVisualStudio10TargetGenerator:: WriteRCOptions(std::string const& configName, std::vector<std::string> const & includes) { + if(!this->MSTools) + { + return; + } this->WriteString("<ResourceCompile>\n", 2); // Preprocessor definitions and includes are shared with clOptions. @@ -1754,45 +1787,53 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) config.c_str()); } - linkOptions.AddFlag("Version", ""); - - if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) + if(this->MSTools) { - linkOptions.AddFlag("SubSystem", "Windows"); - } - else - { - linkOptions.AddFlag("SubSystem", "Console"); - } + linkOptions.AddFlag("Version", ""); - if(const char* stackVal = - this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE")) - { - linkOptions.AddFlag("StackReserveSize", stackVal); - } + if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) + { + linkOptions.AddFlag("SubSystem", "Windows"); + } + else + { + linkOptions.AddFlag("SubSystem", "Console"); + } - if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos) - { - linkOptions.AddFlag("GenerateDebugInformation", "true"); - } - else - { - linkOptions.AddFlag("GenerateDebugInformation", "false"); + if(const char* stackVal = + this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE")) + { + linkOptions.AddFlag("StackReserveSize", stackVal); + } + + if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos) + { + linkOptions.AddFlag("GenerateDebugInformation", "true"); + } + else + { + linkOptions.AddFlag("GenerateDebugInformation", "false"); + } + std::string pdb = this->Target->GetPDBDirectory(config.c_str()); + pdb += "/"; + pdb += targetNamePDB; + std::string imLib = this->Target->GetDirectory(config.c_str(), true); + imLib += "/"; + imLib += targetNameImport; + + linkOptions.AddFlag("ImportLibrary", imLib.c_str()); + linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); } - std::string pdb = this->Target->GetPDBDirectory(config.c_str()); - pdb += "/"; - pdb += targetNamePDB; - std::string imLib = this->Target->GetDirectory(config.c_str(), true); - imLib += "/"; - imLib += targetNameImport; - linkOptions.AddFlag("ImportLibrary", imLib.c_str()); - linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); linkOptions.Parse(flags.c_str()); - std::string def = this->GeneratorTarget->GetModuleDefinitionFile(""); - if(!def.empty()) + + if(this->MSTools) { - linkOptions.AddFlag("ModuleDefinitionFile", def.c_str()); + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(""); + if(!def.empty()) + { + linkOptions.AddFlag("ModuleDefinitionFile", def.c_str()); + } } this->LinkOptions[config] = pOptions.release(); @@ -1857,6 +1898,11 @@ void cmVisualStudio10TargetGenerator:: WriteMidlOptions(std::string const& /*config*/, std::vector<std::string> const & includes) { + if(!this->MSTools) + { + 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 // input filename) into output files at the per-config *build* dir diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 6bdb40a..6c92b57 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -120,6 +120,7 @@ private: std::string Platform; std::string GUID; std::string Name; + bool MSTools; cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; cmLocalVisualStudio7Generator* LocalGenerator; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index dc4f894..ca7fcdc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -77,7 +77,7 @@ if(BUILD_TESTING) # some old versions of make simply cannot handle spaces in paths if (MAKE_IS_GNU OR CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR - CMAKE_GENERATOR MATCHES "Visual Studio|XCode|Borland") + CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland") set(MAKE_SUPPORTS_SPACES 1) else() set(MAKE_SUPPORTS_SPACES 0) @@ -1502,7 +1502,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) endif() - if(MAKE_SUPPORTS_SPACES) + if(MAKE_SUPPORTS_SPACES AND NOT CMAKE_GENERATOR STREQUAL "Xcode") add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SubDirSpaces" diff --git a/Tests/CTestTestMemcheck/memtester.cxx.in b/Tests/CTestTestMemcheck/memtester.cxx.in index 55a34e3..43c0ba7 100644 --- a/Tests/CTestTestMemcheck/memtester.cxx.in +++ b/Tests/CTestTestMemcheck/memtester.cxx.in @@ -1,11 +1,19 @@ #include <cmSystemTools.h> +#include <cmsys/Encoding.hxx> #include <string> +#include <locale.h> #define RETVAL @_retval@ int -main(int argc, char **argv) +main(int ac, char **av) { + setlocale(LC_CTYPE, ""); + cmsys::Encoding::CommandLineArguments args = + cmsys::Encoding::CommandLineArguments::Main(ac, av); + int argc = args.argc(); + const char* const* argv = args.argv(); + std::string exename = argv[0]; std::string logarg; bool nextarg = false; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 06272ce..ff3b9a0 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -18,6 +18,7 @@ endif() if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 2) set(TargetSources_ARGS -DXCODE_BELOW_2=1) + set(File_Generate_ARGS -DXCODE_BELOW_2=1) endif() add_RunCMake_test(CMP0019) diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index f74d17e..dee0692 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -1,8 +1,8 @@ include(RunCMake) run_cmake(CommandConflict) -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio" OR "${RunCMake_GENERATOR}" MATCHES "XCode" ) - run_cmake(OutputConflict) +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode" AND NOT XCODE_BELOW_2) + run_cmake(OutputConflict) endif() run_cmake(EmptyCondition1) run_cmake(EmptyCondition2) diff --git a/Utilities/Sphinx/create_identifiers.py b/Utilities/Sphinx/create_identifiers.py index 4db7a3f..7715e53 100755 --- a/Utilities/Sphinx/create_identifiers.py +++ b/Utilities/Sphinx/create_identifiers.py @@ -19,13 +19,27 @@ if not lines: newlines = [] for line in lines: - if "<keyword name=\"command\"" in line: - if not "id=\"" in line: - prefix = "<keyword name=\"command\" " - part1, part2 = line.split(prefix) - head, tail = part2.split("#command:") - cmdname, rest = tail.split("\"") - line = part1 + prefix + "id=\"command/" + cmdname + "\" " + part2 + + mapping = (("command", "command"), + ("variable", "variable"), + ("target property", "prop_tgt"), + ("test property", "prop_test"), + ("source file property", "prop_sf"), + ("global property", "prop_gbl"), + ("module", "module"), + ("directory property", "prop_dir"), + ("cache property", "prop_cache"), + ("policy", "policy"), + ("installed file property", "prop_inst")) + + for domain_object_string, domain_object_type in mapping: + if "<keyword name=\"" + domain_object_string + "\"" in line: + if not "id=\"" in line: + prefix = "<keyword name=\"" + domain_object_string + "\" " + part1, part2 = line.split(prefix) + head, tail = part2.split("#" + domain_object_type + ":") + domain_object, rest = tail.split("\"") + line = part1 + prefix + "id=\"" + domain_object_type + "/" + domain_object + "\" " + part2 newlines.append(line + "\n") f = open(name, "w") |