From 1028e52c93d2292b44ff7bae8e721025d2f2c94d Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 10 Mar 2025 13:13:30 +0200 Subject: [PATCH] CMake: Fix tuklib_use_system_extensions Revert back to a macro so that list(APPEND CMAKE_REQUIRED_DEFINITIONS) will affect the calling scope. I had forgotten that while CMake functions inherit the variables from the parent scope, the changes to them are local unless using set(... PARENT_SCOPE). This also means that the commit message in 5bb77d0920dc is wrong. The commit itself is still fine, making it clearer that -DHAVE_SYS_PARAM_H is only needed for specific check_c_source_compiles() calls. Fixes: c1ea7bd0b60eed6ebcdf9a713ca69034f6f07179 --- cmake/tuklib_common.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/tuklib_common.cmake b/cmake/tuklib_common.cmake index b575506a..9762e245 100644 --- a/cmake/tuklib_common.cmake +++ b/cmake/tuklib_common.cmake @@ -26,7 +26,10 @@ endfunction() # This is an over-simplified version of AC_USE_SYSTEM_EXTENSIONS in Autoconf # or gl_USE_SYSTEM_EXTENSIONS in gnulib. -function(tuklib_use_system_extensions) +# +# NOTE: This is a macro because the changes to CMAKE_REQUIRED_DEFINITIONS +# must be visible in the calling scope. +macro(tuklib_use_system_extensions) if(NOT MSVC) add_compile_definitions( _GNU_SOURCE # glibc, musl, mingw-w64 @@ -50,4 +53,4 @@ function(tuklib_use_system_extensions) -D_ALL_SOURCE ) endif() -endfunction() +endmacro()