Correctly query termios.h and ioctl.h for struct winsize

The previous check was including these as relative includes, meaning the actual
system header files weren't actually being explicitly included and the check
could spuriously fail.

CMAKE_EXTRA_INCLUDE_FILES doesn't seem to have a way to specify that the
includes should be treated as system/global includes and CHECK_TYPE_SIZE() isn't
documented as being affected by any other variables that do, so switch to
another method altogether.

This requires that `struct winsize` have a member `ws_row`, but as best as I can
tell that is always the case.

Closes #9279.
This commit is contained in:
Mahmoud Al-Qudsi 2022-10-14 22:01:48 -05:00
parent 8b5cc0883a
commit 11f954e7ec

View File

@ -173,10 +173,9 @@ check_cxx_symbol_exists(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L)
check_cxx_symbol_exists(uselocale "locale.h;xlocale.h" HAVE_USELOCALE) check_cxx_symbol_exists(uselocale "locale.h;xlocale.h" HAVE_USELOCALE)
cmake_push_check_state() cmake_push_check_state()
set(CMAKE_EXTRA_INCLUDE_FILES termios.h sys/ioctl.h) check_struct_has_member("struct winsize" ws_row "termios.h;sys/ioctl.h" _HAVE_WINSIZE)
check_type_size("struct winsize" STRUCT_WINSIZE LANGUAGE CXX)
check_cxx_symbol_exists("TIOCGWINSZ" "termios.h;sys/ioctl.h" HAVE_TIOCGWINSZ) check_cxx_symbol_exists("TIOCGWINSZ" "termios.h;sys/ioctl.h" HAVE_TIOCGWINSZ)
if(STRUCT_WINSIZE GREATER -1 AND HAVE_TIOCGWINSZ EQUAL 1) if(_HAVE_WINSIZE EQUAL 1 AND HAVE_TIOCGWINSZ EQUAL 1)
set(HAVE_WINSIZE 1) set(HAVE_WINSIZE 1)
endif() endif()
cmake_pop_check_state() cmake_pop_check_state()