[CMake] GUIDs in VS solution files

Vincent Scheib vsglists at gmail.com
Mon Feb 5 19:19:49 EST 2007


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
// ...
-------


More information about the CMake mailing list