CMake seems to make assumptions about files - specifically, what to compile source files with - based on their extension. While this can sometimes be manually overwritten using compiler flags (e.g. -x C++
for .c
file), that's dependent on specific compilers and seems like circumventing the problem.
Is there a way to tell CMake "treat a file with extension .ext1
as though it had extension .ext2
"? I can't seem to find something like that in the CMake documentation.
You can set the LANGUAGE
of a file by using
`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.