[CMake] "Needs Utility" macro
John Biddiscombe
biddisco at cscs.ch
Thu Aug 18 03:23:19 EDT 2005
I have a root project with N subdirs. In most Subdirs are projects which
are all under CMake control. Some Projects use others and all is working
fine. The root project presents options
CSCS_BUILD_PROJECT_X
CSCS_BUILD_PROJECT_Y
CSCS_BUILD_PROJECT_Z
and then ADD_SUBDIRECTORY(ProjectX) if an option to build a sub proj is
turned on.
If a sub project depends on another subproject and it is not turned on,
the user sees a warning and it rurns on the other subproject.
but...
One subDir contains utilities. Libraries which are mostly used by
various projects, but some (eg GLUT/GLUI) are used by Project X, but not
by project Y. When the user enables Project X, we must build Glut, but
when X is off and no other X//Y/Z project uses GLUT I don't want to
build it. As it stands at the moment, the utilities are always built,
whether they are needed or not (because adding a GUI option for each is
getting tiresome)
I'd like to create a Macro that each project can call which says
Project X : NEED_UTILITY(Glut Glui QtWidgets)
Project Y : NEED_UTILITY(Glut)
Project Z : NEED_UTILITY(QtWidgets)
Clearly, when only Z is built, we don't need Glut/Glui and when Y alone,
we don't need QtWidgets etc etc. The root level project would scan the
list of required utilites and only add_subdirectory for those that are
required.
Has anyone done this before? (or something similar?). I don't see any
great difficulty in implementing it, but perhaps some functionality
already exists which I've missed which will save me doing it - By
default CMake will build things based on dependency, but when nothing
depends on a lib, it is still built (since it's a target). I just want
to turn off build for non "top-level" targets. Perhaps a
SET_TARGET_PROPERTIES(mylib, SKIP_BUILD_IF_NOT_USED_BY_ANYTHING_ELSE)
thanks
JB
--
John Biddiscombe, email:biddisco @ cscs.ch
http://www.cscs.ch/about/BJohn.php
CSCS, Swiss National Supercomputing Centre | Tel: +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
More information about the CMake
mailing list