[CMake] Build different targets depending on build configuration

Steven Dwyer steven.dwyer at shoutresearch.com
Mon Aug 18 08:38:25 EDT 2008


I'm looking at moving from scons to cmake, but after reading through the documentation and mailing lists, I'm not sure if it will handle everything that I want to do.  In particular:

I want to build three different configurations:  Debug, Release, Test

The input to the three configurations is mostly the same (some differences in compiler switches, etc.).  However, the output is different for the test configuration.

The test configuration should build with the following "rules".

1.  The test configuration should always link in an additional library that contains its own 'main' function.
2.  If the Debug/Release configurations build an executable, the test configuration should also build an executable and run it after it is built.
3.  If the Debug/Release configurations build a library, the test configuration should build an executable and run it after it is built.

Is it possible to do this with cmake, and if so are there any pointers on how to set it up?

I'm using the Microsoft Visual Studio 2005 generator and am running on the Windows platform.

Thanks very much,
Steven



More information about the CMake mailing list