From e69103395472da8e621f8fcf437274686d392d06 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 1 Aug 2022 22:13:11 +0200 Subject: [PATCH] Require CMake 3.16 for ObjC and ObjC++ sources Both languages gained native CMake support in 3.16: https://cmake.org/cmake/help/latest/release/3.16.html#languages --- CMakeLists.txt | 2 +- examples/cocoa/CMakeLists.txt | 2 ++ src/SFML/Main/CMakeLists.txt | 1 + src/SFML/Window/CMakeLists.txt | 7 ++----- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62a0955b4..346a5c96c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.16) # define a macro that helps defining an option macro(sfml_set_option var default type docstring) diff --git a/examples/cocoa/CMakeLists.txt b/examples/cocoa/CMakeLists.txt index 731ac5189..30819faa4 100644 --- a/examples/cocoa/CMakeLists.txt +++ b/examples/cocoa/CMakeLists.txt @@ -1,3 +1,5 @@ +enable_language(OBJC OBJCXX) + # Usage: compile_xib(INPUT path/to/file.xib OUTPUT path/to/file.nib) function(compile_xib) cmake_parse_arguments(THIS "" "INPUT;OUTPUT" "" ${ARGN}) diff --git a/src/SFML/Main/CMakeLists.txt b/src/SFML/Main/CMakeLists.txt index f889768a1..3cd140489 100644 --- a/src/SFML/Main/CMakeLists.txt +++ b/src/SFML/Main/CMakeLists.txt @@ -6,6 +6,7 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/src/SFML/Main) if(SFML_OS_WINDOWS) set(SRC ${SRC} ${SRCROOT}/MainWin32.cpp) elseif(SFML_OS_IOS) + enable_language(OBJCXX) set(SRC ${SRC} ${SRCROOT}/MainiOS.mm) elseif(SFML_OS_ANDROID) set(SRC ${SRC} ${SRCROOT}/MainAndroid.cpp) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index d2afd093a..c9595b3e3 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -150,6 +150,7 @@ elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) endif() source_group("unix" FILES ${PLATFORM_SRC}) elseif(SFML_OS_MACOSX) + enable_language(OBJC OBJCXX) set(PLATFORM_SRC ${SRCROOT}/OSX/cpp_objc_conversion.h ${SRCROOT}/OSX/cpp_objc_conversion.mm @@ -203,6 +204,7 @@ elseif(SFML_OS_MACOSX) ) source_group("mac" FILES ${PLATFORM_SRC}) elseif(SFML_OS_IOS) + enable_language(OBJCXX) set(PLATFORM_SRC ${SRCROOT}/iOS/CursorImpl.hpp ${SRCROOT}/iOS/CursorImpl.cpp @@ -272,11 +274,6 @@ target_link_libraries(sfml-window PUBLIC SFML::System) # glad sources target_include_directories(sfml-window SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include") -# 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() - # Vulkan headers target_include_directories(sfml-window SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/vulkan")