[CMake] Bug in SET ?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Apr 16 12:30:07 EDT 2007


On 2007-04-13 12:30-0700 Alan W. Irwin wrote:

> Here is a complete test CMakeLists.txt file which illustrates what I believe
> is a bug in 2.4.6 for the SET command:
>
> message(STATUS TEST=${TEST})
> set(TEST OFF CACHE BOOL "test variable" FORCE)
> message(STATUS TEST=${TEST})
> set(TEST OFF CACHE BOOL "test variable" FORCE)
> message(STATUS TEST=${TEST})
>
> Here are the results (note the important -DTEST=ON option in the command
> line) from running cmake-2.4.6 on this using an initially empty
> build tree:
>
> software at starling> cmake -DTEST=ON ../test_variable_set/
> -- Check for working C compiler: /usr/bin/gcc
> -- Check for working C compiler: /usr/bin/gcc -- works
> -- Check size of void*
> -- Check size of void* - done
> -- Check for working CXX compiler: /usr/bin/c++
> -- Check for working CXX compiler: /usr/bin/c++ -- works
> -- TEST=ON
> -- TEST=ON
> -- TEST=OFF
> -- Configuring done
> -- Generating done
> -- Build files have been written to: 
> /home/software/plplot_cvs/HEAD/cmaketest/build_dir
>
> Why do I have to force TEST OFF twice before it "takes"?
> If I don't specify -DTEST on the command line then, the three messages
> are
>
> -- TEST=
> -- TEST=OFF
> -- TEST=OFF
>
> as you would expect.
>
> I believe the -DTEST=ON result where the variable cannot be forced OFF the
> first time you try is a bug in 2.4.6, but I would like to see some discussion
> here before I make a bug report about this.

I have investigated further.  -DTEST=ON is what I tested above and which
cannot be forced off on the first try.  However, if I use -DTEST:BOOL=ON
(i.e., specify the type) then the problem disappears, i.e.,

-- TEST=ON
-- TEST=OFF
-- TEST=OFF

is the result.  I obtain this result regardless of what type (BOOL, PATH,
FILEPATH, INTERNAL, or STRING) that I specify for the -D option.  So it is
only when no type is specified at all that there is a problem.  I am a
little suprised at this since I would have normally assumed that if no type
was specified for the -D option, some type would have been assigned by
default.

I would appreciate some comments from the CMake developers about the
necessity of using type with the -D option, whether a default type should
be assigned if one isn't specified, and why I am getting the two
different behaviours above depending on whether type is used or not.

My opinion is that the FORCE option to SET should _always_ force the
specified cache value (as is currently documented and as seems intuitive to
users).  When you get situations like above where it doesn't always force
the value, it can be quite confusing to users.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list