How to add in a CMake project a global file extension (*.pde) to GCC which is treated like C++ code

后端 未结 4 651
陌清茗
陌清茗 2020-12-18 03:40

I have a very simple CMake script. Unfortunately, the project uses a *.pde file which is plain C++ or C code.

CMake is working with any file ending, but I get a comp

4条回答
  •  青春惊慌失措
    2020-12-18 03:53

    You should be able to use set_source_files_properties along with the LANGUAGE property to mark the file(s) as C++ sources:

    set_source_files_properties(${TheFiles} PROPERTIES LANGUAGE CXX)
    

    As @steveire pointed out in his own answer, this bug will require something like the following workaround:

    set_source_files_properties(${TheFiles} PROPERTIES LANGUAGE CXX)
    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
      add_definitions("-x c++")
    endif()
    

提交回复
热议问题