[CMake] GUIDs in VS solution files

Bill Hoffman bill.hoffman at kitware.com
Mon Feb 5 19:41:10 EST 2007


I just checked a fix into CVS, that reads the GUID from  an external 
project and uses that instead of generating a new one.  (caused an error 
with VS 2005 SP1).  You may want to update and start with that code.   
The code uses an XML parser, so you should be able to figure out the 
type of external project as well without changing too much.

-Bill


Vincent Scheib wrote:
> I've implemented the ability to reference C# projects in a vc80 .sln
> solution file with INCLUDE_EXTERNAL_MSPROJECT. Though, it is not a
> small isolated code snippet. Here are the steps I took:
>
> - I added cmGlobalVisualStudio71Generator::GetPlatform(), which
> returns "Win 32", and is overridden in cmGlobalVisualStudio80Generator
> to return this->Platform.
>
> - I added the ability to store a string in the cache for the platform
> for each project in a solution. (similar to GetGUID().) I called these
> new member functions: SetProjectPlatform() / GetProjectPlatform().
> GetProjectPlatform defaults to GetPlatform() if no cache entry is set.
> (these were added to cmGlobalVisualStudio71Generator)
>
> - in WriteSolutionConfigurations(), the solution level platform is
> always "Mixed Platforms".
> (I only added to cmGlobalVisualStudio8Generator, as that's all I need)
>
> - in WriteProjectConfigurations(), the solution platform of "Mixed
> Platforms" maps to a per project platform, extracted with
> GetProjectPlatform().
> (I only added to cmGlobalVisualStudio8Generator, as that's all I need)
>
> - My previous version of WriteExternalProject() has been updated
> slightly, and sets the platform for the project if it is C#.
>
> -------
> void cmGlobalVisualStudio71Generator
> ::WriteExternalProject(std::ostream& fout,
>                               const char* name,
>                               const char* location,
>                               const std::vector<std::string>& depends)
> {
> //*** BEGIN EMERGENT MODIFICATION
> //*** support for external project files that are not C++
>
>  // Create an uppercase version of location
>  char* location_uppercase = NULL;
>  {
>      size_t location_strlen = strlen(location);
>      location_uppercase = new char[location_strlen+1];
>      strcpy(location_uppercase, location);
>      for (char* c = location_uppercase; *c != NULL; c++)
>      {
>          *c = toupper(*c);
>      }
>  }
>
>  // Check what type of project it is, to know what type of GUID to use.
>  const char* project_type_guid = 
> "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"; //C
>  if (strstr(location_uppercase, ".CSPROJ"))
>  {
>      project_type_guid = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
>      this->SetProjectPlatform(name, "Any CPU");
>  }
>  delete [] location_uppercase;
>  location_uppercase = NULL;
>
>  std::string d = cmSystemTools::ConvertToOutputPath(location);
>  fout << "Project(\"{" << project_type_guid << "}\") = \""
>       << name << "\", \""
>       << d << "\", \"{"
>       << this->GetGUID(name)
>       << "}\"\n";
>
> //*** END EMERGENT MODIFICATION
> // ...
> -------
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>



More information about the CMake mailing list