CMake, QtCreator, and Header Files

This is not exactly a compilation issue, but a much more important visual issue ...

I have a project created using CMake (this is not a Qt project). When I open this project using QtCreator, it perfectly finds all related files, and the files in the project browser are in alphabetical order, for example:

Project
 + abc.cpp
 + abc.h
 + def.cpp
 + def.h

However, if I work with QtCreator and a QMake-based project, the headers and sources are perfectly separated, for example:

Project
 + Headers
 |  + abc.h
 |  + def.h
 + Sources 
    + abc.cpp
    + def.cpp

Question: How to achieve this separation of headers and sources using Qt Creator? I tried with SOURCE_GROUP("Headers" FILES abc.h def.h), and although this works (to some extent) with Visual Studio, it does not work with Qt Creator. Any other tips?

+4
1

, CMake, - :

ADD_CUSTOM_COMMAND(OUTPUT
    ${CMAKE_BINARY_DIR}/include/res.h ${CMAKE_BINARY_DIR}/Sources/abc.cpp
    COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/Headers/abc.h
DEPENDS ${CMAKE_SOURCE_DIR}/resources/res.gen)

:

, Qt Creator, , . Qt Creator :

File > New File or Project > Files and Classes > C++ :

:

  • ++: , .
  • ++: ​​ .
  • ++: ​​ .

, , , , .

+2

Source: https://habr.com/ru/post/1530960/


All Articles