On 6. Mar, 2009, at 14:50, Marcel Loose wrote:

Hi all,

With respect to my previous post.
Is it possible to somehow reset the result variable from
CheckCSourceCompiles(SOURCE VAR)?

I wanted to run a number of tests in a foreach loop, using the same
C-code snippet, but with one CMake variable being substituted, but I
noticed that the test is run only once. Is there a way to reuse/reset
the cache variable "result", or should I make the result variable
unique, e.g. HAVE_${func_name}?

foreach(func_name __PRETTY_FUNCTION__ __FUNCTION__)
 check_c_source_compiles("
   #include <stdio.h>
   int main() { puts(${func_name}); }
   " result)
# if(result)
#   break()
# endif(result)
endforeach(func_name __PRETTY_FUNCTION__ __FUNCTION__)


That's really funny, I ran into exactly the same problem today. My solution was to use unique variable names:

foreach(func_name __PRETTY_FUNCTION__ __FUNCTION__)
  check_c_source_compiles("
    #include <stdio.h>
    int main() { puts(${func_name}); }
    " result${func_name})
  if(result${func_name})
    set(result ${result${func_name}})
    break()
  endif(result${func_name})
endforeach(func_name __PRETTY_FUNCTION__ __FUNCTION__)

With CMake-CVS (or 2.6.3, but I'm not sure) you could also use unset(func_name CACHE).

Michael
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to