Page MenuHomePhabricator

[CMAKE] Wrap the check_include_files() macro to make it honor sysroot

Authored by Fabien on May 21 2020, 15:12.


Group Reviewers
Restricted Project

In the case a sysroot is specified (via CMAKE_SYSROOT or
CMAKE_OSX_SYSROOT for example), all the find_* functions will take
it into account during the search. Unfortunately this is not the case
for check_include_files() which is designed to test for headers
implicitely included by the compiler (it does not only search, but also
builds a minimal program which uses the header).

This diff adds a wrapper to the check_include_files() to make it able
to find the headers in the case a sysroot is specified. This will make
it possible to test for headers located in the Apple Framework when
building for OSX.

This cause no change in the software behavior, as the only header found
that was previously missed on OSX is sys/select.h, and its only use is
for the glibc compatibility layer which is unused on OSX.

Test Plan

Build for OSX (both native and cross build).
Check the sys/select.h header is now found.

Event Timeline

Fabien requested review of this revision.May 21 2020, 15:12
Fabien planned changes to this revision.May 21 2020, 15:16

Despite the doc not stating it and the mailing list telling the opposite, it seems that check_include_files DOES use the sysroot...