[CMake] Add header files to project when there are no cpp files

David Doria daviddoria at gmail.com
Tue Aug 28 10:01:32 EDT 2012


I have just started using QtCreator. When I open a CMake project in
QtCreator, all of my cpp files mentioned in the CMakeLists.txt are added to
the "project". However, my headers (.h) and template implementation (.hpp)
are not added to the project (I believe this is the same behavior as Visual
Studio). I have seen this thread:
http://www.cmake.org/pipermail/cmake/2003-January/003274.html that says you
can simply add the headers to the add_executable/add_library line:

add_library(MyProject main.cpp MyClass.h MyClass.cpp)

This works fine. However, I have several projects that are "template only"
(there are no .cpp files), and I essentially only use them as git
submodules, so there are actually no driver cpp files either (the drivers
are in the project that includes the submodule). That is, the complete
directory looks like this:

MyProject/CMakeLists.txt
MyProject/MyProject.h

Because of this, I can't use add_executable or add_library at all. Is there
another command that can get CMake to add these files to the project?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120828/2f4b931d/attachment.htm>


More information about the CMake mailing list