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.

0
2 comments
Avatar
Permanently deleted user

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.

0

Yes, you can add the following line to your CMakeLists:

file(GLOB_RECURSE headers "*.h")

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-270Feel free to comment or upvote.

0

Please sign in to leave a comment.