macOS: CMake uses -Wl,-rpath for Mac OS X 10.4 Tiger despite not being supported
This issue stemmed from a build failure in another software project; see https://github.com/minetest/minetest/issues/11647 for more information. Essentially, no matter what I tried after the fact, CMake was still trying to use -Wl,-rpath
to link a test program for a library.
This included setting CMAKE_OSX_DEPLOYMENT_TARGET
to 10.4
, CMAKE_SKIP_RPATH
to TRUE
and CMAKE_MACOSX_RPATH
to FALSE
, but again, nothing changed.
Looking at the CMake file for Darwin (macOS), I found this:
if(NOT "${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
endif()
From the looks of it, this should only be enabling -rpath
if the macOS version is not less (i.e. greater than or equal to) 10.5. It appears, however, to be completely ignored.
In desperation, I forcibly modified this file to set CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG
to an empty string. While this did get zstd in the project to be detected, it still did not complete successfully.
Thomass-iMac:build thomas$ cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.4" -DCMAKE_SKIP_RPATH=TRUE -DCMAKE_SKIP_BUILD_RPATH=TRUE -DCMAKE_MACOSX_RPATH=FALSE -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.4u.sdk/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/irrlichtmt/ppc -DCMAKE_TOOLCHAIN_FILE=/Users/thomas/Documents/minetest/ppctoolchain.cmake -DCMAKE_INSTALL_PREFIX=/Users/thomas/Documents/minetest-built -DZSTD_INCLUDE_DIR=/opt/zstd/ppc/include -DZSTD_LIBRARY=/opt/zstd/ppc/lib/libzstd.dylib -DBUILD_UNITTESTS=FALSE -DENABLE_CURL=OFF -DENABLE_CURSES=OFF -DENABLE_FREETYPE=OFF -DENABLE_GETTEXT=OFF -DENABLE_LEVELDB=OFF -DENABLE_POSTGRESQL=OFF -DENABLE_REDIS=OFF -DENABLE_SPATIAL=OFF -DENABLE_SOUND=OFF -DENABLE_LUAJIT=OFF -DVERSION_EXTRA="powerpc"
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/gcc/ppc/11/bin/powerpc-apple-darwin8-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/gcc/ppc/11/bin/powerpc-apple-darwin8-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- *** Will build version 5.5.0-powerpc ***
-- Found IrrlichtMt 1.9.0
-- Using GMP provided by system.
-- Found GMP: /opt/gmp/ppc/lib/libgmp.dylib
-- Using JsonCpp provided by system.
-- Found Json: /opt/jsoncpp/ppc/lib/libjsoncpp.dylib
-- LuaJIT detection disabled! (ENABLE_LUAJIT=0)
-- LuaJIT not found, using bundled Lua.
CMake Warning at src/CMakeLists.txt:53 (message):
cURL is required to load the server list
-- GetText disabled.
-- Found OpenGL: /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/OpenGL.framework
-- Found SQLite3: /Developer/SDKs/MacOSX10.4u.sdk/usr/lib/libsqlite3.dylib
-- Prometheus client disabled.
-- Found ZLIB: /opt/zlib/ppc/lib/libz.dylib (found version "1.2.11")
-- Looking for ZSTD_initCStream
-- Looking for ZSTD_initCStream - found
-- Found Zstd: /opt/zstd/ppc/lib/libzstd.dylib
-- Looking for include file endian.h
-- Looking for include file endian.h - not found
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Configuring done
CMake Error at /opt/irrlichtmt/ppc/lib/cmake/IrrlichtMt/IrrlichtMtTargets.cmake:54 (add_library):
Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being
set. This could be because you are using a Mac OS X version less than 10.5
or because CMake's platform configuration is corrupt.
Call Stack (most recent call first):
/opt/irrlichtmt/ppc/lib/cmake/IrrlichtMt/IrrlichtMtConfig.cmake:11 (include)
CMakeLists.txt:88 (find_package)
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.