我正在尝试为我的项目创建一个 NewConfiguration:
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 2.8.4 为 VS2008 创建了 6 或 7 个新配置(现在是 2.8.5 发布的几天甚至几小时),用于简单的 hello world 项目。
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 错误 - 对此一无所知)。
但是,无论如何,经过 2 或 3
cmake ..
有用!!!!
关于visual-studio - 如何使用 CMake 创建新配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4212945/