Fix for universal binaries on macOS

Fix the issue of a
    clang: error: no such file or directory: 'x86_64'
error on building universal binaries on macOS.

It is also necessary to specify:
    -DCMAKE_C_FLAGS="-DPNG_ARM_NEON_OPT=0"

Example CMake command:
    cmake -S libpng \
          -B build_libpng \
          -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
          -DCMAKE_C_FLAGS="-DPNG_ARM_NEON_OPT=0"

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
This commit is contained in:
Jon Creighton
2023-01-09 13:17:31 +00:00
committed by Cosmin Truta
parent 9923515ff4
commit cd0ea2a7f5
2 changed files with 5 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
# CMakeLists.txt # CMakeLists.txt
# Copyright (c) 2018-2022 Cosmin Truta # Copyright (c) 2018-2023 Cosmin Truta
# Copyright (c) 2007,2009-2018 Glenn Randers-Pehrson # Copyright (c) 2007,2009-2018 Glenn Randers-Pehrson
# Written by Christian Ehrlicher, 2007 # Written by Christian Ehrlicher, 2007
# Revised by Roger Lowman, 2009-2010 # Revised by Roger Lowman, 2009-2010
@@ -20,6 +20,7 @@
# Revised by Gleb Mazovetskiy, 2021 # Revised by Gleb Mazovetskiy, 2021
# Revised by Christopher Sean Morrison, 2022 # Revised by Christopher Sean Morrison, 2022
# Revised by Martin Storsjo, 2022 # Revised by Martin Storsjo, 2022
# Revised by Jon Creighton, 2023
# This code is released under the libpng license. # This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer # For conditions of distribution and use, see the disclaimer

View File

@@ -24,10 +24,10 @@ set(ZLIBINCDIR "@ZLIB_INCLUDE_DIRS@")
set(PLATFORM_C_FLAGS) set(PLATFORM_C_FLAGS)
if(APPLE) if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "@CMAKE_OSX_ARCHITECTURES@") set(CMAKE_OSX_INTERNAL_ARCHITECTURES "@CMAKE_OSX_INTERNAL_ARCHITECTURES@")
set(CMAKE_OSX_SYSROOT "@CMAKE_OSX_SYSROOT@") set(CMAKE_OSX_SYSROOT "@CMAKE_OSX_SYSROOT@")
if(CMAKE_OSX_ARCHITECTURES) if(CMAKE_OSX_INTERNAL_ARCHITECTURES)
set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}) set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -arch ${CMAKE_OSX_INTERNAL_ARCHITECTURES})
endif() endif()
if(CMAKE_OSX_SYSROOT) if(CMAKE_OSX_SYSROOT)
set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}) set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT})