Skip to content

Check*: Restore support for arbitrary result variable names

Ruoyu Zhong requested to merge ZhongRuoyu/cmake:source-from-var into master

In !7717 (merged) the switch to SOURCE_FROM_* required a stronger precondition (the second argument to check_include_files must not have path components) than before (any variable name could be used).

Fix that by transforming the variable name to a C identifier before feeding it to try_compile as a filename. The filename is unspecified by the documentation, and the file itself is only temporary, so that should work fine.

I have gone through all the occurrences of SOURCE_FROM_*, and identified these two that require changes. The rest should work fine as the filenames do not depend on input variable names.

Fixes: #24204 (closed)
Backport: release

Edited by Brad King

Merge request reports