1
0
mirror of https://github.com/glennrp/libpng.git synced 2026-10-22 20:29:09 +03:00

fix(build): Use space-separated string for CMAKE_REQUIRED_FLAGS

This is a cherry-pick of commit d733c11206
from branch 'libpng18'.

Co-authored-by: Brad King <brad.king@kitware.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
This commit is contained in:
yaito3014
2026-06-12 18:45:03 +09:00
committed by Cosmin Truta
parent 78ae423bf0
commit fad0b25433
2 changed files with 13 additions and 8 deletions

View File

@@ -396,34 +396,37 @@ if(ld-version-script AND NOT (ANDROID OR APPLE))
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()

View File

@@ -11,6 +11,7 @@ Author List
* B. Scott Michel
* Benjamin Buch
* Bernd Kuhls
* Brad King
* Cameron Cawley
* Carlo Bramini
* Christian Ehrlicher
@@ -31,6 +32,7 @@ Author List
* John Bowler
* Jon Creighton
* Joost Nieuwenhuijse
* Kakeyama Yaito (掛山夜糸)
* Kyle Bentley
* Luis Caro Campos
* Martin Storsjö