1

I have a cmake build script which collects all the files in my eclipse project source directory. The problem is, that if I add a file, I should rerun cmake to collect this file and add it to the build scripts. Is there a possibility to trigger this automatically from eclipse when adding a file?

thi gg
  • 1,969
  • 2
  • 22
  • 47
  • "It is tempting to use this command to avoid writing the list of source files for a library or executable target. While this seems to work, there is no way for CMake to generate a build system that knows when a new source file has been added. Normally the generated build system knows when it needs to rerun CMake because the CMakeLists.txt file is modified to add a new source. When the source is just added to the directory without modifying this file, one would have to manually rerun CMake to generate a build system incorporating the new file."-CMake documentation – IdeaHat Nov 18 '14 at 17:51
  • Personally, I think its better to use the tool correctly than to try and hack your personal dev environment to support explicitly suggested against usage. – IdeaHat Nov 18 '14 at 17:54
  • Yeah my problem is that this was the only way i found to use ninja as build system – thi gg Nov 18 '14 at 21:34
  • Since I've done it before, I assure you that ninja will still work if you include all the source in the CMakeLists.txt rather than as a generated list. – IdeaHat Nov 18 '14 at 22:29
  • yes, but adding 100 or more source files manually is really annoying. If there is a way that eclipse manages my cmake file I would like to know. – thi gg Nov 18 '14 at 22:34
  • Last suggestion, you can dump your current source list using `message(STATUS "${SOURCE_VAR}")` (putting in `SOURCE_VAR` whatever you are currently using). Then adding the rest as you add the files should be pretty light work. Seriously, the time you save by not adding these files to the list is more than gobbled up by trying to deal with the system if you want to do conditional includes, having to remember to regenerate every checkout of version control, switching to different IDEs/buildchains, or messing with trying to write custom plugins. – IdeaHat Nov 18 '14 at 22:48
  • My current workflow is: add file, run cmake again. My new workflow would be: add file, add file to cmake, run cmake again. I don't see the improvment, or am I missing something? – thi gg Nov 19 '14 at 07:23
  • 2
    Your current workflow from to add a file and build is "add file; run cmake; run ninja". My workflow is "add file; add file to CMakeLists.txt; run ninja". So that by weight is about the same. But your method pollutes other workflows as well. Example: merging other's changes is. "pull; run cmake; run make" rather than "pull; run make". Not only is it shorter, but I don't have to remember anything. In a real project, you'll be merging others changes way more often than adding a file. – IdeaHat Nov 19 '14 at 18:16

0 Answers0