English 中文(简体)
CMake:为不同建筑目标确定联系名录和图书馆
原标题:CMake: defining link directories and libraries for different build targets

我这里有一个2008年项目。 其项目档案由CMake生成。 我想要做的是,独立确定Debug和释放目标的图书馆和图书馆名录,即释放目标的校准和降标的校准。

到目前为止,我不知道如何做到这一点。 我知道,我可以用CMAKE_CXX_FLAGS_DEBUG<>/strong>和界定不同的汇编者论点,例如(或称“建筑目标”),但我不知道如何将二者与校准联系起来。

一位同事用所有定义编造了CMakeList案,与他一起尝试。

IF( CMAKE_BUILD_TYPE MATCHES "Debug" )

例如,这只是工作。 据一些CMake wiki称,变数CMAKE_BUILD_TYPE在配置时间没有界定,这当然取决于你的工作目标。

目前,我处于死灰色,希望任何方面或方向:

最佳回答

有一个<代码>target_link_libraries的备选办法,有助于您做到这一点。 但是,你们需要把你的图书馆名称扩大到完全的道路。

target_link_libraries(foo
  debug c:/path/to/debug/lib/blah.lib 
  optimized c:/path/to/optimized/lib/blah.lib)

如果贵图书馆所在地点的名称是CMake(Debug/MinSizeRel/RelWithDebInfo/Release),你可以使用VS$(ConfigurationName):

link_directories(c:/path/to/all/libs/$(ConfigurationName)/)

Beware, $(ConfigurationName) is not a厘米变数:在建筑/连接阶段,该系统只能由VS扩大。

问题回答
include_directories("${DEVINSTPREFIX}$<$<CONFIG:Debug>:/debug>/include")
link_directories("${DEVINSTPREFIX}$<$<CONFIG:Debug>:/debug>/lib")

include_directories("${DEVINSTPREFIX}$<$<CONFIG:Release>:/release>/include")
link_directories("${DEVINSTPREFIX}$<$<CONFIG:Release>:/release>/lib")

假设:

  • prefix/ contains mixed stuff where you use find_package to select the correct stuff.
  • prefix/debug contains "manually" configured debug builds
  • prefix/release contains "manually" configured release builds.

你可以简单地援引已经确定的组合:

cmake -DCMAKE_BUILD_TYPE="Debug"

或我做的是规定指挥线上的联系和平台,然后手工调整配置类型:

cmake -dMyConfigType="DebugStaticX86"

#CMakeLists.txt
if( ${MyConfigType} STREQUAL "DebugStaticX86" )
  set( CMAKE_BUILD_TYPE Debug )
  set( MyLinkType Static )
  set( MyPlatform x86 )
  #now include other files that set the actual compile/link options
  #depending on values of MyLinkType and MyPlatform
  ....
endif




相关问题
How to speed up Visual Studio 2008? Add more resources?

I m using Visual Studio 2008 (with the latest service pack) I also have ReSharper 4.5 installed. ReSharper Code analysis/ scan is turned off. OS: Windows 7 Enterprise Edition It takes me a long time ...

Trouble with VS.PHP installing it s own Apache server

I tried installing VS.PHP some time ago. I was intent on seeing how it works with my current setup. I immediately encountered trouble: none of my sites wanted to render. On windows, I m using WAMP ...

Jquery and Intellisense in VS 2008 with hotfix and SP1

I followed Scott Guthrie s instructions as outlined at http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx but no avail: intellisense still doesn t work. Any tips?

Fixing "error C2065: undeclared identifier"

First off, I m completely out of my depth here. So the question might be the wrong one to ask, but here goes... As per the accepted answer to this question, I m trying to compile the bindings for the ...

View whitespace in VS2008

After Jeph most recent post: http://www.codinghorror.com/blog/archives/001310.html, I thought to myself it would be fun to see if any of my code has those trailing whitespaces. So I open Visual ...