From af4954aee3483f03ff69e990e80f4e4a18e8b7f6 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 5 Feb 2022 21:37:37 +0100 Subject: CMake/macOS: build arm files for libpng only on ARM Remove macOS warning "ranlib: file ... has no symbols" although this works only partially (see comment in png/CMakeLists.txt). --- png/CMakeLists.txt | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/png/CMakeLists.txt b/png/CMakeLists.txt index 117d699ee..3994dfd7b 100644 --- a/png/CMakeLists.txt +++ b/png/CMakeLists.txt @@ -1,7 +1,7 @@ # # PNG library CMake configuration for the Fast Light Toolkit (FLTK). # -# Copyright 1998-2021 by Bill Spitzak and others. +# Copyright 1998-2022 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this @@ -31,13 +31,33 @@ set(PNG_SRCS pngwrite.c pngwtran.c pngwutil.c - - # build on ARM (Apple M1 systems) - arm/arm_init.c - arm/filter_neon_intrinsics.c - arm/palette_neon_intrinsics.c ) +####################################################################### +# Build some files on ARM (e.g. Apple M1 systems) +####################################################################### + +# We can only determine the target architecture if it is set +# in CMAKE_OSX_ARCHITECTURES, otherwise we *assume* it is true and +# compile these files even if this results in some warnings. +# This includes all non-macOS platforms. + +if (CMAKE_OSX_ARCHITECTURES) + string(REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}") +else () + set (is_arm TRUE) +endif () + +if (is_arm) + LIST (APPEND PNG_SRCS + arm/arm_init.c + arm/filter_neon_intrinsics.c + arm/palette_neon_intrinsics.c + ) +endif () + +unset (is_arm) + ####################################################################### # Build the static library ####################################################################### -- cgit v1.2.3