[CMake] CMake Build References
Bill Hoffman
bill.hoffman at kitware.com
Thu Nov 30 09:20:46 EST 2006
Sylvain Benner wrote:
>
>> 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.
One hack you could do is this....
Run CMake once on the project. Then grep for GUID in the CMakeCache.txt
for the project.
You will get a bunch of stuff like this:
DumpDocumentation_GUID_CMAKE:INTERNAL=608A20C3-74D8-44BF-AD76-E758979D6DD2
You can do two things with those values.
1. you can create an initial CMakeCache.txt file, and copy this into any
binary directory that you want
to run cmake on.
2. You can convert them to SET commands and add them to the top of your
project.
like this:
SET(DumpDocumentation_GUID_CMAKE 608A20C3-74D8-44BF-AD76-E758979D6DD2
CACHE INTERNAL "GUID value")
You should not need to modify the cmake source for either of these
solutions.
-Bill
More information about the CMake
mailing list