Prevent CMake configure checks for affecting future checks

Using CMAKE_PUSH_CHECK_STATE/CMAKE_POP_CHECK_STATE to prevent CMake
checks from permanently altering the environment used by future checks.
This commit is contained in:
Mahmoud Al-Qudsi 2019-01-04 14:30:14 -06:00
parent 490432c177
commit 5196a42165

View File

@ -106,13 +106,14 @@ CHECK_CXX_SYMBOL_EXISTS(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L)
CHECK_CXX_SYMBOL_EXISTS(_sys_errs stdlib.h HAVE__SYS__ERRS)
CMAKE_PUSH_CHECK_STATE()
SET(CMAKE_EXTRA_INCLUDE_FILES termios.h sys/ioctl.h)
CHECK_TYPE_SIZE("struct winsize" STRUCT_WINSIZE LANGUAGE CXX)
CHECK_CXX_SYMBOL_EXISTS("TIOCGWINSZ" "termios.h;sys/ioctl.h" HAVE_TIOCGWINSZ)
IF(STRUCT_WINSIZE GREATER -1 AND HAVE_TIOCGWINSZ EQUAL 1)
SET(HAVE_WINSIZE 1)
ENDIF()
SET(CMAKE_EXTRA_INCLUDE_FILES)
CMAKE_POP_CHECK_STATE()
IF(EXISTS "/proc/self/stat")
SET(HAVE__PROC_SELF_STAT 1)
@ -135,7 +136,8 @@ ELSEIF(HAVE_NCURSES_TERM_H)
SET(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses/term.h>\n")
ENDIF()
SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
CMAKE_PUSH_CHECK_STATE()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
CHECK_CXX_SOURCE_COMPILES("
${TPARM_INCLUDES}
@ -162,7 +164,7 @@ int main () {
SET(TPARM_VARARGS 1)
ENDIF()
ENDIF()
SET(CMAKE_REQUIRED_LIBRARIES)
CMAKE_POP_CHECK_STATE()
CHECK_CXX_SOURCE_COMPILES("
#include <memory>