From d1d788fcb373826a7f8a20cbe9d507ea735cd578 Mon Sep 17 00:00:00 2001 From: Jonny Paton Date: Mon, 27 Aug 2018 11:49:42 +0100 Subject: [PATCH] Add -ObjC flag to fix static linking on macOS --- src/SFML/Window/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 1fe8b5a43..98ea43946 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -229,6 +229,11 @@ sfml_add_library(sfml-window SOURCES ${SRC} ${PLATFORM_SRC}) target_link_libraries(sfml-window PUBLIC sfml-system) +# When static linking on macOS, we need to add this flag for objective C to work +if ((NOT BUILD_SHARED_LIBS) AND SFML_OS_MACOSX) + target_link_libraries(sfml-window PRIVATE -ObjC) +endif() + # find and setup usage for external libraries if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OPENBSD) sfml_find_package(X11 INCLUDE "X11_INCLUDE_DIR" LINK "X11_X11_LIB" "X11_Xrandr_LIB")