Normally you should simply extend CMAKE_CXX_SOURCE_FILE_EXTENSIONS . This will help if you have many files with unknown file extensions.
But this variable is not cached - for example, CMAKE_CXX_FLAGS - so the following code in CMakeCXXCompiler.cmake.in will always overwrite / hide everything that you set:
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
I believe that this is not a caching error in CMake , but until this changes, I was looking for a workaround considering the following
- Normally you do not want to modify the files in your CMake installation.
- This will have no effect if you change
CMAKE_CXX_SOURCE_FILE_EXTENSIONS after project() / enable_language() (as discussed here ).
I successfully tested the following using one of the hooks / configuration variables inside CMakeCXXCompiler.cmake.in :
cmake_minimum_required(VERSION 2.8) set(CMAKE_CXX_SYSROOT_FLAG_CODE "list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS pde)") project(RPiCopter CXX) message("CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS}") add_executable(RPiCopter tinycopter.pde)
Florian Jun 02 '15 at 8:40 2015-06-02 08:40
source share