[CMake] EXCLUDE_IF_UNUSED was : "Needs Utility" macro
John Biddiscombe
biddisco at cscs.ch
Fri May 12 03:20:34 EDT 2006
> PROJECT(SUBDIR)
> SUBDIRS(Executable EXCLUDE_FROM_ALL Examples)
OK. The EXCLUDE_FROM_ALL flag is doing what it is supposed to do. The
(in this case) Examples projects are not built by default. However, they
do still appear in the IDE (Vis Stud).
I'd like to do this
ADD_SUBDIRECTORY(UtilityLib1 EXCLUDE_IF_UNUSED)
ADD_SUBDIRECTORY(UtilityLib2 EXCLUDE_IF_UNUSED)
ADD_SUBDIRECTORY(UtilityLib3 EXCLUDE_IF_UNUSED)
...
so that if we have
IF(USER_WANTS_PROJECTX)
ADD_SUBDIRECTORY(ProjectX)
# imagine that project X uses Utilility lib 1,3
ENDIF(USER_WANTS_PROJECTX)
IF(USER_WANTS_PROJECTY)
ADD_SUBDIRECTORY(ProjectY)
# imagine that project Y uses Utilility lib 2
ENDIF(USER_WANTS_PROJECTY)
etc etc
If (from the GUI) we enable projectX, then 1,3 are built and are seen in
the IDE, if we enable Y, then 2 is seen, and so on, but when unused,
they just disappear completely from the build and IDE. I have about 10
projects and about 5 utilites that are used in various combinations. I
started writing macros to hide the ones that are not used, but due to
complex subdirectory heirarchies it is painfull.
Is there an easy way to do this, and if not, is it a good suggestion for
an addition?
JB
More information about the CMake
mailing list