如何创建一个新的配置与CMake [英] How to create a new configuration with CMake

查看:171
本文介绍了如何创建一个新的配置与CMake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的项目创建一个NewConfiguration:

  set(CMAKE_CONFIGURATION_TYPESRelease; RelWithDebInfo; Debug; NewConfiguration CACHE STRINGConfigurationsFORCE)

但是当我运行CMake时, p>

  CMake错误:需要内部CMake变量未设置,cmake可能不是
正确构建。
缺少变量是:
CMAKE_SHARED_LINKER_FLAGS_NEWCONFIGURATION
CMake错误:需要内部CMake变量未设置,cmake可能不是
正确构建。
缺少变量是:
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
将配置重置为我们需要的配置
FORCE)
endif()

但同样的错误...


$ b b

EDIT:



如果我这样做:

  (CMAKE_CXX_FLAGS_PLAYERVIEWER-Wall -WabiCACHE STRINGC ++编译器在维护程序构建期间使用的标志。FORCE)
SET(CMAKE_C_FLAGS_PLAYERVIEWER-Wall -pedanticCACHE STRINGC编译器在维护程序构建期间使用的标志。 FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_PLAYERVIEWER-Wl, - 警告未解析的符号, - 警告一次CACHE STRING用于在维护程序构建期间链接二进制文件的标志FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_PLAYERVIEWER -Wl, - warn-unresolved-symbols, - warn-onceCACHE STRING共享库链接器在维护程序生成期间使用的标志FORCE)


设置(CMAKE_CONFIGURATION_TYPES Release; RelWithDebInfo; Debug; PlayerViewerCACHE STRINGConfigurationsFORCE)

,但我无法编译。我认为国旗是不正确的。 Visual Studio 2008



谢谢:)

方案

我刚刚为VS2008创建了6或7个新配置,使用cmake 2.8.4(现在从2.8.5版本开始,甚至是几天甚至几个小时)。

 你的attemps失败的原因是什么标志是inccorect eg它们必须是/ MDd否-MDd 
您的符号将适用于基于GCC的编译器,而不是VS。

我建议你设置最近的标志并修改它

  set(CMAKE_CXX_FLAGS_FOO $ {CMAKE_CXX_FLAGS_DEBUG})
#.. modifiy it - 添加或删除标志



也注意到cmake有时不会实际写入.sln或者不总是重新加载(好,我运行win7上的VirualBox也许是源

  



文件(GLOB WILL_REMOVE$ {CMAKE_CURRENT_BINARY_DIR} / * .vcproj)
execute_process(COMMAND $ {CMAKE_COMMAND} -E remove -f $ {WILL_REMOVE})

文件(GLOB WILL_REMOVE$ {CMAKE_CURRENT_BINARY_DIR} / *。sln)
execute_process(COMMAND $ {CMAKE_COMMAND} -E remove -f $ {WILL_REMOVE})

文件(GLOB WILL_REMOVE$ {CMAKE_CURRENT_BINARY_DIR} / *。 user)
execute_process(COMMAND $ {CMAKE_COMMAND} -E remove -f $ {WILL_REMOVE})

至少它重新加载文件:)



然而,有时我需要运行cmake 2或3次在visual studio看到新的配置



但是,无论如何,在2或3之后

  cmake .. 

It WORKS !!!!


I'm trying to create a NewConfiguration for my project:

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

But when I run CMake, I have multiple 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 I'm missing something...

I also followed 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 same errors...

EDIT:

If I do:

    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)

It creates the new configuration, but I can not compile. I think flags are not correct. I am using Visual Studio 2008.

Thank you :)

解决方案

I've just created 6 or 7 new configurations for VS2008 with cmake 2.8.4 (now it is days or even hours from 2.8.5 release) for simple hello world project.

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.

What I recommend you is to get closest flags set and modify it then

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

also i noticed that cmake sometimes does not actually write to .sln or it is not always reloaded (well, I am running win7 on VirualBox maybe it is source of issues).

what i did is 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 new configuration at visual studio (can be virtual box, cmake or visual studio bug - have no idea about it).

But, anyway, after 2 or 3

cmake ..

It WORKS!!!!

这篇关于如何创建一个新的配置与CMake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆