3.25.0: Some modules that use try_compile no longer accept pathnames as variable names
!7717 (merged) modified some built-in modules to use try_compile
's new
SOURCE_FROM_*
arguments. However, that broke some cases where the input
variable may not be considered valid by try_compile
. For example, this
no longer worked:
include(CheckIncludeFiles)
foreach(header sys/signal.h)
check_include_files(${header} have_${header})
endforeach()
The above is a real example taken from Facebook's Watchman 1. Prior to CMake 3.25.0, this worked fine; CMake 3.25.0, however, complains:
CMake Error at /opt/homebrew/Cellar/cmake/3.25.0/share/cmake/Modules/CheckIncludeFiles.cmake:136 (try_compile):
SOURCE_FROM_VAR given invalid filename "have_sys/signal.h.c"
Call Stack (most recent call first):
CMakeLists.txt:5 (check_include_files)
This was because the switch to SOURCE_FROM_*
posed a stronger
precondition (the second argument to check_include_files
must not have
path components) than before (any variable name could be used), as
required by try_compile
(documented in Documentation >
cmake-commands(7) > try_compile
).
Edited by Ruoyu Zhong