# # Singe 3 # Copyright (C) 2006-2026 Scott Duensing # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public Licens # as published by the Free Software Foundation; either version 3 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # # Joins the Apple silicon and Intel Singe binaries into one universal binary with llvm-lipo. # Run as: cmake -P cmake/zig/macosUniversal.cmake (after both macOS presets have built) get_filename_component(buildDir ${CMAKE_CURRENT_LIST_DIR}/../../.builddir ABSOLUTE) file(GLOB armBinary ${buildDir}/Singe-v*-Macos-aarch64) file(GLOB intelBinary ${buildDir}/Singe-v*-Macos-x86_64) if(NOT armBinary OR NOT intelBinary) message(FATAL_ERROR "Build the macos-aarch64 and macos-x86_64 presets first.") endif() string(REPLACE "-aarch64" "-universal" universalBinary ${armBinary}) find_program(SINGE_LIPO NAMES llvm-lipo llvm-lipo-21 llvm-lipo-20 llvm-lipo-19 llvm-lipo-18 llvm-lipo-17 llvm-lipo-16 llvm-lipo-15) if(NOT SINGE_LIPO) message(FATAL_ERROR "llvm-lipo is needed to make the universal binary (apt-get install llvm).") endif() execute_process(COMMAND ${SINGE_LIPO} -create ${armBinary} ${intelBinary} -output ${universalBinary} RESULT_VARIABLE code) if(NOT code EQUAL 0) message(FATAL_ERROR "llvm-lipo failed.") endif() message(STATUS "Wrote ${universalBinary}")