On Sun, Aug 9, 2009 at 5:07 PM, Bill Hoffman<bill.hoff...@kitware.com> wrote:
> James C. Sutherland wrote:
>
>>> #define TEST_VAR_VALUE ${TEST_VAR_VALUE}
>>>
>>> is what you want.
>>
>>
>> But if I do
>>  set( TEST_VAR_VALUE 0 )
>> then this results in TEST_VAR_VALUE being undefined rather than having the
>> value of 0 as I want.  If the value is anything other than zero it works.
>>  This is what I tried to explain in my original (probably unclear) post...
>>
> No it won't.   That is a #define not a #cmakedfine.  It will always be
> there.
>
> -Bill
>

You also need to set the value in the cmake file BEFORE calling the
configure_file() command. So what you really want is the following:

*.cmake file
set( TEST_VAR_VALUE 0 )
configure_file( ${PROJECT_SOURCE_DIR}/src/config.h.in
${PROJECT_SOURCE_DIR}/src/configure.h  @ONLY)


and in your config.h.in you will have:
#define TEST_VAR_VALUE @TEST_VAR_VALUE@

This results in TEST_VAR_VALUE  _always_ being defined in your
program. It will be defined to what ever you set it to in the *.cmake
file.

-- 
Mike Jackson                               mike.jack...@bluequartz.net
BlueQuartz Software                    www.bluequartz.net
_______________________________________________
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