]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Use cmake_push_check_state in tuklib_cpucores and tuklib_physmem
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 9 Mar 2025 12:43:07 +0000 (14:43 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 9 Mar 2025 15:44:37 +0000 (17:44 +0200)
Now the changes to CMAKE_REQUIRED_DEFINITIONS are temporary and don't
leak to the calling code.

cmake/tuklib_cpucores.cmake
cmake/tuklib_physmem.cmake

index e5e9c34d7fec9c17a82aedf459a293e83af6dd46..05f3ceef8d15ebed3e9f365bcd67fb7a2386ee1c 100644 (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
index e4888ebeb760b892f82b8818395b1ab9ab03bb57..d4d3f3d260c38ea23d5c20cb2ec6d484cf5faaf1 100644 (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