[CMake] add_custom_target / add_definitions cache issues

Reto Glauser gentoo at blinkeye.ch
Thu May 14 05:59:53 EDT 2009


Hello

I have a macro to get SCM information (in this case git) from the
${CMAKE_SOURCE_DIR}. I use the branch and SHA1 information to define the
${PROJECT_VERSION} which in turn defines a compiler definition:

add_definitions( -DVERSION="${PROJECT_VERSION}" )

Example:

-DVERSION="master:cef2dc74ef1301b4d6948077969f713fb87fef08"

Now, I'd like to rerun and redefine -DVERSION each time I commit a change
to the SCM or change the branch but fail to see how to achieve that. 

I tried to add a add_custom_target which calls the macro. But even though
the add_custom_target is called each time (I verified that with the COMMENT
argument), the macro isn't. So, how do I force the macro to be called each
time? And how to properly redefine the compiler definition
-DVERSION="${PROJECT_VERSION}" afterwards?

Regards,
Reto


More information about the CMake mailing list