[CMake] --enable-* with cmake

Philip Lowman philip at yhbt.com
Wed Aug 8 10:19:29 EDT 2007


Eric Noulard wrote:
> 2007/8/8, gga <ggarra at advancedsl.com.ar>:
>> I'm currently using cmake for a variety of projects.  Love it.
>> However, one feature I find myself missing more and more is one from
>> autotools configure scripts: AC_ARG_ENABLE().
>> That is, the ability to allow the configuration script (ie. cmake) to be
>> run with arbitrary flags to turn on or turn off some options
>> (--enable-X11 for example), regardless of what it finds on the standard
>> paths.  Also this option in autoconf allows too have those options
>> available to the user thru a simple help line.
>>
>> I know I can pass -D symbols to cmake to modify its behavior and that
> 
> What do you think very different between
> 
> configure --enable-X11
> cmake -DENABLE_X11

In defense of the original post,

--enable-foo is much more readable than -DENABLE_FOO or -DUSE_FOO.
Having implemented USE_FOO arguments for every single one of our
optional dependencies and looked at them on a CMake command line I can
attest to this. :)

I love CMake, but there have been times when I wished that

--enable-foo would simply be a shortcut to set a boolean variable
ENABLE_FOO to true.

>> windows also has its ugly CmakeSetup gui.
> 
> un*x version of cmake has menu driven UI too
> did you try ccmake (note the double 'c')
> 
> <joke>
> personnally I think the ugliness of GUI app most
> of time comes from the GUI concept itself :=))
> command line is far more powerful.
> </joke>

<joke>
Real men edit CMakeCache.txt manually. :)
</joke>

> 
>> However, neither approach seems to me as clean as what's available under
>> autotools.
> 
> I personnally think the OPTION CMake macro is just as good
> as AC_ARG_ENABLE is.

Almost.  Automake has a neat feature the original poster pointed out
that uses arguments to AC_ARG_ENABLE to output documentation when you
call "./configure --help".  CMake doesn't have an equivalent feature I
know of for this but I think the closest would be a visual inspection of
the variables in "ccmake" or "CMakeSetup.exe".

-- 
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com


More information about the CMake mailing list