How to create a new configuration using CMake

I am trying to create a NewConfiguration for my project:

set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug;NewConfiguration" CACHE STRING "Configurations" FORCE) 

But when I start CMake, I have a few errors:

 CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. Missing variable is: CMAKE_SHARED_LINKER_FLAGS_NEWCONFIGURATION CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. Missing variable is: CMAKE_CXX_FLAGS_NEWCONFIGURATION 

I think something is missing ...

I also took advantage of the CMake FAQ:

  if(CMAKE_CONFIGURATION_TYPES) set(CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo Debug NewConfiguration) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Reset the configurations to what we need" FORCE) endif() 

But the same mistakes ...

EDIT:

If I do this:

  SET( CMAKE_CXX_FLAGS_PLAYERVIEWER "-Wall -Wabi" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE ) SET( CMAKE_C_FLAGS_PLAYERVIEWER "-Wall -pedantic" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE ) SET( CMAKE_EXE_LINKER_FLAGS_PLAYERVIEWER "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE ) SET( CMAKE_SHARED_LINKER_FLAGS_PLAYERVIEWER "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE ) set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug;PlayerViewer" CACHE STRING "Configurations" FORCE) 

Creates a new configuration, but I cannot compile it. I think the flags are wrong. I am using Visual Studio 2008.

Thanks:)

+4
source share
2 answers

I just created 6 or 7 new configurations for VS2008 with cmake 2.8.4 (now it's days or even hours since version 2.8.5) for a simple hi-world project.

 The reason why your attemps failed what flags are inccorect eg they must be /MDd no -MDd You notation will work for GCC based compilers, not for VS. 

I recommend that you set the closest flags and change them, and then

 set(CMAKE_CXX_FLAGS_FOO ${CMAKE_CXX_FLAGS_DEBUG}) # .. modifiy it - add or remove flags 

I also noticed that sometimes cmake doesn’t actually write to .sln, or it does not always reboot (well, I am running win7 on VirualBox, maybe this is the source of the problems).

I did the following:

 file(GLOB WILL_REMOVE "${CMAKE_CURRENT_BINARY_DIR}/*.vcproj") execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${WILL_REMOVE}) file(GLOB WILL_REMOVE "${CMAKE_CURRENT_BINARY_DIR}/*.sln") execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${WILL_REMOVE}) file(GLOB WILL_REMOVE "${CMAKE_CURRENT_BINARY_DIR}/*.user") execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${WILL_REMOVE}) 

at least it reloads files :)

however, sometimes I need to run cmake 2 or 3 times to see the new configuration in visual studio (maybe a virtual box, cmake, or a visual studio error - they have no idea about this).

But, in any case, after 2 or 3

 cmake .. 

It works!!!!

+2
source

Despite CMake's frequently asked questions, there seems to be something else not done for this function request. There is an open problem for him:

http://www.cmake.org/Bug/view.php?id=5811

Watch that the error in the CMake error debugger should be notified as things get updated.

+1
source

All Articles