authorgravatar for erik.arvstedt@gmail.comErik Arvstedt <erik.arvstedt@gmail.com> 2024-04-12 14:54:08+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-18 12:16:24-07:00
log130fb5cb0fb9039e79450c9db58d6590c5bee3b3
treee9cdb82a0fd1913d6ab7abcb81c970fe29de0a46
parent22a97cd235b5a2ffa9882c267b365c463b38e5ba

cmake: support setting the dynamic linker


1 files changed, 8 insertions(+), 1 deletions(-)

CMakeLists.txt+8-1
......@@ -109,6 +109,8 @@ endif()
109109
110110set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
111111set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
112set(ZIG_TARGET_DYNAMIC_LINKER "" CACHE STRING
113 "Override the dynamic linker used by the Zig binary. Default is to auto-detect the dynamic linker.")
112114set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
113115set(ZIG_AR_WORKAROUND off CACHE BOOL "append 'ar' subcommand to CMAKE_AR")
114116
......@@ -897,12 +899,16 @@ if(ZIG_STATIC AND NOT MSVC)
897899else()
898900 set(ZIG_STATIC_ARG "")
899901endif()
900
901902if(CMAKE_POSITION_INDEPENDENT_CODE OR ZIG_PIE)
902903 set(ZIG_PIE_ARG "-Dpie")
903904else()
904905 set(ZIG_PIE_ARG "")
905906endif()
907if("${ZIG_TARGET_DYNAMIC_LINKER}" STREQUAL "")
908 set(ZIG_DYNAMIC_LINKER_ARG "")
909else()
910 set(ZIG_DYNAMIC_LINKER_ARG "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}")
911endif()
906912
907913# -Dno-langref is currently hardcoded because building the langref takes too damn long
908914# To obtain these two forms of documentation, run zig build against stage3 rather than stage2.
......@@ -918,6 +924,7 @@ set(ZIG_BUILD_ARGS
918924 ${ZIG_PIE_ARG}
919925 "-Dtarget=${ZIG_TARGET_TRIPLE}"
920926 "-Dcpu=${ZIG_TARGET_MCPU}"
927 ${ZIG_DYNAMIC_LINKER_ARG}
921928 "-Dversion-string=${RESOLVED_ZIG_VERSION}"
922929)
923930