CMake commands cause project build to walk entire drive.

These lines sent Cmake into a lengthy walk of the entire drive when trying to build a project, see if you can spot the mistake. I’ll post the answer in a bit, but seems like an easy mistake to make and that should be caught by the parser.

set(SDK_SOURCE_DIR, “${SDK_DIR}/foo”)


The comma? It’s a valid variable character (though one we could possibly deny as a literal name via a policy). This will still always work:

set(varname "foo,")
set("${varname}" value)

That said…maybe one shouldn’t use GLOB_RECURSE for source file listings :slight_smile: . I, personally, would never recommend it.

That said, there are warnings for unused/undefined variables you can ask for upon request (--warn-unused and --warn-undefined).

Correct version is this without commas on the set calls.

And one either explicitly lists files in huge directory listings, or GLOB_RECURSE and exclude. Depends on how much effort one wants to go to listing everything out especially when the projects you pull are changing a lot. Personally prefer to limit changes to the CMakeLists.txt files in this case.

set(SDK_SOURCE_DIR “${SDK_DIR}/foo”)


Personally, I prefer to spend a bit of time explicitly listing the ~100 SDK files getting compiled into my binaries. It gives me security when updating SDK version, assurance that new installs are done correctly, avoids potential naming conflicts, and easily allows me to mock library APIs in tests.

1 Like