Revert "Performance: Improve efficiency of source file lookup in cmMakefile"
Unfortunately the main change in !1154 (merged) broke some legacy behavior that was not covered by the test suite. Revert the change and add a test case covering behavior it broke.