redguardtoo/cpputils-cmake — pull request #21 by dojeda (2014-03-03 14:54:27+00:00)
Title: Support for projects with subprojects

**DISCLAIMER:** This is the first time I try to code something in lisp, and the first time I make a pull request. My contributions should be taken with a grain of salt.

I found cpputils-cmake quite useful, but it failed to work in some of my projects. I found out that the `cppcm-include-dirs` variable was not set correctly and the culprit was the `cppcm-query-var` function, which was selecting the wrong directory. To be fair, my project structure is not trivial, but after some debugging I found that the problem was that I had a cmake project with a cmake subproject.

Due to the names that I chose for my projects, the `cppcm-query-var` was selecting the subproject instead of the main project. Since my subproject was a library without executables, no Makefile was generated and somehow the include directories were not detected correctly.

In this pull request, I wrote a variant of the `cppcm-query-var` that does not stop at the first match, but continues and the selects the *shorter* match (in my case, the shorter match means the one of the top-level project). I know that this workaround is far from elegant but it solves my problem, which is why I did not rewrite `cppcm-query-var`. Also, I'm not sure if I'm breaking some other functionalities with this change.

In addition to this improvement, I also include some other modifications, which are:
* Customization of Makefile filename: I did this because I don't like to have files named Makefile around, it seems to confusion to have Makefiles that were not generated by me or cmake.
* Modified the regular expression of `cppcm-query-targets` so it ignores commented lines. I had a ton on commented `add_library` and `add_executable` and I thought that these should be ignored. **Warning:** I'm not 100% sure of this regexp, please check if this is pertinent.
* A minimum example project that reproduces my problem with version 0.4.5

I realize that this pull request is probably ill-formed or includes some commits that should not be included. As I said before, I've never done a pull request before.