I do this by making a .in file that gets configured that contains the value of the CMake variable.<br><br><a href="http://header.h.in">header.h.in</a>:<br>===========<br>#define FEATURE_X @FEATURE_X@<br><br>CMakeLists.txt:<br>
===========<br>configure_file(${CMAKE_CURRENT_SOURCE_DIR}/<a href="http://header.h.in">header.h.in</a><br>  ${CMAKE_CURRENT_BINARY_DIR}/header.h<br>  @ONLY)<br>include_directories(${CMAKE_CURRENT_BINARY_DIR})<br><br>features.c:<br>
===========<br>
#include &quot;header.h&quot;<br>
<br>Now, when FEATURE_X changes in cmake, header.h changes, which triggers a re-compile of any files that include it.<br><br><br>HTH,<br>David<br><br><br>On Tue, May 17, 2011 at 11:45 AM, Robert Bielik <span dir="ltr">&lt;<a href="mailto:robert.bielik@xponaut.se">robert.bielik@xponaut.se</a>&gt;</span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi all,<br>
<br>
I&#39;m wondering if there&#39;s a way to touch files on cached var changes. Let&#39;s say I have an option to enable or disable a feature<br>
in my application, and depending on its setting a preprocessor macro is defined (or not defined) in the CMakeLists.txt file:<br>
<br>
OPTION(FEATURE_X &quot;Check to enable feature X&quot; OFF)<br>
<br>
IF(FEATURE_X)<br>
ADD_DEFINITIONS(-DUSE_FEATURE_X=1)<br>
ELSE(FEATURE_X)<br>
ADD_DEFINITIONS(-DUSE_FEATURE_X=0)<br>
ENDIF(FEATURE_X)<br>
<br>
and in &quot;features.c&quot;:<br>
<br>
...<br>
#if USE_FEATURE_X<br>
// Code for feature X<br>
<br>
#endif<br>
...<br>
<br>
The source code file &quot;features.c&quot; that have code depending on the preprocessor macro needs to be recompiled each time the option changes, which does not automatically<br>
happen if the macro is defined like above (and I _really_ need to have it defined, either to zero or one...).<br>
<br>
So I pretty much need to hook a dependency of &quot;features.c&quot; to change of cached cmake options/vars...<br>
<br>
Ideas?<br>
TIA<br>
/Rob<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>