CMAKE vars问题 [英] Problems with CMAKE vars
问题描述
我正在使用CMAKE生成VS2008 SLN / VCPROJ文件,但一些简单的操作似乎无效:
I'm using CMAKE to generate VS2008 SLN/VCPROJ files but a few simple things don't appear to work:
1)工作正常: INCLUDE_DIRECTORIES($ ENV {MCS_OGRE_HOME} / OgreMain / include)
但这不是,我的VC ++其他include dirs完全可用我这样做时搞砸了,括号和各种各样的东西都在浮动:
But this doesn't, my VC++ additional include dirs gets totally screwed up when I do this, brackets and all kinds floating around:
SET (OGRE_PATH $ENV{OGRE_HOME}/OgreMain)
INCLUDE_DIRECTORIES (${OGRE_PATH}/include)
2)工作原理: target_link_libraries(debug $ ENV {OGRE_HOME} /lib/OgreMainStatic_d.lib)
但这不是,库路径不是t在VC ++中的库路径下显示:
But this doesn't, the library path isn't shown under the library paths in VC++:
LINK_DIRECTORIES($ENV{OGRE_HOME}/lib/)
target_link_libraries( debug OgreMainStatic_d.lib )
我认为这一定很简单吗?
I figure it must be something simple?
推荐答案
而不是:
set(OGRE_PATH $ENV{OGRE_HOME}/OgreMain)
使用:
string(REPLACE "\\" "/" OGRE_PATH "$ENV{OGRE_HOME}/OgreMain")
CMake在所有平台上都使用 /作为路径分隔符。
CMake uses all "/" for path separators on all platforms.
此外,建议使用完整路径名称(带有 /分隔符)作为target_link_libraries的库参数,而不是指定link_directories。然后,CMake提取所有链接到的库,并找出在所有平台上传递链接器标志的正确顺序。
Also, it's recommended to use full path names (with "/" separators) as library arguments to target_link_libraries rather than specifying link_directories. CMake then takes the whole set of libraries linked to and figures out the right order to pass linker flags on all platforms.
另外一条评论:看来您有一个库或您对target_link_libraries的调用中名为 debug的可执行文件。真的吗?还是您错过了此处发布的问题的第一个论点?
One more comment: looks like you have a library or an executable named "debug" from your call to target_link_libraries. Is that true? Or are you missing the first argument in the question posted here?
应该是这样的:
target_link_libraries(mylib
debug /path/to/DebugLib.lib
optimized /path/to/ReleaseLib.lib)
这篇关于CMAKE vars问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!