[CMake] "Needs Utility" macro

dohadwala, moiz dohadwala_moiz at emc.com
Fri Aug 19 13:03:42 EDT 2005


I have a question about this.

Now if I navigate to exclude_dir1 project which happens to have a dependency
on a library1 in dir1, and build it, will cmake handle the dependencies and
build the library in dir1, if it is not already built or out of date with
the source code?

-Moiz
 

-----Original Message-----
From: cmake-bounces+dohadwala_moiz=emc.com at cmake.org
[mailto:cmake-bounces+dohadwala_moiz=emc.com at cmake.org] On Behalf Of William
A. Hoffman
Sent: Thursday, August 18, 2005 6:34 AM
To: John Biddiscombe; cmake at cmake.org
Subject: Re: [CMake] "Needs Utility" macro

I think you may want SUBDIRS(EXCLUDE_FROM_ALL )



SUBDIRS: Add a list of subdirectories to the build.

  SUBDIRS(dir1 dir2 ...[EXCLUDE_FROM_ALL exclude_dir1 exclude_dir2 ...]
[PREORDER] )

Add a list of subdirectories to the build. This will cause any
CMakeLists.txt files in the sub directories to be processed by CMake. Any
directories after the PREORDER flag are traversed first by makefile builds,
the PRORDER flag has no effect on IDE projects. Any directories after the
EXCLUDE_FROM_ALL marker will not be included in the top level makefile or
project file. This is useful for having cmake create makefiles or projects
for a set of examples in a project. You would want cmake to generated
makefiles or project files for all the examples at the same time, but you
would not want them to show up in the top level project or be built each
time make is run from the top. 





At 03:23 AM 8/18/2005, John Biddiscombe wrote:
>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
>
>
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
CMake mailing list
CMake at cmake.org
http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list