The starter git project? Just a starter

Yesterday I mentioned that my git starter project had a significant gap (and closed it there) and a problem. I had noticed the gap before I posted the original, but I didn't notice the problem until, as I wrote yesterday, I tried to use the original for something else.

The problem was that the starter wasn't well laid out for further development. It showed how to bring the different pieces together in one place but not how one should lay things out for longer term ease of use. I considered laying down steps to change the project, but if a patch is a picture of a change to source code, and if a picture is worth a thousand words, then if you download this patch and execute the following commands, you'll see what I mean. (I'm assuming you saved the patch in your current working directory, beside the starter project)

cd starter
git apply ../git-starter-patch.diff

The result shows far more eloquently than I can briefly describe what needed to be done. Your final tool will need to use the code that you want to write and test -- but so will the tests! Putting the code next to the tool would make bringing your "test-me" code into a test as well as into the final tool awkward. After this patch, when you want to bring your library into the main tool, you can add a line to the top level CMakeLists.txt file, just after the "add_executable" line, to bring the library in there, too, thus:

target_link_libraries( starter math-primitives )

Then, everything will be compiled exactly once, available for linking in each different context (currently only two, but it could grow). Oh, and by the way, the test in the patch fails; so don't commit it yet!

No comments: