[CMake] configure_file - false vs "0"
James C. Sutherland
James.Sutherland at utah.edu
Sun Aug 9 18:05:09 EDT 2009
>>>
>>> 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...
>>
>
> $ cat CMakeLists.txt
> cmake_minimum_required( VERSION 2.6 )
> project( test )
> set( TEST_VAR_VALUE1 0 )
> set( TEST_VAR_VALUE2 1 )
> set( TEST_VAR_VALUE3 "hello there" )
> configure_file( config.h.in ${test_BINARY_DIR}/config.h )
>
> $ cat config.h.in
> #define TEST_VAR_VALUE1 ${TEST_VAR_VALUE1}
> #define TEST_VAR_VALUE2 ${TEST_VAR_VALUE2}
> #define TEST_VAR_VALUE3 ${TEST_VAR_VALUE3}
>
> $ mkdir build && cd build && cmake ..
> $ cat config.h
> #define TEST_VAR_VALUE1 0
> #define TEST_VAR_VALUE2 1
> #define TEST_VAR_VALUE3 hello there
>
>
> Which presumably is what you want... why would you think that
> SET(TEST_VAR_VALUE 0) "undefines" it? For that you either use
> SET(TEST_VAR_VALUE), or with newer versions of CMake you can use the
> clearer UNSET(TEST_VAR_VALUE).
>
>
> Michael
Thank you and Bill for your patience and help. Indeed, I
misunderstood the "#define" vs "#cmakedefine" in the config.h.in
file. This now works.
BTW, although I am somewhat new to build systems, I find cmake to be a
very nice tool - definitely much simpler to use than autoconf! I also
dabbled with bjam and find cmake more usable (and the fact that it
supports F90 is great).
Thanks again for the help.
More information about the CMake
mailing list