Modular building of kde modules

Alexander Neundorf neundorf at kde.org
Wed Mar 18 22:58:31 GMT 2009


On Wednesday 18 March 2009, Parker Coates wrote:
> On Tue, Mar 17, 2009 at 20:03, Matthew Woehlke wrote:
> > Parker Coates wrote:
> >> I've often wished CMake had a construct equivalent to Python's "if
> >> __name__ == '__main__' :" that would let you run certain code only if
> >> the current file was being run as the "top level" CMakeLists.txt.
> >
> > You mean like this?
> > if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
>
> Okay, so we've determined that I /can/. The next question is whether I
> /should/.
>
> Is this a good idea? Will people reading it actually understand what
> I'm trying to do? Is there a more elegant alternative?

Well, this comparison says "is the current source dir equal to the top level 
source dir", i.e. is this project being built as part of a bigger project.

Another way to check would be to ask "is this project being built as part of 
e.g. kdeutils ?"
This could be done like this:

if (NOT kdeutils_SOURCE_DIR)
   ... build as separate project
endif (NOT kdeutils_SOURCE_DIR)

This is more specific, and could more easily break (e.g. if the 
project "kdeutils" is renamed to "KDEUtils" or so).

Alex



More information about the kde-core-devel mailing list