Skip to content

cmake: fix creation of static lib in xcode#7139

Open
dyfer wants to merge 1 commit intolibgit2:mainfrom
dyfer:fix-xcode-static-lib
Open

cmake: fix creation of static lib in xcode#7139
dyfer wants to merge 1 commit intolibgit2:mainfrom
dyfer:fix-xcode-static-lib

Conversation

@dyfer
Copy link

@dyfer dyfer commented Sep 28, 2025

When I was trying to use libgit2 as a submodule building static library for another project under Xcode 16.1, I got linker errors and realized that the static library was not being created. In the process I found that - as far as I can tell - Xcode needs a workaround (a dummy C file) in order to actually create a static library file.

Libgit used to have this workaround built-in, but it was removed in d7b49ed (#6133).

As far as I can tell, this workaround is still needed when one wants to create a static library under Xcode.

For reference, this is what I used to build a static library:

mkdir build && cd build
cmake -G Xcode -D BUILD_SHARED_LIBS=OFF -D BUILD_CLI=OFF -D BUILD_EXAMPLES=OFF ..
cmake --build . --config RelWithDebInfo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant