Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 如何使用CMake创建新配置_Visual Studio_Visual Studio 2008_Visual C++_Cmake - Fatal编程技术网

Visual studio 如何使用CMake创建新配置

Visual studio 如何使用CMake创建新配置,visual-studio,visual-studio-2008,visual-c++,cmake,Visual Studio,Visual Studio 2008,Visual C++,Cmake,我正在尝试为我的项目创建新配置: set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug;NewConfiguration" CACHE STRING "Configurations" FORCE) 但当我运行CMake时,我有多个错误: CMake Error: Error required internal CMake variable not set, cmake may be not be built correctl

我正在尝试为我的项目创建新配置:

set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug;NewConfiguration" CACHE STRING "Configurations" FORCE)
但当我运行CMake时,我有多个错误:

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
我想我错过了什么

我还关注了CMake常见问题:

 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()
但同样的错误

编辑:

如果我这样做:

    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)
它创建了新的配置,但我无法编译。我认为旗子不对。我正在使用Visual Studio 2008。


谢谢:)

尽管有CMake常见问题解答,但此功能请求似乎仍有一些未实现的地方。甚至还有一个悬而未决的问题:


在CMake bug跟踪器中监视该bug,以便在更新时得到通知。

我刚刚为简单的hello world项目创建了6到7个新配置,使用CMake 2.8.4(现在距离2.8.5版本还有几天甚至几小时)

The reason why your attemps failed what flags are  inccorect e.g. they must be /MDd no -MDd
You notation will work for GCC based compilers, not for VS.
我建议您设置最接近的标志,然后对其进行修改

set(CMAKE_CXX_FLAGS_FOO ${CMAKE_CXX_FLAGS_DEBUG})
# .. modifiy it - add or remove flags
我还注意到,cmake有时实际上并不写入.sln,或者它并不总是被重新加载(我在VirualBox上运行win7,可能这是问题的根源)

我所做的如下-

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})
至少它会重新加载文件:)

然而,有时我需要运行cmake 2到3次,才能在visual studio中看到新的配置(可以是虚拟盒、cmake或visual studio bug,我对此一无所知)

但是,不管怎么说,两三次之后

cmake ..
它有效

“多次运行…”可能是visual studio的问题,而不是CMake的问题。基本上我的经验是,在VS2005和2008中(还没有使用2010),重新加载项目通常不起作用,所以我总是关闭解决方案并重新打开它。