[CMake] target issue

Brad King brad.king at kitware.com
Wed Jul 26 11:22:38 EDT 2006


Flávio P. Duarte wrote:
> Hi,
> 	I am developing a project where I have a subdirectory with a bunch of
> programs. Those programs are being created with ADD_EXECUTABLE command.
> The main CMakeLists.txt include this dir using SUBDIRS command, which
> makes all programs in this directory. Since ADD_CUSTOM_COMMAND seems to
> add a target that is executed by default, I would like to know how I can
> change this behaviour by only creating those programs when the user
> explicitly invoke make with a target (make programs).

Use the ADD_SUBDIRECTORY command with the EXCLUDE_FROM_ALL option.
CMake will create a build system in that subdirectory in the build tree
but it will not be included by default.  Users will have to manually go
into the subdirectory to build it.  Then you can use ADD_CUSTOM_TARGET
to create a target that does the build for you.

-Brad



More information about the CMake mailing list