Nadir SOUALEM wrote:
Robert Blake wrote:
I'm converting a large mixed C++/C cmake application to C++. The project has many ".c" files that I would like to compile with the C++ compiler instead of the C compiler. Does anyone know the proper way to do this in CMake?

Things I've tried:
1.) Changing CMAKE_C_COMPILER myself: Usually CMake doesn't let you change CMAKE_C_COMPILER, but there are ways around that. This way feels like a hack. The output while compiling still says "Compiling C". In addition, forcing CMAKE_*_COMPILER to change makes it very difficult to run plane cmake on Unix machines where curses is not installed.

2.) Tell CMake that ".c" files are in the CXX language:  I've tried
PROJECT(Blah CXX)
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS c)

When I run CMake on my project with these changes, I get errors like:

CMake Error: Cannot determine link language for target "foobar"

...for all my targets that depend only on .c files.

Help!
Rob
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Try

SET_SOURCE_FILES_PROPERTIES( file1.c file2.c PROPERTIES LANGUAGE CXX )


For sure !!! CXX not C !!! :-)

--
Nadir SOUALEM
Ingénieur INRIA - Équipe SAGE


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to