[CMake] CMake Build References

Sylvain Benner benner at virtools.com
Thu Nov 30 04:34:09 EST 2006


> 3)       Have CMake generate VC Solutions with the same GUIDs each time
>
I think you want that CMake generates the same GUIDs each time -and- on 
any computer.
We had this problem here, it's a common issue when you have to source 
controlled your projects.

You have 2 possibilities:

1) Use the same CMakeLists.txt on each computer. It works but it is very 
limited.

2) Patch CMake to support this feature. This is what we've done here.

So, we implemented a GUID macro for the CMakeLists.txt command:

MACRO(GUID guid)
    # for Visual Studio
    IF(CMAKE_GENERATOR MATCHES "Visual Studio")
        STRING(TOUPPER ${PROJECT_NAME} UPPER_PROJECT_NAME)
        SET(${UPPER_PROJECT_NAME}_GUID ${guid})
    ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
ENDMACRO(GUID)

The result is a variable called NAMEPROJECT_GUID.

The idea is to get this variable if it exists in the CMakeCache.txt 
instead of the variable named CMAKE_PROJECTNAME_GUID which is different 
when you generate project files on two different computers.
So you have to patch the following methods:
    -cmGlobalVisualStudio71Generator::CreateGUID : to adds your GUID to 
the cache
    -cmGlobalVisualStudio71Generator::GetGUID : to get your GUID

I can't submit a patch since this feature is implemented in a custom 
generator and it is embedded in a lot of customizations.
CMake is the first open source program I am working with and I made some 
mistakes that prevent me from sharing our custom features to the community.
I will act differently next time.

Sylvain






More information about the CMake mailing list