[CMake] configure_file - false vs "0"
Mike Jackson
mike.jackson at bluequartz.net
Sun Aug 9 17:13:53 EDT 2009
On Sun, Aug 9, 2009 at 5:07 PM, Bill Hoffman<bill.hoffman at 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.jackson at bluequartz.net
BlueQuartz Software www.bluequartz.net
More information about the CMake
mailing list