I am developing a C project. I have a library with .cpp files (No other option). But my project has most of .c files. Finally, I have to connect the different file types.
Whenever I build a project, I get compilation-level errors. My c project is not recognizing C++ keywords like class, virtual, new etc.
Are there any commands or arguments from CMake to use .cpp files in the C project?
Can I mention the C++ and c compilers to build respective files in a project?
Do you have any solutions for this kind of problematic situation from CMake’s side?
Optional. Can also be specified without LANGUAGES keyword per the first, short signature.
and
By default C and CXX are enabled if no language options are given.
I had the opposite problem; a C++ project was not compiling a C file. In that case, I had LANGUAGES CXX (only). Adding C to the list fixed the problem.
Your issue doesn’t have to remain unsolved, but if there is some reason my solution won’t work, you’ll need to give us more information.