I’m trying to cross compile from a Linux host to a MacOS target. I am using Zig as my cross compiler (but I don’t think that’s relevant here, any linux->macos cross compiler should exhibit the same issue). Zig is special because it does not require a sysroot of the target system.
The install_name_tool
tool seems to be required. But not when initializing language support (here I’m using C) through project(MyApp C)
, it is required only when using enable_language(C)
after the fact.
Here’s a minimal reproducible example:
CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(MyApp NONE)
enable_language(C)
add_executable(MyApp main.c)
main.c
int main() {}
toolchain-macos.cmake
set(CMAKE_SYSTEM_NAME "Darwin")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_C_COMPILER "/usr/bin/zig" "cc" "-target" "x86_64-macos")
set(CMAKE_CXX_COMPILER "/usr/bin/zig" "c++" "-target" "x86_64-macos")
Here’s the error message:
-- The C compiler identification is Clang 18.1.8
CMake Error at /usr/share/cmake-4.0/Modules/CMakeFindBinUtils.cmake:250 (message):
Could not find install_name_tool, please check your installation.
Call Stack (most recent call first):
/usr/share/cmake-4.0/Modules/CMakeDetermineCCompiler.cmake:201 (include)
CMakeLists.txt:5 (enable_language)
-- Configuring incomplete, errors occurred!
My CMake version is 4.0.2
.