[CMake] Custom configuration types in Visual Studio

Michael Hertling mhertling at online.de
Fri Jan 13 10:22:52 EST 2012


On 01/12/2012 10:23 PM, Robert Dailey wrote:
> I see there is documentation for this but it doesn't have an implementation
> for VS generators:
> http://www.cmake.org/Bug/view.php?id=5811
> 
> Any status updates on this bug? I'd like to be able to create my own debug
> configuration called DebugStatic that uses the /MTd flag in all projects to
> link statically against the Microsoft libraries such as CRT.
> 
> Any help?

Look at the following exemplary project:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(P C)
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} DebugStatic
    CACHE STRING "" FORCE)
SET(CMAKE_C_FLAGS_DEBUGSTATIC "/MTd"
    CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUGSTATIC ""
    CACHE STRING "" FORCE)
FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
ADD_EXECUTABLE(main main.c)

After "cmake <srcdir>" and a subsequent "cmake ." from within the build
directory, I can see the DebugStatic configuration appear in the VS IDE
when the generated solution is opened. Is this what you intend?

However, I do not see DebugStatic when I open the solution right after
the initial configuration, i.e. without the reconfiguration step. Can
you confirm this behavior? Does anybody know why the reconfiguration
is necessary to make the custom configuration appear? This is with
CMake 2.8.7 and VS 2008.

Regards,

Michael


More information about the CMake mailing list