cmake: fix a bunch of things to properly link without LOADSO enabled. The wrong logic, copy/pasted to a bunch of places, would correctly disable the dynamic loading but fail to specify the libraries that SDL would now need to explicitly link against.
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index ba549c3..36e8b38 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -101,14 +101,13 @@ macro(CheckALSA)
file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
set(SDL_AUDIO_DRIVER_ALSA 1)
- if(ALSA_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
- else()
- FindLibraryAndSONAME("asound")
- set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
- set(HAVE_ALSA_SHARED TRUE)
- endif()
+ if(ALSA_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
+ endif()
+ if(ALSA_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("asound")
+ set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
+ set(HAVE_ALSA_SHARED TRUE)
else()
list(APPEND EXTRA_LIBS asound)
endif()
@@ -131,14 +130,13 @@ macro(CheckPipewire)
set(SOURCE_FILES ${SOURCE_FILES} ${PIPEWIRE_SOURCES})
set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS})
- if(PIPEWIRE_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
- else()
- FindLibraryAndSONAME("pipewire-0.3")
- set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
- set(HAVE_PIPEWIRE_SHARED TRUE)
- endif()
+ if(PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
+ endif()
+ if(PIPEWIRE_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("pipewire-0.3")
+ set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
+ set(HAVE_PIPEWIRE_SHARED TRUE)
else()
list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS})
endif()
@@ -162,14 +160,13 @@ macro(CheckPulseAudio)
set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
- if(PULSEAUDIO_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
- else()
- FindLibraryAndSONAME("pulse-simple")
- set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
- set(HAVE_PULSEAUDIO_SHARED TRUE)
- endif()
+ if(PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
+ endif()
+ if(PULSEAUDIO_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("pulse-simple")
+ set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
+ set(HAVE_PULSEAUDIO_SHARED TRUE)
else()
list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
endif()
@@ -192,14 +189,13 @@ macro(CheckJACK)
set(SOURCE_FILES ${SOURCE_FILES} ${JACK_SOURCES})
set(SDL_AUDIO_DRIVER_JACK 1)
list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS})
- if(JACK_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
- else()
- FindLibraryAndSONAME("jack")
- set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
- set(HAVE_JACK_SHARED TRUE)
- endif()
+ if(JACK_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
+ endif()
+ if(JACK_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("jack")
+ set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
+ set(HAVE_JACK_SHARED TRUE)
else()
list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS})
endif()
@@ -222,16 +218,15 @@ macro(CheckESD)
set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
set(SDL_AUDIO_DRIVER_ESD 1)
list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
- if(ESD_SHARED)
- if(NOT HAVE_SDL_LOADSO)
+ if(ESD_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
- else()
+ endif()
+ if(ESD_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME(esd)
set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
set(HAVE_ESD_SHARED TRUE)
- endif()
else()
- list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
+ list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
endif()
set(HAVE_SDL_AUDIO TRUE)
endif()
@@ -256,15 +251,14 @@ macro(CheckARTS)
set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
set(SDL_AUDIO_DRIVER_ARTS 1)
set(HAVE_ARTS TRUE)
- if(ARTS_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
- else()
- # TODO
- FindLibraryAndSONAME(artsc)
- set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
- set(HAVE_ARTS_SHARED TRUE)
- endif()
+ if(ARTS_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
+ endif()
+ if(ARTS_SHARED AND HAVE_SDL_LOADSO)
+ # TODO
+ FindLibraryAndSONAME(artsc)
+ set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
+ set(HAVE_ARTS_SHARED TRUE)
else()
list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
endif()
@@ -288,14 +282,13 @@ macro(CheckNAS)
file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
set(SDL_AUDIO_DRIVER_NAS 1)
- if(NAS_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
- else()
- FindLibraryAndSONAME("audio")
- set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
- set(HAVE_NAS_SHARED TRUE)
- endif()
+ if(NAS_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
+ endif()
+ if(NAS_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("audio")
+ set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
+ set(HAVE_NAS_SHARED TRUE)
else()
list(APPEND EXTRA_LIBS ${D_NAS_LIB})
endif()
@@ -319,14 +312,13 @@ macro(CheckSNDIO)
file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
set(SDL_AUDIO_DRIVER_SNDIO 1)
- if(SNDIO_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
- else()
- FindLibraryAndSONAME("sndio")
- set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
- set(HAVE_SNDIO_SHARED TRUE)
- endif()
+ if(SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
+ endif()
+ if(SNDIO_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("sndio")
+ set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
+ set(HAVE_SNDIO_SHARED TRUE)
else()
list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
endif()
@@ -349,14 +341,13 @@ macro(CheckFusionSound)
set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
- if(FUSIONSOUND_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
- else()
- FindLibraryAndSONAME("fusionsound")
- set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
- set(HAVE_FUSIONSOUND_SHARED TRUE)
- endif()
+ if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
+ endif()
+ if(FUSIONSOUND_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("fusionsound")
+ set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
+ set(HAVE_FUSIONSOUND_SHARED TRUE)
else()
list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
endif()
@@ -375,14 +366,13 @@ macro(CheckLibSampleRate)
check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)
if(HAVE_LIBSAMPLERATE_H)
set(HAVE_LIBSAMPLERATE TRUE)
- if(LIBSAMPLERATE_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
- else()
- FindLibraryAndSONAME("samplerate")
- set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
- set(HAVE_LIBSAMPLERATE_SHARED TRUE)
- endif()
+ if(LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
+ endif()
+ if(LIBSAMPLERATE_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("samplerate")
+ set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
+ set(HAVE_LIBSAMPLERATE_SHARED TRUE)
else()
list(APPEND EXTRA_LDFLAGS -lsamplerate)
endif()
@@ -668,20 +658,19 @@ macro(CheckWayland)
set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
endif()
- if(WAYLAND_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
- else()
- FindLibraryAndSONAME(wayland-client)
- FindLibraryAndSONAME(wayland-egl)
- FindLibraryAndSONAME(wayland-cursor)
- FindLibraryAndSONAME(xkbcommon)
- set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
- set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
- set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
- set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
- set(HAVE_WAYLAND_SHARED TRUE)
- endif()
+ if(WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
+ endif()
+ if(WAYLAND_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME(wayland-client)
+ FindLibraryAndSONAME(wayland-egl)
+ FindLibraryAndSONAME(wayland-cursor)
+ FindLibraryAndSONAME(xkbcommon)
+ set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
+ set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
+ set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
+ set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
+ set(HAVE_WAYLAND_SHARED TRUE)
else()
set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
endif()
@@ -693,14 +682,13 @@ macro(CheckWayland)
set(HAVE_LIBDECOR_H 1)
link_directories(${LIBDECOR_LIBRARY_DIRS})
include_directories(${LIBDECOR_INCLUDE_DIRS})
- if(LIBDECOR_SHARED)
- if(NOT HAVE_SDL_LOADSO)
+ if(LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
- else()
+ endif()
+ if(LIBDECOR_SHARED AND HAVE_SDL_LOADSO)
set(HAVE_LIBDECOR_SHARED TRUE)
FindLibraryAndSONAME(decor-0)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
- endif()
else()
set(EXTRA_LIBS ${LIBDECOR_LIBRARIES} ${EXTRA_LIBS})
endif()
@@ -745,14 +733,13 @@ macro(CheckDirectFB)
set(SDL_VIDEO_DRIVER_DIRECTFB 1)
set(SDL_VIDEO_RENDER_DIRECTFB 1)
list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
- if(DIRECTFB_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
- else()
- FindLibraryAndSONAME("directfb")
- set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
- set(HAVE_DIRECTFB_SHARED TRUE)
- endif()
+ if(DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
+ endif()
+ if(DIRECTFB_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME("directfb")
+ set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
+ set(HAVE_DIRECTFB_SHARED TRUE)
else()
list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
endif()
@@ -1242,16 +1229,15 @@ macro(CheckKMSDRM)
set(SDL_VIDEO_DRIVER_KMSDRM 1)
- if(KMSDRM_SHARED)
- if(NOT HAVE_SDL_LOADSO)
- message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
- else()
- FindLibraryAndSONAME(drm)
- FindLibraryAndSONAME(gbm)
- set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
- set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
- set(HAVE_KMSDRM_SHARED TRUE)
- endif()
+ if(KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
+ message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
+ endif()
+ if(KMSDRM_SHARED AND HAVE_SDL_LOADSO)
+ FindLibraryAndSONAME(drm)
+ FindLibraryAndSONAME(gbm)
+ set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
+ set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
+ set(HAVE_KMSDRM_SHARED TRUE)
else()
set(EXTRA_LIBS ${KMSDRM_LIBRARIES} ${EXTRA_LIBS})
endif()