[CMake] Possible to get target's _GUID_CMAKE value at cmake time?

zkhan zamir.khan at gmail.com
Fri Mar 15 08:41:49 EDT 2013


After playing around with this more, I realized that this method wouldn't
always work because I can't expect the GUIDs to be available on a fresh run
of CMake. So I went the route that I had seen suggested previously, which is
to explicitly set the GUID values myself.

So in the CMakeLists.txt for each C++/CLI wrapper project, I have something
like this:

# Set a global cache variable for this project GUID
# The TestAppNet csproj needs this GUID to properly reference this project
set_property(GLOBAL PROPERTY Wrapper_GUID
"1897F4D1-E929-444E-9343-00F094113772") 
get_property(projectGUID GLOBAL PROPERTY Wrapper_GUID) # Just wanted to make
sure I could retrieve it
MESSAGE( STATUS "Setting project GUID to: ${projectGUID}")
set(Wrapper_GUID_CMAKE "${projectGUID}" CACHE INTERNAL "Project GUID")

And in the C# project CMakeLists.txt, I have this:

get_property(CMAKE_WRAPPER_GUID GLOBAL PROPERTY Wrapper_GUID)
MESSAGE( STATUS "Setting Wrapper GUID to: ${CMAKE_WRAPPER_GUID}" )

... and then the CMAKE_WRAPPER_GUID is used as a variable in the .csproj
file that is populated during the configure_file command.

I'm not sure if this is efficient or even advisable, but it seems to work.



--
View this message in context: http://cmake.3232098.n2.nabble.com/Possible-to-get-target-s-GUID-CMAKE-value-at-cmake-time-tp7583648p7583685.html
Sent from the CMake mailing list archive at Nabble.com.


More information about the CMake mailing list