[CMake] Control Object code destination?

KSpam keesling_spam at cox.net
Fri Apr 25 14:56:51 EDT 2008


Eric,

On Friday 25 April 2008 11:27:54 Eric Torstenson wrote:
> So, I take it that this isn't possible? Is there a way to make a feature
> request?

What you are asking for is already possible, and very easy to accomplish in 
CMake.  Consider the following directory structure:

build/
	linux-i386/
		deug/
		release/
	linux-amd64/
		debug/
		release/
	windows/
	...
source/
	CMakeLists.txt
	...

To build the i386 Linux debug targets, simply configure the build directory 
and build as follows (on your i386 OS):

	1) Create the build directory if it does not already exist 
(build/linux-i386/debug)
	2) cd build/linux-i386/debug
	3) cmake -D CMAKE_BUILD_TYPE:STRING=Debug ../../../source
	4) Run "make" as usual in this build directory

Similarly, to build the amd64 Linux release targets, configure the build 
directory and build as follows (on your amd64 OS):

	1) Create the build directory if it does not already exist 
(build/linux-amd64/release)
	2) cd build/linux-amd64/release
	3) cmake -D CMAKE_BUILD_TYPE:STRING=Release ../../../source
	4) Run "make" as usual in this build directory

If you are using the Visual Studio IDE on Windows, you do not need to worry 
about separate build directories for release and debug.  This is because the 
objectfile directories automatically include the build type.  The Windows 
build process goes like this:

	1) Create the build directory if it does not already exist (build/windows)
	2) cd build/windows
	3) cmake ../../source
	4) Open your resulting sln file in the Visual Studio IDE, and build as normal 
(remember to select the build type in the IDE)

The bottom line is that your build directories should be separate from your 
source tree.  You can have as many independent build directories as you want, 
and you can share the exact same source tree for all of them.  Cleanup is a 
breeze; simply remove the appropriate build directory.

Hope This Helps,
Justin


More information about the CMake mailing list