[CMake] Compile all .c source files with the CXX compiler
Mathieu Malaterre
mathieu.malaterre at gmail.com
Tue Mar 31 12:12:48 EDT 2009
On Tue, Mar 31, 2009 at 5:53 PM, Alexandre Feblot
<Alexandre.Feblot at thomsonreuters.com> wrote:
> Well, I indeed found this to work, but my project has about 20000 c files.
Nice ! It this project called GNU/Linux ? ;)
> Alin, forcing CC to a C++ compiler is not an option either, as I also have a couple of libs which must be compiled with a C-ansi compiler.
>
>
> I found that I could get the correct behaviour by modifying the value of CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS in the generated files <build_dir>/CMakeFiles/Cmake{CC,CXX}Compiler.cmake
This is bad habit to manually trick internal cmake cache variable...
> BUT:
> These files are read when calling 'project()'. They set the initial value for CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS, which then seem to be used once for all by cmake. Any later attempt to change them has no effect.
>
> So, should these CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS variables be considerered as read-only?
> Is this a bug?
No, it's a feature.
Simply pass the output of file(glob_recurse ... ) to
SET_SOURCE_FILES_PROPERTIES( file1.c file2.c file3.c PROPERTIES
LANGUAGE CXX ). Or do it recursively if there is some limit to the
number of filename you can specify...
$ cmake --help-command FILE
2cts
--
Mathieu
More information about the CMake
mailing list