cmake: on Apple, don't use find_library for frameworks + use EXTRA_LDFLAGS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27cecf1..e76470f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,9 @@ if (HAIKU)
set(LINKER_LANGUAGE CXX)
endif()
+set(EXTRA_LIBS)
+set(EXTRA_LDFLAGS)
+
# This is a virtual "library" that just exists to collect up compiler and
# linker options that used to be global to this CMake project. When you
# specify it as part of a real library's target_link_libraries(), that
@@ -2116,52 +2119,40 @@ elseif(APPLE)
# Actually load the frameworks at the end so we don't duplicate include.
if(SDL_FRAMEWORK_COREVIDEO)
- find_library(COREVIDEO CoreVideo)
- list(APPEND EXTRA_LIBS ${COREVIDEO})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreVideo")
endif()
if(SDL_FRAMEWORK_COCOA)
- find_library(COCOA_LIBRARY Cocoa)
- list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Cocoa")
endif()
if(SDL_FRAMEWORK_IOKIT)
- find_library(IOKIT IOKit)
- list(APPEND EXTRA_LIBS ${IOKIT})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,IOKit")
endif()
if(SDL_FRAMEWORK_FF)
- find_library(FORCEFEEDBACK ForceFeedback)
- list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,ForceFeedback")
endif()
if(SDL_FRAMEWORK_CARBON)
- find_library(CARBON_LIBRARY Carbon)
- list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Carbon")
endif()
if(SDL_FRAMEWORK_COREAUDIO)
- find_library(COREAUDIO CoreAudio)
- list(APPEND EXTRA_LIBS ${COREAUDIO})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreAudio")
endif()
if(SDL_FRAMEWORK_AUDIOTOOLBOX)
- find_library(AUDIOTOOLBOX AudioToolbox)
- list(APPEND EXTRA_LIBS ${AUDIOTOOLBOX})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,AudioToolbox")
endif()
if(SDL_FRAMEWORK_AVFOUNDATION)
- find_library(AVFOUNDATION AVFoundation)
- list(APPEND EXTRA_LIBS ${AVFOUNDATION})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,AVFoundation")
endif()
if(SDL_FRAMEWORK_COREBLUETOOTH)
- find_library(COREBLUETOOTH CoreBluetooth)
- list(APPEND EXTRA_LIBS ${COREBLUETOOTH})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreBluetooth")
endif()
if(SDL_FRAMEWORK_COREGRAPHICS)
- find_library(COREGRAPHICS CoreGraphics)
- list(APPEND EXTRA_LIBS ${COREGRAPHICS})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreGraphics")
endif()
if(SDL_FRAMEWORK_COREMOTION)
- find_library(COREMOTION CoreMotion)
- list(APPEND EXTRA_LIBS ${COREMOTION})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreMotion")
endif()
if(SDL_FRAMEWORK_FOUNDATION)
- find_library(FOUNDATION Foundation)
- list(APPEND EXTRA_LIBS ${FOUNDATION})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Foundation")
endif()
if(SDL_FRAMEWORK_GAMECONTROLLER)
find_library(GAMECONTROLLER GameController)
@@ -2171,27 +2162,23 @@ elseif(APPLE)
endif()
if(SDL_FRAMEWORK_METAL)
if(IOS OR TVOS)
- find_library(METAL Metal)
- list(APPEND EXTRA_LIBS ${METAL})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Metal")
else()
list(APPEND EXTRA_LDFLAGS "-Wl,-weak_framework,Metal")
endif()
endif()
if(SDL_FRAMEWORK_OPENGLES)
- find_library(OPENGLES OpenGLES)
- list(APPEND EXTRA_LIBS ${OPENGLES})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,OpenGLES")
endif()
if(SDL_FRAMEWORK_QUARTZCORE)
if(IOS OR TVOS)
- find_library(QUARTZCORE QuartzCore)
- list(APPEND EXTRA_LIBS ${QUARTZCORE})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,QuartzCore")
else()
list(APPEND EXTRA_LDFLAGS "-Wl,-weak_framework,QuartzCore")
endif()
endif()
if(SDL_FRAMEWORK_UIKIT)
- find_library(UIKIT UIKit)
- list(APPEND EXTRA_LIBS ${UIKIT})
+ list(APPEND EXTRA_LDFLAGS "-Wl,-framework,UIKit")
endif()
if(SDL_FRAMEWORK_COREHAPTICS)
find_library(COREHAPTICS CoreHaptics)