Indeed, the first GUID in the project definition line indicates the
project type (C++, C#, Visual Basic...). The
INCLUDE_EXTERNAL_MSPROJECT command needs to change the GUID based on
the project type.

Thanks for pointing this out.. ;) I just added some C# projects to our
solution, quite handy.

Here is a modification I've just made to add this functionality to CMAKE.

In CMAKE version 2.4.3

Modified Files:
.\Source\cmGlobalVisualStudio71Generator.cxx

- WriteExternalProject() member function modified to check the project type,
and use the appropriate project type GUID when writing the solution file.

Code snipit:
------------------------------
// Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here
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";
if (strstr(location_uppercase, ".VBPROJ"))
    project_type_guid = "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
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


On 1/11/07, Mike Talbot <[EMAIL PROTECTED]> wrote:
Hello,

I am trying to use the INCLUDE_EXTERNAL_MSPROJECT command to add a C#
project to my solution, but the solution fails to load in VS 2005.  I
have traced this down to the fact that all projects in the
cmake-generated .sln file have the same GUID - i.e. every project entry
(including the external C# project) starts with:

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") =

If I change the GUID for the external C# project (to anything else),
then the solution loads fine.  Question is how to work around this.  I
can either change the WriteExternalProject method in the cmake generator
code to use a different GUID when writing out external projects or if
someone has a suggestion on how to fix the GUID in the generated
solution automatically that would be helpful.

(I am using cmake 2.4.2)

Many thanks,
Mike

--
Mike Talbot
Senior Software Developer
Schlumberger
Lambourn Court, Wyndyke Furlong,
Abingdon Business Park, Abingdon,
Oxfordshire, OX14 1UJ, UK
Tel: +44 (0)1235 543 488

_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to