[CMake] multiple out of source builds from same source

Dekeyser, Kris Kris.Dekeyser at lms.be
Wed Apr 20 15:47:44 EDT 2005


Hi Cim,

I'm very much in favor of your -f suggestion. I think it is a powerfull feature still missing from CMake. Unless somebody is already working on this, I suggest you enter it in the bug tracker.

For the time being, you can create a cache var "BUILD_TYPE" and have some conditionals like 
IF(BUILD_TYPE EQUALS 1)
  # Do your build 1 stuff
ENDIF(BUILD_TYPE EQUALS 1)
IF(BUILD_TYPE EQUALS 2)
  # Do your build 2 stuff
ENDIF(BUILD_TYPE EQUALS 2)
in your CMakeLists.txt.

Regards, Kris

> -----Original Message-----
> From: cimarron_cmake at taylors.org [mailto:cimarron_cmake at taylors.org]
> Sent: Wednesday, April 20, 2005 10:20
> To: cmake at cmake.org
> Cc: cimarron at christopherrobin.kolo.net
> Subject: [CMake] multiple out of source 
> builds from
> same source
> 
> 
> 
> Hello, 
> 
> I have a situation where I want to produce multiple executables
> from the same source code where the different executables would
> differ mostly by linking with different external libraries.
> 
> If I was using an ordinary makefile, I'd have a slightly different
> makefile in each of my destination directories, or I would have
> multiple makefiles in my source directory and use make -f to specify
> the specific makefile.
> 
> I understand that the CMake way of doing things is to have the
> CMakeLists.txt file reside in the source directory, but then I can't
> effectively have separate setttings in separate CMakeLists.txt files.
> 
> So for now I've created what I believe is an unnatural situation 
> where I have a directory structure like:
> 
>    source/
>        settings1/
>            CMakeLists.txt  (with settings for build1)
>        settings2/
>            CMakeLists.txt  (with settings for build2)
>    build1
>    build2
> 
> and I have my build script cd to build1, do a cmake 
> ../source/settings1
> then cd to build2, do a cmake ../source/settings2, etc.  The problem
> with this is that all my pathnames need an extra level of indirection.
> 
> Ideally, I'd like to have something more like
> 
>    source/
>        settings1-CMakeLists.txt  (with settings for build1)
>        settings2-CMakeLists.txt  (with settings for build2)
>    build1
>    build2
> 
> and then do a cmake -f settings1-CMakeLists.txt ../source in build1
> and cmake -f settings2-CMakeLists.txt ../source in build2 and so on.
> 
> So my questions are:
> 
>   1. Is there an equivalent to 'make -f' for CMake?
>   2. Is there a better way I can use CMake to accomplish what I want?
> 
> I really do want to keep the settings in separate CMake files
> instead of using some kind of conditional processing since I have
> lots of them which are worked on by different people.
> 
> Regards,
> 
> Cim
> 
> 
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 
+-+-+- Email Confidentiality Footer +-+-+- 
Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not print, retain, copy nor disseminate this message or any part of it to anyone and you should notify the sender by reply email and destroy this message. Neglecting this clause could be a breach of confidence. Please advise immediately if you or your employer does not consent to Internet email for messages of this kind. Opinions, conclusions and other information in this message that are not related to the official business of my firm shall be understood as neither given nor endorsed by it.



More information about the CMake mailing list