[CMake] install a demo program only if requestet

Philip Lowman philip at yhbt.com
Sun Jan 11 13:33:14 EST 2009


On Sun, Jan 11, 2009 at 10:00 AM, Wilfried Holzke <cmake at holzke.net> wrote:

> Hi,
>
> > cmake -DWITH_DEMO=ON srcdir
> >
> > in CMakeLists.txt:
> >
> > if(WITH_DEMO)
> >    install( demo ....)
> > endif(WITH_DEMO)
>
> If nothing else depends on the demo code I could do
>
> if(WITH_DEMO)
>  add_subdirectory(example)
> endif(WITH_DEMO)
>
> to avoid building the whole source, right?


Yes.  The above code will stop CMake from building any targets in the
"example" subdirectory.

You can also use the option() command to specify a default for boolean
variables like WITH_DEMO and have it appear as an configurable cache
variable when using "ccmake" or "cmake-gui".

option(WITH_DEMO "Build the examples" OFF)
if(WITH_DEMO)
 add_subdirectory(example)
endif(WITH_DEMO)


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090111/3e1b0aca/attachment.htm>


More information about the CMake mailing list