From 556602b9ce922493779229bd852d42bb84060c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20P=C4=85czkowski?= Date: Sun, 28 Sep 2025 12:43:01 -0700 Subject: [PATCH] cmake: fix creation of static lib in xcode --- src/libgit2/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt index 0dddb025e..4e351cf8c 100644 --- a/src/libgit2/CMakeLists.txt +++ b/src/libgit2/CMakeLists.txt @@ -55,6 +55,12 @@ set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE) # Compile and link libgit2 # +if (NOT BUILD_SHARED_LIBS AND XCODE_VERSION) + # This is required for Xcode to actually create the static libgit2 library + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "") + list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c) +endif() + add_library(libgit2package ${SRC_RC} ${LIBGIT2_OBJECTS}) target_link_libraries(libgit2package ${LIBGIT2_SYSTEM_LIBS}) target_include_directories(libgit2package SYSTEM PRIVATE ${LIBGIT2_INCLUDES})