力CMake的使用C ++编译器的C文件与Visual Studio [英] Force CMake to use C++ compiler for C files with Visual Studio

查看:176
本文介绍了力CMake的使用C ++编译器的C文件与Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经生成的.h和必须被编译成C ++和Visual Studio文件.c文件。
我听说我可以做类似 set_source_files_properties($ {}源属性的语言CXX)。与此同时,我已阅读,我不应该这样做,因为它应该具有异国情调的情况下,只能使用。

I have generated .h and .c files which must be compiled as C++ files with Visual Studio. I heard I could do something like set_source_files_properties( ${SOURCES} PROPERTIES LANGUAGE "CXX" ). In parallel, I have read that I should not do that as it should used only in exotic situations.

那么,什么是强制CMake的,以产生编译C文件作为C ++文件VS项目的最佳方法是什么?

PS:重命名生成的文件是不是一种选择

PS: renaming the generated files is not an option.

推荐答案

我一直在使用各个属性(最有可能的,你还可以设置目录属性 - 但这不是因为细粒度)没有任何问题。不是,虽然设置语言(但它为什么应该是有什么不同?):

I have been using the individual properties (most likely you can also set directory properties - but this is not as fine grained) without any problems. Not for setting the language though (but why should it be any different?):

SET_SOURCE_FILES_PROPERTIES( file1.c PROPERTIES LANGUAGE CXX )

这工作Linux和Windows下似乎并没有给带来任何问题。你有什么听说过,让你还犹豫什么?

This works under Linux and Windows and doesn't seem to pose any problems. What have you heard that makes you hesitate?

这篇关于力CMake的使用C ++编译器的C文件与Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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