[CMake] configure_file - false vs "0"

James C. Sutherland James.Sutherland at utah.edu
Sun Aug 9 16:49:49 EDT 2009


>>>>>
>>>>> In my configure.h.in file I have:
>>>>>
>>>>> #cmakedefine TEST_VAR_VALUE
>>>>>
>>>>> In my CMakeLists.txt file I have:
>>>>>
>>>>> configure_file( ${PROJECT_SOURCE_DIR}/src/config.h.in $ 
>>>>> {PROJECT_SOURCE_DIR}/src/configure.h )
>>>>> set( TEST_VAR_VALUE  "0" )
>>>>>
>>>>> This results in a configure.h file containing:
>>>>> /* #undef TEST_VAR_VALUE */
>>>>>
>>>>> But what I would like is:
>>>>> #define TEST_VAR_VALUE 0
>>>>>
>>>>>
>>>>> So basically cmake is seeing the value of TEST_VAR_VALUE as 0  
>>>>> and treating it as "false" rather than a value.
>>>>>
>>>>> Any ideas how to accomplish this?
>>>>>
>>>>> James
>>>>>
>>>>
>>>>
>>>> Use the (undocumented) #cmakedefine01.
>>>>
>>>> I already submitted a patch, and the documentation has been fixed  
>>>> in CVS.
>>>>
>>>> Michael
>>>>
>>>
>>> Thanks!  That did it.
>>
>>
>> Okay - I spoke too soon.  It gave me a partial solution.
>>
>> What if I want to have something like
>> #define TEST_VAR_VALUE 5
>>
>> In the .in file:
>> #cmakedefine TEST_VAR_VALUE ${TEST_VAR_VALUE}
>> doesn't work (for reasons mentioned above)
>>
>> However,
>> #cmakedefine01 TEST_VAR_VALUE ${TEST_VAR_VALUE}
>> results in
>> #define TEST_VAR_VALUE 5 1
>> if I have
>> set( TEST_VAR_VALUE 5 )
>> in my CMakeLists.txt file.
>>
>> Can I get rid of the trailing value?
>>
>
> Aah, now I see what you want...
>
> #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...



More information about the CMake mailing list