I have a file named foo.bar
. I want to compile it once as a C++ file, into a mycpplib
library target, and once as a C file, into a myclib
target; and I want to do it in the same build, with the same CMakeLists.txt
.
Now, I know I can arbitrarily set a source file's associated language, like so:
set_source_files_properties(foo.bar PROPERTIES LANGUAGE C)
but this doesn't look like it'll help in my case. Is there something I can do at the CMake level?
Notes:
- Related question: The single-arbitrary-language case.
- There are non-CMake solutions to this, e.g. duplicating the file; using a symlink with a different name; having a file with
#include "otherfile"
as its contents etc.