c++ - 我如何 "override"CMake中文件的扩展类型

标签 c++ cmake file-extension file-type

CMake 似乎根据文件的扩展名对文件做出假设——具体来说,用什么来编译源文件。虽然这有时可以使用编译器标志手动覆盖(例如 .c 文件的 -x C++),但这取决于特定的编译器并且似乎可以规避问题。

有没有办法告诉 CMake“将扩展名为 .ext1 的文件当作扩展名为 .ext2 的文件”?我似乎无法在 CMake 文档中找到类似的内容。

最佳答案

您可以设置 LANGUAGE通过使用一个文件 `set_source_files_properties'

LANGUAGE

What programming language is the file.

A property that can be set to indicate what programming language the source file is. If it is not set the language is determined based on the file extension. Typical values are CXX (i.e. C++), C, CSharp, CUDA, Fortran, and ASM. Setting this property for a file means this file will be compiled. Do not set this for headers or files that should not be compiled.

关于c++ - 我如何 "override"CMake中文件的扩展类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59348579/

相关文章:

c++ - 一个通用的 STLish contains()

c++ - 如何在自定义类实例上执行 cmath 函数?

c# - C#/C++ 之间的 Replace() 差异

c++ - 除了静态库本身之外,停止 cmake target_link_libraries 链接静态库的两个目标文件

c++ - 在 cmake C++ 项目中使用 mongodb cxx 驱动程序

php - 如何在 PHP 中获取文件的扩展名?

c++ - 如何为 size_t 以外的返回类型专门化 std::hash 调用运算符?

cmake错误:Error in configuration files.项目文件可能无效

c# - 查找图像类型(gif、bmp、jpg 等)的预览处理程序 GUID

c++ - 我为我的 C++ 程序使用哪个文件扩展名重要吗?