[CMake] Newbie: Building multiple configurations (x86/x64, MSVC/MinGW-W64, etc.)

Alok Govil alokgovil at hotmail.com
Fri May 7 14:41:23 EDT 2010


Hi all,

John wrote:
> You really should not be using the same binary folder for all these
>
 different configurations. Use 1 binary folder tree for each build. Or
>
 in the case of a multi-configuration generator like visual studio you
>
 use 1 binary folder per architecture. Also separate compiler versions
>
 in separate build trees since they build incompatible binaries.

That's exactly what I want to do!  Sorry that this was not clear from my original message.

Given that I am a newbie, I may be missing on some things that are obvious to other people.  I promise I have made enough attempts to read through the all documentation available and have performed enough Google searches.

Assuming that the procedure for running cmake would be something like:

0.  Say I begin in the project root folder that has the top-level CMakeLists.txt file.
1.  cd ./make/msvc9/x64/release/         # switch to config specific folder
2.  cmake -G "generator-for-a-given-config" ../../../../

Now I would like the top-level CMakeLists.txt file to figure out the following:

1.  Link to the correct pre-compiled version of UnitTest++ based on the configuration.
2.  Find the correct compilers and build tools (MSVC is easily handled but MinGW-W64 is not since it has separate tool-chains for x86 and x64 while CMake has only one generator for MinGW (not counting Code::Blocks and Eclipse ones))
3.  Place the output files in one-per-configuration folder, which are separate from the tree where cmake cache and the makefiles reside.  For example, something like, ./bin/msvc9/x64/release/ instead of ./make/msvc9/x64/release/

Thanks,

Alok

> Date: Fri, 7 May 2010 12:32:18 -0400
> Subject: Re: [CMake] Newbie: Building multiple configurations (x86/x64, 	MSVC/MinGW-W64, etc.)
> From: drescherjm at gmail.com
> To: alokgovil at hotmail.com
> CC: cmake at cmake.org
> 
> On Fri, May 7, 2010 at 11:53 AM, Alok Govil <alokgovil at hotmail.com> wrote:
> > Hi all,
> >
> > I am trying to use CMake to build my code under multiple configurations:
> >
> > 1.  x86 and x64
> > 2.  MSVC various versions and MinGW-W64 mainly
> > 3.  Debug and release (optional)
> >
> > In each case I would like to link the code with a corresponding pre-compiled
> > version of UnitTest++.
> > (There is always an option to include UnitTest++ as a target into the
> > project, but I do not see the
> > point in building UnitTest++ on each run and for each project where
> > UnitTest++ is used.  Please let
> > me know if the direction I am taking here is not correct.)
> >
> > The case for MinGW-W64 seems to be more involved since they have two
> > separate toolchains for
> > x86 and x64.  How would I even write CMakeLists.txt for these two such that
> > correct paths to x86
> > and x64 bin folders is recognized?
> >
> > Another thing I would like to do is to specify folders where the output
> > binaries are created using
> > EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH.  This would again be based
> > on the
> > configuration used (MinGW-64 vs. MSVC, and x86 vs. x64)
> >
> > I have looked into the following, but have not been able to figure it all
> > out as yet:
> >
> >     From:  http://www.elpauer.org/stuff/learning_cmake.pdf
> >
> >         TARGET_LINK_LIBRARIES(wakeup RELEASE ${wakeup_SRCS})
> >         TARGET_LINK_LIBRARIES(wakeupd DEBUG ${wakeup_SRCS})
> >
> >     Notes:
> >     - This allows specifying different libraries for debug and release, but
> > there does not seem to
> >       be an option to use the same method to specify different libraries for
> > x86 vs. x64.
> >
> >     From:  http://www.cmake.org/pipermail/cmake/2009-June/030072.html
> >
> >         # check 64 bit
> >         if( CMAKE_SIZEOF_VOID_P EQUALS 4 )
> >             set( HAVE_64_BIT 0 )
> >         else()
> >             set( HAVE_64_BIT 1 )
> >         endif()
> >
> > Thanks,
> >
> 
> You really should not be using the same binary folder for all these
> different configurations. Use 1 binary folder tree for each build. Or
> in the case of a multi-configuration generator like visual studio you
> use 1 binary folder per architecture. Also separate compiler versions
> in separate build trees since they build incompatible binaries.
> 
> John
 		 	   		  
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100507/b7eda2ca/attachment-0001.htm>


More information about the CMake mailing list