[CMake] Patch to apply! Changing the default name"CMakeLists.txt"! Introduction to "Common Build System"

Brandon Van Every bvanevery at gmail.com
Tue Jan 15 11:37:12 EST 2008


On Jan 15, 2008 7:03 AM, Martin Lutken <mlu at danware.dk> wrote:
>
> Simple example from my actual codebase. CBS (Common Build System) makefiles
> for zlib and libpng, which depends on zlib (install stuff not included):
>
> --- z.cbs ---
> TARGET_DEFAULT_VERSION ( 1 2 3  )
> ADD_SOURCE_FILE ( adler32.c     )
> ADD_SOURCE_FILE ( compress.c    )
> ...
> ADD_SOURCE_FILE ( inffast.c     )

Why do I want ADD_SOURCE_FILE?  In CMake I just do:
SET(mysources adler32.c compress.c inffast.c)
ADD_LIBRARY(mysharedlib SHARED ${mysources})
ADD_LIBRARY(mystaticlib STATIC ${mysources})

>
> --- png.cbs ---
> TARGET_DEFAULT_VERSION ( 1 2 16 )
> ADD_DEPENDS_ON (  z  )

Why do I want ADD_DEPENDS_ON?  In CMake I just do:
TARGET_LINK_LIBRARIES(mysharedlib z)
TARGET_LINK_LIBRARIES(mystaticlib z)

> --------------------------------
> Note the ADD_DEPENDS_ON ( z ) for png. This single line takes care of all
> needed includes, linkdirs/libraries etc. thats neeeded to compile and link
> libpng.

>From your description, I don't understand what this is doing extra.

> In the (in time hopefully rare) cases where you depend on external libraries
> you use ADD_LINK_DIR, ADD_LINK_LIBRARY

CMake's TARGET_LINK_LIBRARIES doesn't care if you hand it external
link libraries or internal library target names.  It just deals with
them.  Why do you need a 2nd command?

> In case you need to add defines you can do
> ADD_DEFINE or ADD_PUBLIC_DEFINE

CMake has ADD_DEFINITIONS.  What would ADD_PUBLIC_DEFINE do?
>
> --- Main configuration file ---
> Lastly I should mention some of the cool stuff you can do in the main
> configuration file, by this example from (again from my actual codebase):
>
> SET ( z_USE     SYSTEM   ) # Use system version (currently not Windows)

So you are implementing cross-compiling support?  CMake CVS has that.

> SET ( png_USE   BUILD    ) # Build from sources in this project

CMake can do this, but it has to be handled by the consumers of the
png library, not the png library itself.
if(use_myzlib)
  TARGET_LINK_LIBRARY(mylib myzlib)
else(use_myzlib)
  TAGET_LINK_LIBRARY(mylib z)
endif(use_myzlib)

> SET ( bz2_USE   PREBUILT ) # Prebuilt (with CBS) from othter source tree.

I don't have a lot of experience with using CMake builds that wrap
other CMake builds.  CMake does have mechanisms for 3rd party builds.

> SET ( z_LINK_TYPE STATIC  ) # Build/use zlib static event though current
> default for project as a whole is to make shared libs/DLLs.

CMake already has that.  ADD_LIBRARY(mylibname [SHARED | STATIC |
MODULE] blah blah blah) where the stuff in [ ] is optional.

> Well hope that gave you an impression of what it is.

I'm unclear.  What is the strategic purpose of CBS?

Are you trying to do CMake projects, but at what you consider to be a
higher level of abstraction than CMake provides?  If so, then it's
probably worth going over each of those features above individually.
Some of them, I think CMake does just fine already.  Others, perhaps
you have a more elegant approach.  But community buy-in is important
here.  Nobody's looking for new things to learn, unless there are
clear benefits.  One of the biggest detriments I see in adding new,
supposedly better ways of doing the same thing, is that CMake is
already woefully under-documented as is.  So it really should do a
different or clearly better thing, not just a variation on the thing.
It's way easier for CMake developers to function as a community when
they're all speaking the same language.

Are you trying to make it possible to generate CMake projects, or
other build tool projects (SCons?  Ant?) using a common build tool?
If so, that's already what CMake is trying to do.  We don't want a
common build tool, we think we are the common build tool.  We would
want a generator for SCons or Ant or whatever.


Cheers,
Brandon Van Every


More information about the CMake mailing list