49 lines
2.5 KiB
CMake
49 lines
2.5 KiB
CMake
#
|
|
# Singe 3
|
|
# Copyright (C) 2006-2026 Scott Duensing <scott@kangaroopunch.com>
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# 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)
|
|
# The binaries by name, from the project() line as CMakeLists.txt makes SINGE_VERSION_FULL (patch 1
|
|
# is a beta and tweak says which), so one an older version left in .builddir is never joined.
|
|
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt projectLine REGEX "^project\\(singe2 VERSION ")
|
|
if(NOT projectLine MATCHES "VERSION ([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
|
message(FATAL_ERROR "CMakeLists.txt has no four-number project() version.")
|
|
endif()
|
|
if(CMAKE_MATCH_3 EQUAL 1)
|
|
set(version "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}b${CMAKE_MATCH_4}")
|
|
else()
|
|
set(version "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
|
|
endif()
|
|
set(armBinary ${buildDir}/Singe-v${version}-Macos-aarch64)
|
|
set(intelBinary ${buildDir}/Singe-v${version}-Macos-x86_64)
|
|
if(NOT EXISTS ${armBinary} OR NOT EXISTS ${intelBinary})
|
|
message(FATAL_ERROR "Build the macos-aarch64 and macos-x86_64 presets first.")
|
|
endif()
|
|
set(universalBinary ${buildDir}/Singe-v${version}-Macos-universal)
|
|
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}")
|