C ++ / CLI和CMake [英] C++/CLI and CMake

查看:229
本文介绍了C ++ / CLI和CMake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用cmake设置C ++ / CLI项目。我已经在Visual Studio 2010上实现了成功,但是现在我正在使用一个需要Visual Studio 2008的旧解决方案。在Visual Studio 2010中,这样设置我的cmake就足够了:

I am trying to set up a C++/CLI project using cmake. I have had success doing this with visual studio 2010, but I am now working with a legacy solution that requires visual studio 2008. In visual studio 2010, it is enough to set up my cmake like this:

set_target_properties(${PROJECT_NAME} PROPERTIES VS_DOTNET_REFERENCES "${CMAKE_CURRENT_SOURCE_DIR}/../OrionMaster/3rdParty/GMap.NET.Core.dll;System;System.Core;System.Data;System.Drawing;System.Xml;WindowsBase")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/clr /EHa")
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")

if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1")
   string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif()

if(CMAKE_CXX_FLAGS MATCHES "/EHsc")
   string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()

然后我在Visual Studio 2010下检查项目时,可以看到所有引用和公共语言运行时支持已打开。当我在Visual Studio 2008中尝试该程序时,我看不到任何引用,并且该项目被设置为无公共语言运行时支持。如果再查看编译器选项,则可以看到/ clr正在传递给编译器。但是我仍然遇到很多编译器错误,可能是因为它缺少参考。有人知道正确设置此方法的方法吗?

When I then examine the project under visual studio 2010, I can see all the references and "Common Language Runtime Support" is turned on. When I try it in visual studio 2008, I don't see any references, and the project is set to "No Common Language Runtime Support" If i then look at the compiler options, I can see /clr is being passed to the compiler. However I still get a lot of compiler errors, probably because it is lacking references. Does anyone know a way to set this up properly?

推荐答案

对VS_DOTNET_REFERENCES属性的唯一真实源代码引用位于CMake源文件Source / cmVisualStudio10TargetGenerator.cxx。

The only "real" source code reference to the VS_DOTNET_REFERENCES property is in the CMake source file Source/cmVisualStudio10TargetGenerator.cxx.

实际上意味着什么:VS_DOTNET_REFERENCES仅为Visual Studio 2010的CMake生成器以及任何继承的生成器实现从中。 (现在存在于VS 2012和2013的最新CMake版本中……)

What this means in practice: VS_DOTNET_REFERENCES is only implemented for the CMake generator for Visual Studio 2010 and any of the generators that inherit from it. (Which now exist in the latest CMake version for VS 2012 and 2013...)

修改CMake源代码以支持Visual Studio早期版本的此属性可能,但是目前尚待完成。

Modifying the CMake source code to support this property for earlier versions of Visual Studio is probably possible, but it is work yet to be done at this point.

这篇关于C ++ / CLI和CMake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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