Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ CMake (add non-built files)

Tags:

c++

cmake

I am using cmake to configure my project. I visualize project's files using qtcreator which read the CMakeLists.txt. I have a few text files (non-code: config files, log, ..) and I would like to add them to my cmake project without (of course) compiling/linking them. Is it possible ? The main goal it to open them automatically in the tree of my project with qtcreator and edit them ... Thanks for help.

like image 202
Eric Avatar asked Jun 10 '12 21:06

Eric


2 Answers

You should be able to just add them to your list of sources in whichever add_executable or add_library call is appropriate and they will appear in the IDE.

I believe CMake uses the files' extensions to determine if they are actual source files, so if yours have extensions like ".txt" or ".log" they won't be compiled.

like image 53
Fraser Avatar answered Oct 11 '22 03:10

Fraser


Instead of adding files which are not directly needed to build your library or executable, you can create a custom target to make these files appear in you IDE:

add_custom_target(myapp-doc
    SOURCES readme.txt)
like image 4
Florian Avatar answered Oct 11 '22 04:10

Florian