[CMake] Find out which build type is currently used

Michael Wild themiwi at gmail.com
Thu Jul 22 04:00:52 EDT 2010


On 22. Jul, 2010, at 9:55 , norulez wrote:

> I want to set the debug prefix on windows when I build in debug mode, so I check if Debug is in CMAKE_BUILD_TYPE.
> I use both, Visual Studio and the MinGW compiler
> 
> Am 22.07.2010 um 08:53 schrieb Michael Wild <themiwi at gmail.com>:
> 
>> 
>> On 22. Jul, 2010, at 8:38 , norulez wrote:
>> 
>>> How can I find out which build type is used? Because if I didn't define CMAKE_BUILD_TYPE, this variable is uninitialized.
>> 
>> That depends. For single-configuration generators (i.e. Makefile based), the user has to set CMAKE_BUILD_TYPE. If it is empty, no special configuration options will be used. For multi-configuration generators (VisualStudio, Xcode, etc.), you simply can't know at CMake-time, since the user can change the selection before hitting the build button.
>> 
>> What is it that you want to achieve? Probably there's a better way...
>> 
>> Michael
>> 

Well, if you set the variables CMAKE_<CONFIG>_POSTFIX or set the target property <CONFI>_POSTFIX (where <CONFIG> is DEBUG, RELEASE, etc.), CMake does everything automagically. You don't have to know whether in which configuration you are building, because CMake is going to select the appropriate suffix by itself.


HTH

Michael



More information about the CMake mailing list