How to include existing files in a project?
Answered
Hi
Lets say I have an existing C++ project with several hundred files. How to I add these files to the CLion project? Do I have to manually add each file to CMakeList? That would really be a pitty! Thanks.
Please sign in to leave a comment.
You can use Cmake GLOB functionality to obtain all necessary for compilation files. But it's not recommended to use this function since when you'll add new file, Cmake project needs to be reloaded.
Other way is to list needed files using e.g. python script and add it to CMakeList.
Yes, you can add the following line to your CMakeLists:
and then add ${headers} variable to your target.
Also we have an issue about automatically adding headers without sources in the CMakeLists.txt in our tracker: https://youtrack.jetbrains.com/issue/CPP-270. Feel free to comment or upvote.