问题
I'm using cmake, and I just added new source files and I want to include that new source files in the cmake generated makefiles to include in the building. I tried rebuild_cache but nothing happens.
Thanks!
回答1:
It depends how your cmake file was built. If you use GLOB, you must run cmake manually any time you add or remove a source file. If you explicitly list your source files, just run make again. CMake will detect the changed CMakeLists.text.
CMake suggests the latter for this reason:
We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.
CMake documentation
来源:https://stackoverflow.com/questions/19351489/in-cmake-how-to-update-the-makefiles-with-new-source-files-without-cleaning-the