1
0
mirror of https://git.tukaani.org/xz.git synced 2025-03-25 09:50:41 +00:00

CMake: Use cmake_push_check_state in tuklib_cpucores and tuklib_physmem

Now the changes to CMAKE_REQUIRED_DEFINITIONS are temporary and don't
leak to the calling code.
This commit is contained in:
Lasse Collin 2025-03-09 14:43:07 +02:00
parent c1ea7bd0b6
commit 5bb77d0920
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
2 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,7 @@
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(CMakePushCheckState)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
@ -76,6 +77,7 @@ function(tuklib_cpucores_internal_check)
#
# We test sysctl() first and intentionally break the sysctl() test on QNX
# so that sysctl() is never used on QNX.
cmake_push_check_state()
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
if(HAVE_SYS_PARAM_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_PARAM_H)
@ -103,6 +105,7 @@ function(tuklib_cpucores_internal_check)
}
"
TUKLIB_CPUCORES_SYSCTL)
cmake_pop_check_state()
if(TUKLIB_CPUCORES_SYSCTL)
if(HAVE_SYS_PARAM_H)
set(TUKLIB_CPUCORES_DEFINITIONS

View File

@ -12,6 +12,7 @@
#############################################################################
include("${CMAKE_CURRENT_LIST_DIR}/tuklib_common.cmake")
include(CMakePushCheckState)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
@ -76,11 +77,11 @@ function(tuklib_physmem_internal_check)
endif()
# sysctl()
cmake_push_check_state()
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
if(HAVE_SYS_PARAM_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_PARAM_H)
endif()
check_c_source_compiles("
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
@ -96,6 +97,7 @@ function(tuklib_physmem_internal_check)
}
"
TUKLIB_PHYSMEM_SYSCTL)
cmake_pop_check_state()
if(TUKLIB_PHYSMEM_SYSCTL)
if(HAVE_SYS_PARAM_H)
set(TUKLIB_PHYSMEM_DEFINITIONS