mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
build: Fix the CMake file for cross-platform builds that require libm
Detect the availability of `libm` on the target platform. Previously, `libm` was detected on the host platform only. Also introduce the variable `PNG_LINK_LIBRARIES`. Stop using `M_LIBRARY`, which was not namespace-clean.
This commit is contained in:
parent
2e5f296bfa
commit
8087a21d0a
@ -30,6 +30,7 @@ project(libpng
|
|||||||
LANGUAGES C ASM)
|
LANGUAGES C ASM)
|
||||||
|
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
|
include(CheckLibraryExists)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# Allow the users to specify an application-specific API prefix for libpng
|
# Allow the users to specify an application-specific API prefix for libpng
|
||||||
@ -138,19 +139,15 @@ endif()
|
|||||||
|
|
||||||
# Find the zlib library.
|
# Find the zlib library.
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
set(PNG_LINK_LIBRARIES ZLIB::ZLIB)
|
||||||
|
|
||||||
# Find the math library (where available).
|
# Find the math library (unless we already know it's not available or
|
||||||
if(UNIX
|
# not needed).
|
||||||
AND NOT (APPLE OR BEOS OR HAIKU)
|
if(UNIX AND NOT (APPLE OR BEOS OR HAIKU OR EMSCRIPTEN))
|
||||||
AND NOT EMSCRIPTEN)
|
check_library_exists(m pow "" PNG_HAVE_LIBM_POW)
|
||||||
find_library(M_LIBRARY m)
|
endif()
|
||||||
if(M_LIBRARY)
|
if(PNG_HAVE_LIBM_POW)
|
||||||
set(M_LIBRARY m)
|
list(APPEND PNG_LINK_LIBRARIES m)
|
||||||
else()
|
|
||||||
set(M_LIBRARY "")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
# libm is not available or not needed.
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Silence function deprecation warnings on the Windows compilers that might
|
# Silence function deprecation warnings on the Windows compilers that might
|
||||||
@ -702,7 +699,7 @@ if(PNG_SHARED)
|
|||||||
SYSTEM
|
SYSTEM
|
||||||
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
|
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
|
||||||
target_link_libraries(png_shared
|
target_link_libraries(png_shared
|
||||||
PUBLIC ZLIB::ZLIB ${M_LIBRARY})
|
PUBLIC ${PNG_LINK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PNG_STATIC)
|
if(PNG_STATIC)
|
||||||
@ -720,7 +717,7 @@ if(PNG_STATIC)
|
|||||||
SYSTEM
|
SYSTEM
|
||||||
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
|
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
|
||||||
target_link_libraries(png_static
|
target_link_libraries(png_static
|
||||||
PUBLIC ZLIB::ZLIB ${M_LIBRARY})
|
PUBLIC ${PNG_LINK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PNG_FRAMEWORK AND NOT APPLE)
|
if(PNG_FRAMEWORK AND NOT APPLE)
|
||||||
@ -753,7 +750,7 @@ if(PNG_FRAMEWORK)
|
|||||||
SYSTEM
|
SYSTEM
|
||||||
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
|
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
|
||||||
target_link_libraries(png_framework
|
target_link_libraries(png_framework
|
||||||
PUBLIC ZLIB::ZLIB ${M_LIBRARY})
|
PUBLIC ${PNG_LINK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT PNG_LIBRARY_TARGETS)
|
if(NOT PNG_LIBRARY_TARGETS)
|
||||||
@ -950,7 +947,7 @@ if(PNG_SHARED AND PNG_TOOLS)
|
|||||||
|
|
||||||
add_executable(png-fix-itxt ${png_fix_itxt_sources})
|
add_executable(png-fix-itxt ${png_fix_itxt_sources})
|
||||||
target_link_libraries(png-fix-itxt
|
target_link_libraries(png-fix-itxt
|
||||||
PRIVATE ZLIB::ZLIB ${M_LIBRARY})
|
PRIVATE ${PNG_LINK_LIBRARIES})
|
||||||
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
|
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user