[CMake] Multiple makefile builds in a single in-source tree.

Josef Karthauser joe.karthauser at geomerics.com
Thu Oct 4 02:31:00 EDT 2007


I'm trying to determine how much work is required modify cmake to

support in-source build trees for multiple Makefile configurations.

 

Currently, given a source tree such as:

 

      Source/

            Proj1/

            Proj2/

 

with CMakeLists.txt files at each level, it is possible to configure a

Makefile style build tree in-source, by use of

 

      % cd Source

      % cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=RELEASE

 

for a single configuration type, or out-of-tree using

 

      % cd Source

      % (mkdir release; cd release; cmake -G 'Unix Makefiles'

-DCMAKE_BUILD_TYPE=RELEASE)

      % (mkdir debug; cd debug; cmake -G 'Unix Makefiles'

-DCMAKE_BUILD_TYPE=DEBUG) 

 

to create separate file trees configured for each kind of configuration.

 

What I would like to do is to enable in-source build trees which support

multiple configurations in a single tree. I have a proposal for how it

would work, but I don't know how much of a change to the cmake code it

would take to support it.

 

The current in-source layout of a build tree looks like:

 

      Source/

            CMakeLists.txt

            CMakeCache.txt

            CMakeFiles/

                  ... where the objects are built.

            Makefile

 

            Proj1/

                  CMakeLists.txt

                  CMakeFiles/

                        ...

                  Makefile

 

            Proj2/

                  CMakeLists.txt

                  CMakeFiles/

                        ...

                  Makefile

 

 

What I want to be able to do is to generate 'Makefile' and 'CMakeFiles/'

in a subdirectory of each directory, so if I ran for example:

 

      % cd Source

      % cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=DEBUG -

DCMAKE_INLINE_BUILD_PREFIX =DEBUGBUILD

 

it would build the in-line tree configured for DEBUG,

 

      Source/

            DEBUGBUILD/CMakeLists.txt

            DEBUGBUILD/CMakeCache.txt

            DEBUGBUILD/CMakeFiles/

                  ... where the objects are built.

            DEBUGBUILD/Makefile

 

            Proj1/

                  DEBUGBUILD/CMakeLists.txt

                  DEBUGBUILD/CMakeFiles/

                        ...

                  DEBUGBUILD/Makefile

 

            Proj2/

                  DEBUGBUILD/CMakeLists.txt

                  DEBUGBUILD/CMakeFiles/

                        ...

                  DEBUGBUILD/Makefile

 

Of course the relative paths would be wired so as to allow it to be

built by,

 

      % cd Source/DEBUGBUILD

      % make

 

If this was possible, then a number of parallel configuration trees

could be built:

 

      % cd Source

      % cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=DEBUG

-DCMAKE_INLINE_BUILD_PREFIX=DEBUGBUILD

      % cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=RELEASE

-DCMAKE_INLINE_BUILD_PREFIX=RELEASEBUILD

 

generating,

 

      Source/

            DEBUGBUILD/

            RELEASEBUILD/

 

            Proj1/

                  DEBUGBUILD/

                  RELEASEBUILD/

 

            Proj2/

                  DEBUGBUILD/

                  RELEASEBUILD/

 

It would then be a simple step to insert Makefiles in the usual places

that they lived, allowing:

 

      % cd Source

      % make DEBUG RELEASE

or 

      % make all

 

or something.

 

 

Can someone with a familiarity with the cmake code base point me in the

right direction to implement this please?

 

Thanks,

Joe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20071004/c16a1d00/attachment.htm


More information about the CMake mailing list