[Cmake] Interactive build options

Brad King brad.king@kitware.com
Fri May 21 18:29:38 EDT 2004


Eric Wing wrote:
> Hello,
> I'm working on a project that builds many libraries
> and executables. In many cases, other developers may
> not want to build everything and they would like a way
> to selectively build what they want.
> 
> With CMake, I believe I can accomplish this by giving
> each piece an OPTION(). However, because we have many
> targets, I've been asked if there is a way to make
> selection a little more manageable because resetting
> every option one by one can be tedious. 
> 
> First, I thought about having a "Build All" option
> that can be selected and deselected. When deselected,
> I would like all the target options to appear. When
> selected, it would be nice if all the target options
> would disappear (so not to confuse the user). But when
> I tried this out, once the options get displayed, I
> was unable to make them disappear.
> 
> So then I thought about a toggle button action. If the
> user triggers the action, (perhaps this could be
> implemented as an OPTION too), all target options
> should be set to ON. And when triggered the other way,
> all should be off. But when I tried a simple
> implementation of it using OPTION, I was unable to
> change the values visible in the CMake interface
> window.
> 
> Is there a way to accomplish this general idea?

Yes, and it is packaged nicely as a macro in a VTK source file:

http://public.kitware.com/cgi-bin/cvsweb.cgi/VTK/CMake/vtkDependentOption.cmake?rev=1.3&content-type=text/x-cvsweb-markup&cvsroot=VTK

Basically it lets options appear and disappear depending on other 
options, and the value is preserved in between.

-Brad



More information about the Cmake mailing list