cmake: on Apple, don't use find_library for frameworks + use EXTRA_LDFLAGS

This commit is contained in:
Anonymous Maarten 2022-07-25 23:06:52 +02:00 committed by Sam Lantinga
parent 613ce7850e
commit 4690689a4c
1 changed files with 19 additions and 32 deletions

View File

@ -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)