CMake auto add classes files #626
-
Hi! is there a way to automatically add and I'm thinking of dividing But it's too much hassle to go to the cmake file and add every file If there is nothing like this It's okay because I've got a workaround for this in C#
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Yes, cmake support it |
Beta Was this translation helpful? Give feedback.
-
Be careful when using GLOB_RECURSE, because if I recall correctly, it won't detect new files added to your project, and would require the actual CMakeLists.txt to be modified in some way (or simply last modified date changed) in order for it to do a re-build. Read up here for more info: https://stackoverflow.com/questions/1027247/is-it-better-to-specify-source-files-with-glob-or-each-file-individually-in-cmak/1060061#1060061 Many other posts online about it too. Also, you can add a separate CMakeLists.txt in each sub-folder, and reference them from the parent folder etc. That way it keeps your root CMakeLists.txt clean. It may seem like a hassle to add each new source file into CMakeLists.txt manually, but it only ever needs to be done once per file, and you never have to deal with it for that file again. Just as an example, my largest project has over 900 source files and 36 folders just in the "Classes" folder alone, and they're all listed explicitly in a number of CMakeLists.txt files, without any usage of GLOB etc. It takes a few seconds to add the cpp/h file reference into whichever CMakeLists.txt it belongs in, and that's it, it's done. |
Beta Was this translation helpful? Give feedback.
Yes, cmake support it