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/