fix(build): Use space-separated string for CMAKE_REQUIRED_FLAGS This is a cherry-pick of commit d733c11206a350f2af3cd13c6d5929e9fb6b27a1 from branch 'libpng18'. Co-authored-by: Brad King <brad.king@kitware.com> Signed-off-by: Cosmin Truta <ctruta@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt index c5e0667..d994e23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -396,34 +396,37 @@ VERS_1 { global: sym1; local: *; }; VERS_2 { global: sym2; main; } VERS_1; ") - set(_SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + # CMAKE_REQUIRED_FLAGS is a space-separated string, not a CMake list. + # Use string(APPEND) instead of list(APPEND) to prevent misparsing by + # try_compile under CMake 4.4 or newer. + set(_SAVED_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") if(NOT CMAKE_HOST_SOLARIS) # Avoid using CMAKE_SHARED_LIBRARY_C_FLAGS in version script checks on # Solaris, because of an incompatibility with the Solaris link editor. - list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) + string(APPEND CMAKE_REQUIRED_FLAGS " ${CMAKE_SHARED_LIBRARY_C_FLAGS}") endif() - list(APPEND CMAKE_REQUIRED_FLAGS - "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") + string(APPEND CMAKE_REQUIRED_FLAGS + " -Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") check_c_source_compiles(" void sym1(void) {} void sym2(void) {} int main(void) { return 0; } " HAVE_LD_VERSION_SCRIPT) if(NOT HAVE_LD_VERSION_SCRIPT) - set(CMAKE_REQUIRED_FLAGS ${_SAVED_CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "${_SAVED_CMAKE_REQUIRED_FLAGS}") if(NOT CMAKE_HOST_SOLARIS) # Again, avoid using CMAKE_SHARED_LIBRARY_C_FLAGS in version script # checks on Solaris. - list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) + string(APPEND CMAKE_REQUIRED_FLAGS " ${CMAKE_SHARED_LIBRARY_C_FLAGS}") endif() - list(APPEND CMAKE_REQUIRED_FLAGS "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") + string(APPEND CMAKE_REQUIRED_FLAGS " -Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") check_c_source_compiles(" void sym1(void) {} void sym2(void) {} int main(void) { return 0; } " HAVE_SOLARIS_LD_VERSION_SCRIPT) endif() - set(CMAKE_REQUIRED_FLAGS ${_SAVED_CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "${_SAVED_CMAKE_REQUIRED_FLAGS}") file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") endif()
diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index ea4584e..0f9d4e9 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md
@@ -11,6 +11,7 @@ * B. Scott Michel * Benjamin Buch * Bernd Kuhls + * Brad King * Cameron Cawley * Carlo Bramini * Christian Ehrlicher @@ -31,6 +32,7 @@ * John Bowler * Jon Creighton * Joost Nieuwenhuijse + * Kakeyama Yaito (掛山夜糸) * Kyle Bentley * Luis Caro Campos * Martin Storsjö