[CMake] make target names for individual executables?

Brad King brad.king at kitware.com
Sat Mar 5 09:36:39 EST 2005


Zachary Pincus wrote:
> I have a CMakeLists file that calls SUBDIRS(...). Each sub-CMakeList 
> basically consists of an ADD_EXECUTABLE statement.
> 
> So running "make" from the top directory builds all the executables. 
> Moving into one of the subdirectories just builds that executable. This 
> is all good. However, I can't figure out how to run something like "make 
> Executable1" to just make a particular executable from the top level 
> directory.
> 
> The makefile defines some targets like "default_target_Executable1", but 
> when I run "make default_target_Executable1", it seems that all the 
> executables get built anyway.

This is an internally generated rule used for traversing the directory 
structure.  I bet you have a directory called Executable1.  It depends 
on previous directories to make sure things happen in the right order.

> Is there any way to get individual targets from the CMakeLists into the 
> makefiles? I checked the FAQ and docs, but I can't find anything obvious...

The individual targets do exist by their canonical name in the makefile 
for the directory where they are built.  Right now there is no simple 
way to get a top-level target for executables in subdirectories.  You 
might be able to add a custom target that is not part of the all build 
that changes into the subdirectory and make the targets.

-Brad


More information about the CMake mailing list