From 9b26eca3572c14794b73b503262c0a49dde45449 Mon Sep 17 00:00:00 2001 From: Meng-Hsiu Chiang Date: Wed, 17 May 2023 20:16:47 +0000 Subject: [PATCH] Set variables to PARENT_SCOPE in CMake functions 1f2b9d62 replaces macros with functions, but in CMake functions have different scope and the variables set in the functions are not visible to the caller. The change breaks MySQL building with `WITH_ZLIB="system"` for the reason above (ZLIB_FOUND is not visible when returning from `FIND_SYSTEM_ZLIB()`). Setting the necessary variables to PARENT_SCOPE (equal to returning variables) solves this issue. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- cmake/zlib.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 460d87ac61d6..633ca494d3ac 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -60,6 +60,8 @@ FUNCTION(FIND_SYSTEM_ZLIB) TARGET_INCLUDE_DIRECTORIES(zlib_interface SYSTEM INTERFACE ${ZLIB_INCLUDE_DIR}) ENDIF() + SET(ZLIB_FOUND ${ZLIB_FOUND} PARENT_SCOPE) + SET(ZLIB_VERSION ${ZLIB_VERSION} PARENT_SCOPE) ENDIF() ENDFUNCTION(FIND_SYSTEM_ZLIB)