You should not override the compiler for this purpose. If you really need to compile your C files as C++ then you should teach cmake that your files belong to C++ language:
set_source_files_properties(filename.c PROPERTIES LANGUAGE CXX )
More Related Contents:
- GCC dump preprocessor defines
- LD_LIBRARY_PATH vs LIBRARY_PATH
- How to see which flags -march=native will activate?
- How to specify new GCC path for CMake
- How do I check if gcc is performing tail-recursion optimization?
- Unable to specify the compiler with CMake
- OS X 10.9 gcc links to clang
- What’s the difference between gcc and g++/gcc-c++?
- Linking with dynamic library with dependencies
- How do I force cmake to include “-pthread” option during compilation?
- gcc/g++ option to place all object files into separate directory
- How do I set up CLion to compile and run?
- CMake: The C Compiler is not able to compile a simple test program
- How to set the LDFLAGS in CMakeLists.txt?
- Why gcc 4.1 + gcov reports 100% branch coverage and newer (4.4, 4.6, 4.8) reports 50% for “p = new class;” line?
- Makefile removes object files for no reason
- CMake and Static Linking
- CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
- how to install gcc 4.9.2 on RHEL 7.4
- combine two GCC compiled .o object files into a third .o file
- Compiling problems: cannot find crt1.o
- Prefetching Examples?
- How to stop MinGW and MSYS from mangling path names given at the command line
- constexpr initializing static member using static function
- request for member `…’ is ambiguous in g++
- How to fix linker error “cannot find crt1.o”?
- The proper way of forcing a 32-bit compile using CMake
- -static option for gcc?
- How to specify an individual register as constraint in ARM GCC inline assembly?
- what is the order of source operands in AT&T syntax compared to Intel syntax?