cmake/sdlchecks.cmake
author Sam Lantinga <slouken@libsdl.org>
Fri, 07 Oct 2016 18:03:08 -0700
changeset 10490 24472af11074
parent 10329 ad0bee16b6b9
child 10511 8e646a2d1929
permissions -rw-r--r--
Fixed bug 3043 - fix alsa configury and cmake checks

Ozkan Sezer

SDL's alsa uses snd_pcm_recover() which has been available only since alsa-lib-1.0.11.
icculus@8017
     1
macro(FindLibraryAndSONAME _LIB)
icculus@8017
     2
  string(TOUPPER ${_LIB} _UPPERLNAME)
icculus@8017
     3
  string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
icculus@8017
     4
icculus@8017
     5
  find_library(${_LNAME}_LIB ${_LIB})
icculus@8017
     6
  if(${_LNAME}_LIB)
icculus@8017
     7
    # reduce the library name for shared linking
icculus@8017
     8
icculus@8017
     9
    get_filename_component(_LIB_REALPATH ${${_LNAME}_LIB} REALPATH)  # resolves symlinks
icculus@8017
    10
    get_filename_component(_LIB_JUSTNAME ${_LIB_REALPATH} NAME)
icculus@8017
    11
icculus@8017
    12
    if(APPLE)
icculus@8017
    13
      string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*dylib$" "\\1.dylib" _LIB_REGEXD "${_LIB_JUSTNAME}")
icculus@8017
    14
    else()
icculus@8017
    15
      string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*$" "\\1" _LIB_REGEXD "${_LIB_JUSTNAME}")
icculus@8017
    16
    endif()
icculus@8017
    17
icculus@8017
    18
    SET(_DEBUG_FindSONAME FALSE)
icculus@8017
    19
    if(_DEBUG_FindSONAME)
icculus@8017
    20
      message_warn("DYNLIB OUTPUTVAR: ${_LIB} ... ${_LNAME}_LIB")
icculus@8017
    21
      message_warn("DYNLIB ORIGINAL LIB: ${_LIB} ... ${${_LNAME}_LIB}")
icculus@8017
    22
      message_warn("DYNLIB REALPATH LIB: ${_LIB} ... ${_LIB_REALPATH}")
icculus@8017
    23
      message_warn("DYNLIB JUSTNAME LIB: ${_LIB} ... ${_LIB_JUSTNAME}")
icculus@8017
    24
      message_warn("DYNLIB REGEX'd LIB: ${_LIB} ... ${_LIB_REGEXD}")
icculus@8017
    25
    endif()
icculus@8017
    26
icculus@8017
    27
    message(STATUS "dynamic lib${_LIB} -> ${_LIB_REGEXD}")
icculus@8017
    28
    set(${_LNAME}_LIB_SONAME ${_LIB_REGEXD})
icculus@8017
    29
  endif()
icculus@8017
    30
endmacro()
icculus@8017
    31
gabomdq@6674
    32
macro(CheckDLOPEN)
gabomdq@6674
    33
  check_function_exists(dlopen HAVE_DLOPEN)
gabomdq@6674
    34
  if(NOT HAVE_DLOPEN)
gabomdq@6674
    35
    foreach(_LIBNAME dl tdl)
gabomdq@6674
    36
      check_library_exists("${_LIBNAME}" "dlopen" "" DLOPEN_LIB)
gabomdq@6674
    37
      if(DLOPEN_LIB)
gabomdq@6674
    38
        list(APPEND EXTRA_LIBS ${_LIBNAME})
gabomdq@6674
    39
        set(_DLLIB ${_LIBNAME})
gabomdq@6674
    40
        set(HAVE_DLOPEN TRUE)
gabomdq@6674
    41
        break()
icculus@9277
    42
      endif()
gabomdq@6674
    43
    endforeach()
gabomdq@6674
    44
  endif()
gabomdq@6674
    45
gabomdq@6674
    46
  if(HAVE_DLOPEN)
gabomdq@6674
    47
    if(_DLLIB)
gabomdq@6674
    48
      set(CMAKE_REQUIRED_LIBRARIES ${_DLLIB})
gabomdq@6674
    49
    endif()
gabomdq@6674
    50
    check_c_source_compiles("
gabomdq@6674
    51
       #include <dlfcn.h>
jorgen@7507
    52
       int main(int argc, char **argv) {
jorgen@7521
    53
         void *handle = dlopen(\"\", RTLD_NOW);
jorgen@7507
    54
         const char *loaderror = (char *) dlerror();
jorgen@7507
    55
       }" HAVE_DLOPEN)
gabomdq@6674
    56
    set(CMAKE_REQUIRED_LIBRARIES)
gabomdq@6674
    57
  endif()
gabomdq@6674
    58
gabomdq@6674
    59
  if (HAVE_DLOPEN)
gabomdq@6674
    60
    set(SDL_LOADSO_DLOPEN 1)
gabomdq@6674
    61
    set(HAVE_SDL_DLOPEN TRUE)
gabomdq@6674
    62
    file(GLOB DLOPEN_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
gabomdq@6674
    63
    set(SOURCE_FILES ${SOURCE_FILES} ${DLOPEN_SOURCES})
gabomdq@6674
    64
    set(HAVE_SDL_LOADSO TRUE)
gabomdq@6674
    65
  endif()
icculus@9277
    66
endmacro()
gabomdq@6674
    67
gabomdq@6674
    68
# Requires:
gabomdq@6674
    69
# - n/a
gabomdq@6674
    70
macro(CheckOSS)
gabomdq@6674
    71
  if(OSS)
gabomdq@6674
    72
    set(OSS_HEADER_FILE "sys/soundcard.h")
gabomdq@6674
    73
    check_c_source_compiles("
gabomdq@6674
    74
        #include <sys/soundcard.h>
gabomdq@6674
    75
        int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
gabomdq@6674
    76
    if(NOT OSS_FOUND)
gabomdq@6674
    77
      set(OSS_HEADER_FILE "soundcard.h")
gabomdq@6674
    78
      check_c_source_compiles("
gabomdq@6674
    79
          #include <soundcard.h>
gabomdq@6674
    80
          int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
icculus@9277
    81
    endif()
gabomdq@6674
    82
gabomdq@6674
    83
    if(OSS_FOUND)
gabomdq@6674
    84
      set(HAVE_OSS TRUE)
gabomdq@6674
    85
      file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
gabomdq@6674
    86
      if(OSS_HEADER_FILE STREQUAL "soundcard.h")
gabomdq@6674
    87
        set(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H 1)
icculus@9277
    88
      endif()
gabomdq@6674
    89
      set(SDL_AUDIO_DRIVER_OSS 1)
gabomdq@6674
    90
      set(SOURCE_FILES ${SOURCE_FILES} ${OSS_SOURCES})
gabomdq@6674
    91
      if(NETBSD OR OPENBSD)
gabomdq@6674
    92
        list(APPEND EXTRA_LIBS ossaudio)
icculus@9277
    93
      endif()
gabomdq@6674
    94
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
    95
    endif()
icculus@9277
    96
  endif()
icculus@9277
    97
endmacro()
gabomdq@6674
    98
gabomdq@6674
    99
# Requires:
gabomdq@6674
   100
# - n/a
gabomdq@6674
   101
# Optional:
gabomdq@6674
   102
# - ALSA_SHARED opt
gabomdq@6674
   103
# - HAVE_DLOPEN opt
gabomdq@6674
   104
macro(CheckALSA)
gabomdq@6674
   105
  if(ALSA)
gabomdq@6674
   106
    CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
gabomdq@6674
   107
    if(HAVE_ASOUNDLIB_H)
slouken@10490
   108
      CHECK_LIBRARY_EXISTS(asound snd_pcm_recover "" HAVE_LIBASOUND)
slouken@10490
   109
    endif()
slouken@10490
   110
    if(HAVE_LIBASOUND)
gabomdq@6674
   111
      set(HAVE_ALSA TRUE)
gabomdq@6674
   112
      file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
gabomdq@6674
   113
      set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
gabomdq@6674
   114
      set(SDL_AUDIO_DRIVER_ALSA 1)
gabomdq@6674
   115
      if(ALSA_SHARED)
gabomdq@6674
   116
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   117
          message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
gabomdq@6674
   118
        else()
icculus@8017
   119
          FindLibraryAndSONAME("asound")
icculus@8017
   120
          set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
gabomdq@6674
   121
          set(HAVE_ALSA_SHARED TRUE)
icculus@9277
   122
        endif()
icculus@9277
   123
      else()
gabomdq@6674
   124
        list(APPEND EXTRA_LIBS asound)
icculus@9277
   125
      endif()
gabomdq@6674
   126
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
   127
    endif()
icculus@9277
   128
  endif()
icculus@9277
   129
endmacro()
gabomdq@6674
   130
gabomdq@6674
   131
# Requires:
gabomdq@6674
   132
# - PkgCheckModules
gabomdq@6674
   133
# Optional:
gabomdq@6674
   134
# - PULSEAUDIO_SHARED opt
gabomdq@6674
   135
# - HAVE_DLOPEN opt
gabomdq@6674
   136
macro(CheckPulseAudio)
gabomdq@6674
   137
  if(PULSEAUDIO)
gabomdq@6674
   138
    pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
gabomdq@6674
   139
    if(PKG_PULSEAUDIO_FOUND)
gabomdq@6674
   140
      set(HAVE_PULSEAUDIO TRUE)
gabomdq@6674
   141
      file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c)
gabomdq@6674
   142
      set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
gabomdq@6674
   143
      set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
gabomdq@6674
   144
      list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
gabomdq@6674
   145
      if(PULSEAUDIO_SHARED)
gabomdq@6674
   146
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   147
          message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
gabomdq@6674
   148
        else()
icculus@8017
   149
          FindLibraryAndSONAME("pulse-simple")
icculus@8017
   150
          set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
gabomdq@6674
   151
          set(HAVE_PULSEAUDIO_SHARED TRUE)
icculus@9277
   152
        endif()
icculus@9277
   153
      else()
gabomdq@6674
   154
        list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
icculus@9277
   155
      endif()
gabomdq@6674
   156
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
   157
    endif()
icculus@9277
   158
  endif()
icculus@9277
   159
endmacro()
gabomdq@6674
   160
gabomdq@6674
   161
# Requires:
gabomdq@6674
   162
# - PkgCheckModules
gabomdq@6674
   163
# Optional:
gabomdq@6674
   164
# - ESD_SHARED opt
gabomdq@6674
   165
# - HAVE_DLOPEN opt
gabomdq@6674
   166
macro(CheckESD)
gabomdq@6674
   167
  if(ESD)
gabomdq@6674
   168
    pkg_check_modules(PKG_ESD esound)
gabomdq@6674
   169
    if(PKG_ESD_FOUND)
gabomdq@6674
   170
      set(HAVE_ESD TRUE)
gabomdq@6674
   171
      file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c)
gabomdq@6674
   172
      set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
gabomdq@6674
   173
      set(SDL_AUDIO_DRIVER_ESD 1)
gabomdq@6674
   174
      list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
gabomdq@6674
   175
      if(ESD_SHARED)
gabomdq@6674
   176
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   177
          message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
gabomdq@6674
   178
        else()
icculus@8017
   179
          FindLibraryAndSONAME(esd)
icculus@8017
   180
          set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
gabomdq@6674
   181
          set(HAVE_ESD_SHARED TRUE)
icculus@9277
   182
        endif()
icculus@9277
   183
      else()
gabomdq@6674
   184
        list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
icculus@9277
   185
      endif()
gabomdq@6674
   186
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
   187
    endif()
icculus@9277
   188
  endif()
icculus@9277
   189
endmacro()
gabomdq@6674
   190
gabomdq@6674
   191
# Requires:
gabomdq@6674
   192
# - n/a
gabomdq@6674
   193
# Optional:
gabomdq@6674
   194
# - ARTS_SHARED opt
gabomdq@6674
   195
# - HAVE_DLOPEN opt
gabomdq@6674
   196
macro(CheckARTS)
gabomdq@6674
   197
  if(ARTS)
gabomdq@6674
   198
    find_program(ARTS_CONFIG arts-config)
gabomdq@6674
   199
    if(ARTS_CONFIG)
gabomdq@6674
   200
      execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
gabomdq@6674
   201
        OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
gabomdq@6674
   202
      list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS})
gabomdq@6674
   203
      execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs
gabomdq@6674
   204
        OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
gabomdq@6674
   205
      file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c)
gabomdq@6674
   206
      set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
gabomdq@6674
   207
      set(SDL_AUDIO_DRIVER_ARTS 1)
gabomdq@6674
   208
      set(HAVE_ARTS TRUE)
gabomdq@6674
   209
      if(ARTS_SHARED)
gabomdq@6674
   210
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   211
          message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
gabomdq@6674
   212
        else()
gabomdq@6674
   213
          # TODO
icculus@8017
   214
          FindLibraryAndSONAME(artsc)
icculus@8017
   215
          set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
gabomdq@6674
   216
          set(HAVE_ARTS_SHARED TRUE)
icculus@9277
   217
        endif()
icculus@9277
   218
      else()
gabomdq@6674
   219
        list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
icculus@9277
   220
      endif()
gabomdq@6674
   221
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
   222
    endif()
icculus@9277
   223
  endif()
icculus@9277
   224
endmacro()
gabomdq@6674
   225
gabomdq@6674
   226
# Requires:
gabomdq@6674
   227
# - n/a
gabomdq@6674
   228
# Optional:
gabomdq@6674
   229
# - NAS_SHARED opt
gabomdq@6674
   230
# - HAVE_DLOPEN opt
gabomdq@6674
   231
macro(CheckNAS)
gabomdq@6674
   232
  if(NAS)
gabomdq@6674
   233
    # TODO: set include paths properly, so the NAS headers are found
gabomdq@6674
   234
    check_include_file(audio/audiolib.h HAVE_NAS_H)
gabomdq@6674
   235
    find_library(D_NAS_LIB audio)
gabomdq@6674
   236
    if(HAVE_NAS_H AND D_NAS_LIB)
gabomdq@6674
   237
      set(HAVE_NAS TRUE)
gabomdq@6674
   238
      file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
gabomdq@6674
   239
      set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
gabomdq@6674
   240
      set(SDL_AUDIO_DRIVER_NAS 1)
gabomdq@6674
   241
      if(NAS_SHARED)
gabomdq@6674
   242
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   243
          message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
gabomdq@6674
   244
        else()
icculus@8017
   245
          FindLibraryAndSONAME("audio")
icculus@8017
   246
          set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
gabomdq@6674
   247
          set(HAVE_NAS_SHARED TRUE)
icculus@9277
   248
        endif()
icculus@9277
   249
      else()
gabomdq@6674
   250
        list(APPEND EXTRA_LIBS ${D_NAS_LIB})
icculus@9277
   251
      endif()
gabomdq@6674
   252
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
   253
    endif()
icculus@9277
   254
  endif()
icculus@9277
   255
endmacro()
gabomdq@6674
   256
gabomdq@6674
   257
# Requires:
icculus@7367
   258
# - n/a
icculus@7367
   259
# Optional:
icculus@7367
   260
# - SNDIO_SHARED opt
icculus@7367
   261
# - HAVE_DLOPEN opt
icculus@7367
   262
macro(CheckSNDIO)
icculus@7367
   263
  if(SNDIO)
icculus@7367
   264
    # TODO: set include paths properly, so the sndio headers are found
icculus@7367
   265
    check_include_file(sndio.h HAVE_SNDIO_H)
icculus@8017
   266
    find_library(D_SNDIO_LIB sndio)
icculus@7367
   267
    if(HAVE_SNDIO_H AND D_SNDIO_LIB)
icculus@7367
   268
      set(HAVE_SNDIO TRUE)
icculus@7367
   269
      file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
icculus@7367
   270
      set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
icculus@7367
   271
      set(SDL_AUDIO_DRIVER_SNDIO 1)
icculus@7367
   272
      if(SNDIO_SHARED)
icculus@7367
   273
        if(NOT HAVE_DLOPEN)
icculus@7367
   274
          message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
icculus@7367
   275
        else()
icculus@8017
   276
          FindLibraryAndSONAME("sndio")
icculus@8017
   277
          set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
icculus@7367
   278
          set(HAVE_SNDIO_SHARED TRUE)
icculus@9277
   279
        endif()
icculus@9277
   280
      else()
icculus@7367
   281
        list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
icculus@9277
   282
      endif()
icculus@7367
   283
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
   284
    endif()
icculus@9277
   285
  endif()
icculus@9277
   286
endmacro()
icculus@7367
   287
icculus@7367
   288
# Requires:
gabomdq@6674
   289
# - PkgCheckModules
gabomdq@6674
   290
# Optional:
gabomdq@6674
   291
# - FUSIONSOUND_SHARED opt
gabomdq@6674
   292
# - HAVE_DLOPEN opt
gabomdq@6674
   293
macro(CheckFusionSound)
gabomdq@6674
   294
  if(FUSIONSOUND)
gabomdq@6674
   295
    pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0)
gabomdq@6674
   296
    if(PKG_FUSIONSOUND_FOUND)
gabomdq@6674
   297
      set(HAVE_FUSIONSOUND TRUE)
gabomdq@6674
   298
      file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c)
gabomdq@6674
   299
      set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
gabomdq@6674
   300
      set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
gabomdq@6674
   301
      list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
gabomdq@6674
   302
      if(FUSIONSOUND_SHARED)
gabomdq@6674
   303
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   304
          message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
gabomdq@6674
   305
        else()
icculus@8017
   306
          FindLibraryAndSONAME("fusionsound")
icculus@8017
   307
          set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
gabomdq@6674
   308
          set(HAVE_FUSIONSOUND_SHARED TRUE)
icculus@9277
   309
        endif()
icculus@9277
   310
      else()
gabomdq@6674
   311
        list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
icculus@9277
   312
      endif()
gabomdq@6674
   313
      set(HAVE_SDL_AUDIO TRUE)
icculus@9277
   314
    endif()
icculus@9277
   315
  endif()
icculus@9277
   316
endmacro()
gabomdq@6674
   317
gabomdq@6674
   318
# Requires:
gabomdq@6674
   319
# - n/a
gabomdq@6674
   320
# Optional:
gabomdq@6674
   321
# - X11_SHARED opt
gabomdq@6674
   322
# - HAVE_DLOPEN opt
gabomdq@6674
   323
macro(CheckX11)
gabomdq@6674
   324
  if(VIDEO_X11)
gabomdq@6674
   325
    foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
icculus@8017
   326
        FindLibraryAndSONAME("${_LIB}")
gabomdq@6674
   327
    endforeach()
gabomdq@6674
   328
slouken@7835
   329
    find_path(X_INCLUDEDIR X11/Xlib.h)
slouken@7835
   330
    if(X_INCLUDEDIR)
slouken@7835
   331
      set(X_CFLAGS "-I${X_INCLUDEDIR}")
slouken@7835
   332
    endif()
slouken@7835
   333
gabomdq@6674
   334
    check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
gabomdq@6674
   335
    check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
gabomdq@6674
   336
    check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H)
gabomdq@6674
   337
    check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
gabomdq@6674
   338
    check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
gabomdq@6674
   339
    check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
gabomdq@6674
   340
    check_include_file(X11/extensions/shape.h HAVE_XSHAPE_H)
gabomdq@6674
   341
    check_include_files("X11/Xlib.h;X11/extensions/xf86vmode.h" HAVE_XF86VM_H)
icculus@7438
   342
    check_include_files("X11/Xlib.h;X11/Xproto.h;X11/extensions/Xext.h" HAVE_XEXT_H)
gabomdq@6674
   343
gabomdq@6674
   344
    if(X11_LIB)
icculus@7438
   345
      if(NOT HAVE_XEXT_H)
icculus@7438
   346
        message_error("Missing Xext.h, maybe you need to install the libxext-dev package?")
icculus@7438
   347
      endif()
icculus@7438
   348
gabomdq@6674
   349
      set(HAVE_VIDEO_X11 TRUE)
gabomdq@6674
   350
      set(HAVE_SDL_VIDEO TRUE)
gabomdq@6674
   351
gabomdq@6674
   352
      file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
gabomdq@6674
   353
      set(SOURCE_FILES ${SOURCE_FILES} ${X11_SOURCES})
gabomdq@6674
   354
      set(SDL_VIDEO_DRIVER_X11 1)
gabomdq@6674
   355
gabomdq@6674
   356
      if(APPLE)
gabomdq@6674
   357
        set(X11_SHARED OFF)
icculus@9277
   358
      endif()
gabomdq@6674
   359
gabomdq@6674
   360
      check_function_exists("shmat" HAVE_SHMAT)
gabomdq@6674
   361
      if(NOT HAVE_SHMAT)
gabomdq@6674
   362
        check_library_exists(ipc shmat "" HAVE_SHMAT)
gabomdq@6674
   363
        if(HAVE_SHMAT)
gabomdq@6674
   364
          list(APPEND EXTRA_LIBS ipc)
icculus@9277
   365
        endif()
gabomdq@6674
   366
        if(NOT HAVE_SHMAT)
gabomdq@6674
   367
          add_definitions(-DNO_SHARED_MEMORY)
slouken@7835
   368
          set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY")
icculus@9277
   369
        endif()
icculus@9277
   370
      endif()
gabomdq@6674
   371
gabomdq@6674
   372
      if(X11_SHARED)
gabomdq@6674
   373
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   374
          message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
gabomdq@6674
   375
          set(HAVE_X11_SHARED FALSE)
icculus@9277
   376
        else()
gabomdq@6674
   377
          set(HAVE_X11_SHARED TRUE)
gabomdq@6674
   378
        endif()
gabomdq@6674
   379
        if(HAVE_X11_SHARED)
icculus@8017
   380
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
icculus@8017
   381
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
icculus@9277
   382
        else()
gabomdq@6674
   383
          list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
icculus@9277
   384
        endif()
icculus@9277
   385
      endif()
gabomdq@6674
   386
slouken@7835
   387
      set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}")
slouken@7835
   388
gabomdq@6674
   389
      set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
gabomdq@6674
   390
      check_c_source_compiles("
gabomdq@6674
   391
          #include <X11/Xlib.h>
gabomdq@6674
   392
          #include <X11/Xproto.h>
gabomdq@6674
   393
          #include <X11/extensions/Xext.h>
gabomdq@6674
   394
          #include <X11/extensions/extutil.h>
gabomdq@6674
   395
          extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
gabomdq@6674
   396
          int main(int argc, char **argv) {}" HAVE_CONST_XEXT_ADDDISPLAY)
gabomdq@6674
   397
      if(HAVE_CONST_XEXT_ADDDISPLAY)
gabomdq@6674
   398
        set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1)
icculus@9277
   399
      endif()
gabomdq@6674
   400
gabomdq@6674
   401
      check_c_source_compiles("
gabomdq@6674
   402
          #include <X11/Xlib.h>
gabomdq@6674
   403
          int main(int argc, char **argv) {
gabomdq@6674
   404
            Display *display;
gabomdq@6674
   405
            XEvent event;
gabomdq@6674
   406
            XGenericEventCookie *cookie = &event.xcookie;
gabomdq@6674
   407
            XNextEvent(display, &event);
gabomdq@6674
   408
            XGetEventData(display, cookie);
gabomdq@6674
   409
            XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
gabomdq@6674
   410
      if(HAVE_XGENERICEVENT)
gabomdq@6674
   411
        set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
icculus@9277
   412
      endif()
gabomdq@6674
   413
gabomdq@6674
   414
      check_function_exists(XkbKeycodeToKeysym SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
gabomdq@6674
   415
gabomdq@6674
   416
      if(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
gabomdq@6674
   417
        set(HAVE_VIDEO_X11_XCURSOR TRUE)
gabomdq@6674
   418
        if(HAVE_X11_SHARED AND XCURSOR_LIB)
icculus@8017
   419
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
icculus@9277
   420
        else()
gabomdq@6674
   421
          list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
icculus@9277
   422
        endif()
gabomdq@6674
   423
        set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
icculus@9277
   424
      endif()
gabomdq@6674
   425
gabomdq@6674
   426
      if(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
gabomdq@6674
   427
        set(HAVE_VIDEO_X11_XINERAMA TRUE)
gabomdq@6674
   428
        if(HAVE_X11_SHARED AND XINERAMA_LIB)
icculus@8017
   429
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB_SONAME}\"")
icculus@9277
   430
        else()
gabomdq@6674
   431
          list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
icculus@9277
   432
        endif()
gabomdq@6674
   433
        set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
icculus@9277
   434
      endif()
gabomdq@6674
   435
gabomdq@6674
   436
      if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
gabomdq@6674
   437
        set(HAVE_VIDEO_X11_XINPUT TRUE)
gabomdq@6674
   438
        if(HAVE_X11_SHARED AND XI_LIB)
icculus@8017
   439
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
icculus@9277
   440
        else()
gabomdq@6674
   441
          list(APPEND EXTRA_LIBS ${XI_LIB})
icculus@9277
   442
        endif()
gabomdq@6674
   443
        set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
gabomdq@6674
   444
gabomdq@6674
   445
        # Check for multitouch
gabomdq@6674
   446
        check_c_source_compiles("
gabomdq@6674
   447
            #include <X11/Xlib.h>
gabomdq@6674
   448
            #include <X11/Xproto.h>
gabomdq@6674
   449
            #include <X11/extensions/XInput2.h>
gabomdq@6674
   450
            int event_type = XI_TouchBegin;
gabomdq@6674
   451
            XITouchClassInfo *t;
gabomdq@6674
   452
            Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
gabomdq@6674
   453
            {
gabomdq@6674
   454
              return (Status)0;
gabomdq@6674
   455
            }
gabomdq@6674
   456
            int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
gabomdq@6674
   457
        if(HAVE_XINPUT2_MULTITOUCH)
gabomdq@6674
   458
          set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
icculus@9277
   459
        endif()
icculus@9277
   460
      endif()
gabomdq@6674
   461
gabomdq@6674
   462
      if(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
gabomdq@6674
   463
        if(HAVE_X11_SHARED AND XRANDR_LIB)
icculus@8017
   464
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
icculus@9277
   465
        else()
gabomdq@6674
   466
          list(APPEND EXTRA_LIBS ${XRANDR_LIB})
icculus@9277
   467
        endif()
gabomdq@6674
   468
        set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
gabomdq@6674
   469
        set(HAVE_VIDEO_X11_XRANDR TRUE)
icculus@9277
   470
      endif()
gabomdq@6674
   471
gabomdq@6674
   472
      if(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
gabomdq@6674
   473
        if(HAVE_X11_SHARED AND XSS_LIB)
icculus@8017
   474
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
icculus@9277
   475
        else()
gabomdq@6674
   476
          list(APPEND EXTRA_LIBS ${XSS_LIB})
icculus@9277
   477
        endif()
gabomdq@6674
   478
        set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
gabomdq@6674
   479
        set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
icculus@9277
   480
      endif()
gabomdq@6674
   481
gabomdq@6674
   482
      if(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
gabomdq@6674
   483
        set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
gabomdq@6674
   484
        set(HAVE_VIDEO_X11_XSHAPE TRUE)
icculus@9277
   485
      endif()
gabomdq@6674
   486
gabomdq@6674
   487
      if(VIDEO_X11_XVM AND HAVE_XF86VM_H)
icculus@8120
   488
        if(HAVE_X11_SHARED AND XXF86VM_LIB)
icculus@8120
   489
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XXF86VM_LIB_SONAME}\"")
icculus@9277
   490
        else()
icculus@8120
   491
          list(APPEND EXTRA_LIBS ${XXF86VM_LIB})
icculus@9277
   492
        endif()
gabomdq@6674
   493
        set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
gabomdq@6674
   494
        set(HAVE_VIDEO_X11_XVM TRUE)
icculus@9277
   495
      endif()
gabomdq@6674
   496
gabomdq@6674
   497
      set(CMAKE_REQUIRED_LIBRARIES)
icculus@9277
   498
    endif()
icculus@9277
   499
  endif()
icculus@9277
   500
endmacro()
gabomdq@6674
   501
icculus@9409
   502
# Requires:
icculus@9409
   503
# - EGL
icculus@9409
   504
# - PkgCheckModules
icculus@9409
   505
# Optional:
icculus@9409
   506
# - MIR_SHARED opt
icculus@9409
   507
# - HAVE_DLOPEN opt
icculus@8153
   508
macro(CheckMir)
icculus@8153
   509
    if(VIDEO_MIR)
icculus@8153
   510
        find_library(MIR_LIB mirclient mircommon egl)
icculus@8153
   511
        pkg_check_modules(MIR_TOOLKIT mirclient mircommon)
icculus@8153
   512
        pkg_check_modules(EGL egl)
icculus@8153
   513
        pkg_check_modules(XKB xkbcommon)
icculus@8153
   514
icculus@8153
   515
        if (MIR_LIB AND MIR_TOOLKIT_FOUND AND EGL_FOUND AND XKB_FOUND)
icculus@8153
   516
            set(HAVE_VIDEO_MIR TRUE)
icculus@8153
   517
            set(HAVE_SDL_VIDEO TRUE)
icculus@8153
   518
icculus@8153
   519
            file(GLOB MIR_SOURCES ${SDL2_SOURCE_DIR}/src/video/mir/*.c)
icculus@8153
   520
            set(SOURCE_FILES ${SOURCE_FILES} ${MIR_SOURCES})
icculus@8153
   521
            set(SDL_VIDEO_DRIVER_MIR 1)
icculus@8153
   522
icculus@8153
   523
            list(APPEND EXTRA_CFLAGS ${MIR_TOOLKIT_CFLAGS} ${EGL_CLFAGS} ${XKB_CLFLAGS})
icculus@9409
   524
icculus@9409
   525
            if(MIR_SHARED)
icculus@9409
   526
                if(NOT HAVE_DLOPEN)
icculus@9409
   527
                    message_warn("You must have SDL_LoadObject() support for dynamic Mir loading")
icculus@9409
   528
                else()
icculus@9409
   529
                    FindLibraryAndSONAME(mirclient)
icculus@9409
   530
                    FindLibraryAndSONAME(xkbcommon)
icculus@9409
   531
                    set(SDL_VIDEO_DRIVER_MIR_DYNAMIC "\"${MIRCLIENT_LIB_SONAME}\"")
icculus@9409
   532
                    set(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
icculus@9409
   533
                    set(HAVE_MIR_SHARED TRUE)
icculus@9409
   534
                endif()
icculus@9409
   535
            else()
icculus@9409
   536
                set(EXTRA_LIBS ${MIR_TOOLKIT_LIBRARIES} ${EXTRA_LIBS})
icculus@9409
   537
            endif()
icculus@9409
   538
        endif()
icculus@9277
   539
    endif()
icculus@9277
   540
endmacro()
icculus@8153
   541
gabomdq@6674
   542
# Requires:
gabomdq@8062
   543
# - EGL
icculus@9409
   544
# - PkgCheckModules
icculus@9409
   545
# Optional:
icculus@9409
   546
# - WAYLAND_SHARED opt
icculus@9409
   547
# - HAVE_DLOPEN opt
gabomdq@8062
   548
macro(CheckWayland)
gabomdq@8062
   549
  if(VIDEO_WAYLAND)
gabomdq@8062
   550
    pkg_check_modules(WAYLAND wayland-client wayland-cursor wayland-egl egl xkbcommon)
gabomdq@8062
   551
    if(WAYLAND_FOUND)
gabomdq@8062
   552
      link_directories(
gabomdq@8062
   553
          ${WAYLAND_LIBRARY_DIRS}
gabomdq@8062
   554
      )
gabomdq@8062
   555
      include_directories(
gabomdq@8062
   556
          ${WAYLAND_INCLUDE_DIRS}
gabomdq@8062
   557
      )
gabomdq@8062
   558
      set(HAVE_VIDEO_WAYLAND TRUE)
gabomdq@8062
   559
      set(HAVE_SDL_VIDEO TRUE)
gabomdq@8062
   560
gabomdq@8062
   561
      file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
gabomdq@8062
   562
      set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
icculus@9409
   563
icculus@9409
   564
      if(VIDEO_WAYLAND_QT_TOUCH)
icculus@9409
   565
          set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
icculus@9409
   566
      endif()
icculus@9409
   567
icculus@9409
   568
      if(WAYLAND_SHARED)
icculus@9409
   569
        if(NOT HAVE_DLOPEN)
icculus@9409
   570
          message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
icculus@9409
   571
        else()
icculus@9409
   572
          FindLibraryAndSONAME(wayland-client)
icculus@9409
   573
          FindLibraryAndSONAME(wayland-egl)
icculus@9409
   574
          FindLibraryAndSONAME(wayland-cursor)
icculus@9409
   575
          FindLibraryAndSONAME(xkbcommon)
icculus@9409
   576
          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
icculus@9409
   577
          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
icculus@9409
   578
          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
icculus@9409
   579
          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
icculus@9409
   580
          set(HAVE_WAYLAND_SHARED TRUE)
icculus@9409
   581
        endif()
icculus@9409
   582
      else()
icculus@9409
   583
        set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
icculus@9409
   584
      endif()
icculus@9409
   585
gabomdq@8062
   586
      set(SDL_VIDEO_DRIVER_WAYLAND 1)
icculus@9277
   587
    endif()
icculus@9277
   588
  endif()
icculus@9277
   589
endmacro()
gabomdq@8062
   590
gabomdq@8062
   591
# Requires:
gabomdq@6674
   592
# - n/a
gabomdq@6674
   593
#
gabomdq@6674
   594
macro(CheckCOCOA)
gabomdq@6674
   595
  if(VIDEO_COCOA)
icculus@8244
   596
    if(APPLE) # Apple always has Cocoa.
icculus@8244
   597
      set(HAVE_VIDEO_COCOA TRUE)
icculus@9277
   598
    endif()
gabomdq@6674
   599
    if(HAVE_VIDEO_COCOA)
gabomdq@6674
   600
      file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
slouken@7182
   601
      set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
gabomdq@6674
   602
      set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
gabomdq@6674
   603
      set(SDL_VIDEO_DRIVER_COCOA 1)
gabomdq@6674
   604
      set(HAVE_SDL_VIDEO TRUE)
icculus@9277
   605
    endif()
icculus@9277
   606
  endif()
icculus@9277
   607
endmacro()
gabomdq@6674
   608
gabomdq@6674
   609
# Requires:
gabomdq@6674
   610
# - PkgCheckModules
gabomdq@6674
   611
# Optional:
gabomdq@6674
   612
# - DIRECTFB_SHARED opt
gabomdq@6674
   613
# - HAVE_DLOPEN opt
gabomdq@6674
   614
macro(CheckDirectFB)
gabomdq@6674
   615
  if(VIDEO_DIRECTFB)
gabomdq@6674
   616
    pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
gabomdq@6674
   617
    if(PKG_DIRECTFB_FOUND)
gabomdq@6674
   618
      set(HAVE_VIDEO_DIRECTFB TRUE)
gabomdq@6674
   619
      file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
gabomdq@6674
   620
      set(SOURCE_FILES ${SOURCE_FILES} ${DIRECTFB_SOURCES})
gabomdq@6674
   621
      set(SDL_VIDEO_DRIVER_DIRECTFB 1)
gabomdq@6674
   622
      set(SDL_VIDEO_RENDER_DIRECTFB 1)
gabomdq@6674
   623
      list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
gabomdq@6674
   624
      if(DIRECTFB_SHARED)
gabomdq@6674
   625
        if(NOT HAVE_DLOPEN)
gabomdq@6674
   626
          message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
gabomdq@6674
   627
        else()
icculus@8017
   628
          FindLibraryAndSONAME("directfb")
icculus@8017
   629
          set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
gabomdq@6674
   630
          set(HAVE_DIRECTFB_SHARED TRUE)
icculus@9277
   631
        endif()
icculus@9277
   632
      else()
gabomdq@6674
   633
        list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
icculus@9277
   634
      endif()
gabomdq@6674
   635
      set(HAVE_SDL_VIDEO TRUE)
icculus@9277
   636
    endif()
icculus@9277
   637
  endif()
icculus@9277
   638
endmacro()
gabomdq@6674
   639
gabomdq@6674
   640
# Requires:
denis@9127
   641
# - n/a
slouken@9164
   642
macro(CheckVivante)
slouken@9164
   643
  if(VIDEO_VIVANTE)
denis@9127
   644
    check_c_source_compiles("
slouken@9164
   645
        #include <gc_vdk.h>
slouken@9164
   646
        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_VDK)
slouken@9164
   647
    check_c_source_compiles("
slouken@9164
   648
        #define LINUX
denis@9127
   649
        #define EGL_API_FB
denis@9127
   650
        #include <EGL/eglvivante.h>
slouken@9164
   651
        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_EGL_FB)
slouken@9164
   652
    if(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
slouken@9164
   653
      set(HAVE_VIDEO_VIVANTE TRUE)
denis@9127
   654
      set(HAVE_SDL_VIDEO TRUE)
denis@9127
   655
slouken@9164
   656
      file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
slouken@9164
   657
      set(SOURCE_FILES ${SOURCE_FILES} ${VIVANTE_SOURCES})
slouken@9164
   658
      set(SDL_VIDEO_DRIVER_VIVANTE 1)
slouken@9164
   659
      if(HAVE_VIDEO_VIVANTE_VDK)
slouken@9164
   660
        set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
slouken@9164
   661
        list(APPEND EXTRA_LIBS VDK VIVANTE)
philipp@9170
   662
      else()
slouken@9164
   663
        set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
slouken@9164
   664
        list(APPEND EXTRA_LIBS EGL)
slouken@9164
   665
      endif(HAVE_VIDEO_VIVANTE_VDK)
slouken@9164
   666
    endif(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
slouken@9164
   667
  endif(VIDEO_VIVANTE)
slouken@9164
   668
endmacro(CheckVivante)
denis@9127
   669
denis@9127
   670
# Requires:
gabomdq@6674
   671
# - nada
gabomdq@6674
   672
macro(CheckOpenGLX11)
gabomdq@6674
   673
  if(VIDEO_OPENGL)
gabomdq@6674
   674
    check_c_source_compiles("
gabomdq@6674
   675
        #include <GL/gl.h>
gabomdq@6674
   676
        #include <GL/glx.h>
gabomdq@6674
   677
        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL)
gabomdq@6674
   678
gabomdq@6674
   679
    if(HAVE_VIDEO_OPENGL)
gabomdq@6674
   680
      set(HAVE_VIDEO_OPENGL TRUE)
gabomdq@6674
   681
      set(SDL_VIDEO_OPENGL 1)
gabomdq@6674
   682
      set(SDL_VIDEO_OPENGL_GLX 1)
gabomdq@6674
   683
      set(SDL_VIDEO_RENDER_OGL 1)
icculus@9277
   684
    endif()
icculus@9277
   685
  endif()
icculus@9277
   686
endmacro()
gabomdq@6674
   687
gabomdq@6674
   688
# Requires:
gabomdq@6674
   689
# - nada
gabomdq@6674
   690
macro(CheckOpenGLESX11)
gabomdq@6674
   691
  if(VIDEO_OPENGLES)
gabomdq@6674
   692
    check_c_source_compiles("
denis@9127
   693
        #define EGL_API_FB
gabomdq@6674
   694
        #include <EGL/egl.h>
gabomdq@7690
   695
        int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL)
gabomdq@7690
   696
    if(HAVE_VIDEO_OPENGL_EGL)
gabomdq@7690
   697
        set(SDL_VIDEO_OPENGL_EGL 1)
icculus@9277
   698
    endif()
gabomdq@7690
   699
    check_c_source_compiles("
gabomdq@7690
   700
      #include <GLES/gl.h>
gabomdq@7690
   701
      #include <GLES/glext.h>
gabomdq@7690
   702
      int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1)
gabomdq@7690
   703
    if(HAVE_VIDEO_OPENGLES_V1)
gabomdq@7690
   704
        set(HAVE_VIDEO_OPENGLES TRUE)
gabomdq@6674
   705
        set(SDL_VIDEO_OPENGL_ES 1)
gabomdq@6674
   706
        set(SDL_VIDEO_RENDER_OGL_ES 1)
icculus@9277
   707
    endif()
gabomdq@7690
   708
    check_c_source_compiles("
gabomdq@7690
   709
      #include <GLES2/gl2.h>
gabomdq@7690
   710
      #include <GLES2/gl2ext.h>
gabomdq@7690
   711
      int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2)
gabomdq@7690
   712
    if(HAVE_VIDEO_OPENGLES_V2)
gabomdq@7690
   713
        set(HAVE_VIDEO_OPENGLES TRUE)
gabomdq@6674
   714
        set(SDL_VIDEO_OPENGL_ES2 1)
gabomdq@6674
   715
        set(SDL_VIDEO_RENDER_OGL_ES2 1)
icculus@9277
   716
    endif()
gabomdq@7690
   717
icculus@9277
   718
  endif()
icculus@9277
   719
endmacro()
gabomdq@6674
   720
icculus@9414
   721
# Requires:
gabomdq@6674
   722
# - nada
gabomdq@6674
   723
# Optional:
gabomdq@6674
   724
# - THREADS opt
gabomdq@6674
   725
# Sets:
gabomdq@6674
   726
# PTHREAD_CFLAGS
gabomdq@6674
   727
# PTHREAD_LIBS
gabomdq@6674
   728
macro(CheckPTHREAD)
gabomdq@6674
   729
  if(PTHREADS)
gabomdq@6674
   730
    if(LINUX)
gabomdq@6674
   731
      set(PTHREAD_CFLAGS "-D_REENTRANT")
gabomdq@7078
   732
      set(PTHREAD_LDFLAGS "-pthread")
gabomdq@6674
   733
    elseif(BSDI)
gabomdq@6674
   734
      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
gabomdq@6674
   735
      set(PTHREAD_LDFLAGS "")
gabomdq@6674
   736
    elseif(DARWIN)
gabomdq@6674
   737
      set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
gabomdq@6674
   738
      # causes Carbon.p complaints?
gabomdq@6674
   739
      # set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
gabomdq@6674
   740
      set(PTHREAD_LDFLAGS "")
gabomdq@6674
   741
    elseif(FREEBSD)
gabomdq@6674
   742
      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
gabomdq@6674
   743
      set(PTHREAD_LDFLAGS "-pthread")
gabomdq@6674
   744
    elseif(NETBSD)
gabomdq@6674
   745
      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
gabomdq@6674
   746
      set(PTHREAD_LDFLAGS "-lpthread")
gabomdq@6674
   747
    elseif(OPENBSD)
gabomdq@6674
   748
      set(PTHREAD_CFLAGS "-D_REENTRANT")
gabomdq@6674
   749
      set(PTHREAD_LDFLAGS "-pthread")
gabomdq@6674
   750
    elseif(SOLARIS)
gabomdq@6674
   751
      set(PTHREAD_CFLAGS "-D_REENTRANT")
gabomdq@6674
   752
      set(PTHREAD_LDFLAGS "-pthread -lposix4")
gabomdq@6674
   753
    elseif(SYSV5)
gabomdq@6674
   754
      set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
gabomdq@6674
   755
      set(PTHREAD_LDFLAGS "")
gabomdq@6674
   756
    elseif(AIX)
gabomdq@6674
   757
      set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads")
gabomdq@6674
   758
      set(PTHREAD_LDFLAGS "-pthread")
gabomdq@6674
   759
    elseif(HPUX)
gabomdq@6674
   760
      set(PTHREAD_CFLAGS "-D_REENTRANT")
gabomdq@6674
   761
      set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
icculus@7981
   762
    elseif(HAIKU)
icculus@7977
   763
      set(PTHREAD_CFLAGS "-D_REENTRANT")
icculus@7977
   764
      set(PTHREAD_LDFLAGS "")
gabomdq@6674
   765
    else()
gabomdq@6674
   766
      set(PTHREAD_CFLAGS "-D_REENTRANT")
gabomdq@6674
   767
      set(PTHREAD_LDFLAGS "-lpthread")
icculus@9277
   768
    endif()
gabomdq@6674
   769
gabomdq@6674
   770
    # Run some tests
jujjyl@10329
   771
    set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
jujjyl@10329
   772
    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
icculus@9414
   773
    if(CMAKE_CROSSCOMPILING)
icculus@9414
   774
      set(HAVE_PTHREADS 1)
icculus@9414
   775
    else()
icculus@9414
   776
      check_c_source_runs("
gabomdq@6674
   777
        #include <pthread.h>
gabomdq@6674
   778
        int main(int argc, char** argv) {
gabomdq@6674
   779
          pthread_attr_t type;
gabomdq@6674
   780
          pthread_attr_init(&type);
gabomdq@6674
   781
          return 0;
gabomdq@6674
   782
        }" HAVE_PTHREADS)
icculus@9414
   783
    endif()
gabomdq@6674
   784
    if(HAVE_PTHREADS)
gabomdq@6674
   785
      set(SDL_THREAD_PTHREAD 1)
gabomdq@6674
   786
      list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
gabomdq@6674
   787
      list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
gabomdq@6674
   788
      set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
gabomdq@6674
   789
      list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS})
gabomdq@6674
   790
gabomdq@6674
   791
      check_c_source_compiles("
gabomdq@6674
   792
        #include <pthread.h>
gabomdq@6674
   793
        int main(int argc, char **argv) {
gabomdq@6674
   794
          pthread_mutexattr_t attr;
gabomdq@6674
   795
          pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
gabomdq@7078
   796
          return 0;
gabomdq@6674
   797
        }" HAVE_RECURSIVE_MUTEXES)
gabomdq@6674
   798
      if(HAVE_RECURSIVE_MUTEXES)
gabomdq@6674
   799
        set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
icculus@9277
   800
      else()
gabomdq@6674
   801
        check_c_source_compiles("
gabomdq@6674
   802
            #include <pthread.h>
gabomdq@6674
   803
            int main(int argc, char **argv) {
gabomdq@6674
   804
              pthread_mutexattr_t attr;
gabomdq@6674
   805
              pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
gabomdq@7078
   806
              return 0;
gabomdq@6674
   807
            }" HAVE_RECURSIVE_MUTEXES_NP)
gabomdq@6674
   808
        if(HAVE_RECURSIVE_MUTEXES_NP)
gabomdq@6674
   809
          set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
icculus@9277
   810
        endif()
icculus@9277
   811
      endif()
gabomdq@6674
   812
gabomdq@6674
   813
      if(PTHREADS_SEM)
gabomdq@6674
   814
        check_c_source_compiles("#include <pthread.h>
gabomdq@7078
   815
                                 #include <semaphore.h>
gabomdq@7078
   816
                                 int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM)
gabomdq@6674
   817
        if(HAVE_PTHREADS_SEM)
gabomdq@6674
   818
          check_c_source_compiles("
gabomdq@6674
   819
              #include <pthread.h>
gabomdq@6674
   820
              #include <semaphore.h>
gabomdq@6674
   821
              int main(int argc, char **argv) {
gabomdq@6674
   822
                  sem_timedwait(NULL, NULL);
gabomdq@6674
   823
                  return 0;
gabomdq@6674
   824
              }" HAVE_SEM_TIMEDWAIT)
icculus@9277
   825
        endif()
icculus@9277
   826
      endif()
gabomdq@6674
   827
gabomdq@6674
   828
      check_c_source_compiles("
gabomdq@6674
   829
          #include <pthread.h>
gabomdq@6674
   830
          #include <pthread_np.h>
gabomdq@6674
   831
          int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
icculus@9414
   832
      check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
icculus@9415
   833
      check_function_exists(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP)
jujjyl@10329
   834
      set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
gabomdq@6674
   835
gabomdq@6674
   836
      set(SOURCE_FILES ${SOURCE_FILES}
gabomdq@6674
   837
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
gabomdq@6674
   838
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c   # Can be faked, if necessary
gabomdq@6674
   839
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c    # Can be faked, if necessary
icculus@7400
   840
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systls.c
gabomdq@6674
   841
          )
gabomdq@6674
   842
      if(HAVE_PTHREADS_SEM)
gabomdq@6674
   843
        set(SOURCE_FILES ${SOURCE_FILES}
gabomdq@6674
   844
            ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
icculus@9277
   845
      else()
gabomdq@6674
   846
        set(SOURCE_FILES ${SOURCE_FILES}
gabomdq@6674
   847
            ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
icculus@9277
   848
      endif()
gabomdq@6674
   849
      set(HAVE_SDL_THREADS TRUE)
icculus@9277
   850
    endif()
icculus@9277
   851
  endif()
icculus@9277
   852
endmacro()
gabomdq@6674
   853
gabomdq@6674
   854
# Requires
gabomdq@6674
   855
# - nada
gabomdq@6674
   856
# Optional:
gabomdq@6674
   857
# Sets:
gabomdq@6674
   858
# USB_LIBS
gabomdq@6674
   859
# USB_CFLAGS
gabomdq@6674
   860
macro(CheckUSBHID)
gabomdq@6674
   861
  check_library_exists(usbhid hid_init "" LIBUSBHID)
gabomdq@6674
   862
  if(LIBUSBHID)
gabomdq@6674
   863
    check_include_file(usbhid.h HAVE_USBHID_H)
gabomdq@6674
   864
    if(HAVE_USBHID_H)
gabomdq@6674
   865
      set(USB_CFLAGS "-DHAVE_USBHID_H")
icculus@9277
   866
    endif()
gabomdq@6674
   867
gabomdq@6674
   868
    check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
gabomdq@6674
   869
    if(HAVE_LIBUSBHID_H)
gabomdq@6674
   870
      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
icculus@9277
   871
    endif()
gabomdq@6674
   872
    set(USB_LIBS ${USB_LIBS} usbhid)
icculus@9277
   873
  else()
gabomdq@6674
   874
    check_include_file(usb.h HAVE_USB_H)
gabomdq@6674
   875
    if(HAVE_USB_H)
gabomdq@6674
   876
      set(USB_CFLAGS "-DHAVE_USB_H")
icculus@9277
   877
    endif()
gabomdq@6674
   878
    check_include_file(libusb.h HAVE_LIBUSB_H)
gabomdq@6674
   879
    if(HAVE_LIBUSB_H)
gabomdq@6674
   880
      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
icculus@9277
   881
    endif()
gabomdq@6674
   882
    check_library_exists(usb hid_init "" LIBUSB)
gabomdq@6674
   883
    if(LIBUSB)
gabomdq@6674
   884
      set(USB_LIBS ${USB_LIBS} usb)
icculus@9277
   885
    endif()
icculus@9277
   886
  endif()
gabomdq@6674
   887
jujjyl@10329
   888
  set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
jujjyl@10329
   889
  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${USB_CFLAGS}")
gabomdq@6674
   890
  set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
gabomdq@6674
   891
  check_c_source_compiles("
gabomdq@6674
   892
       #include <sys/types.h>
gabomdq@6674
   893
        #if defined(HAVE_USB_H)
gabomdq@6674
   894
        #include <usb.h>
gabomdq@6674
   895
        #endif
gabomdq@6674
   896
        #ifdef __DragonFly__
gabomdq@6674
   897
        # include <bus/usb/usb.h>
gabomdq@6674
   898
        # include <bus/usb/usbhid.h>
gabomdq@6674
   899
        #else
gabomdq@6674
   900
        # include <dev/usb/usb.h>
gabomdq@6674
   901
        # include <dev/usb/usbhid.h>
gabomdq@6674
   902
        #endif
gabomdq@6674
   903
        #if defined(HAVE_USBHID_H)
gabomdq@6674
   904
        #include <usbhid.h>
gabomdq@6674
   905
        #elif defined(HAVE_LIBUSB_H)
gabomdq@6674
   906
        #include <libusb.h>
gabomdq@6674
   907
        #elif defined(HAVE_LIBUSBHID_H)
gabomdq@6674
   908
        #include <libusbhid.h>
gabomdq@6674
   909
        #endif
gabomdq@6674
   910
        int main(int argc, char **argv) {
gabomdq@6674
   911
          struct report_desc *repdesc;
gabomdq@6674
   912
          struct usb_ctl_report *repbuf;
gabomdq@6674
   913
          hid_kind_t hidkind;
gabomdq@6674
   914
          return 0;
gabomdq@6674
   915
        }" HAVE_USBHID)
gabomdq@6674
   916
  if(HAVE_USBHID)
gabomdq@6674
   917
    check_c_source_compiles("
gabomdq@6674
   918
          #include <sys/types.h>
gabomdq@6674
   919
          #if defined(HAVE_USB_H)
gabomdq@6674
   920
          #include <usb.h>
gabomdq@6674
   921
          #endif
gabomdq@6674
   922
          #ifdef __DragonFly__
gabomdq@6674
   923
          # include <bus/usb/usb.h>
gabomdq@6674
   924
          # include <bus/usb/usbhid.h>
gabomdq@6674
   925
          #else
gabomdq@6674
   926
          # include <dev/usb/usb.h>
gabomdq@6674
   927
          # include <dev/usb/usbhid.h>
gabomdq@6674
   928
          #endif
gabomdq@6674
   929
          #if defined(HAVE_USBHID_H)
gabomdq@6674
   930
          #include <usbhid.h>
gabomdq@6674
   931
          #elif defined(HAVE_LIBUSB_H)
gabomdq@6674
   932
          #include <libusb.h>
gabomdq@6674
   933
          #elif defined(HAVE_LIBUSBHID_H)
gabomdq@6674
   934
          #include <libusbhid.h>
gabomdq@6674
   935
          #endif
gabomdq@6674
   936
          int main(int argc, char** argv) {
gabomdq@6674
   937
            struct usb_ctl_report buf;
gabomdq@6674
   938
            if (buf.ucr_data) { }
gabomdq@6674
   939
            return 0;
gabomdq@6674
   940
          }" HAVE_USBHID_UCR_DATA)
gabomdq@6674
   941
    if(HAVE_USBHID_UCR_DATA)
gabomdq@6674
   942
      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
icculus@9277
   943
    endif()
gabomdq@6674
   944
gabomdq@6674
   945
    check_c_source_compiles("
gabomdq@6674
   946
          #include <sys/types.h>
gabomdq@6674
   947
          #if defined(HAVE_USB_H)
gabomdq@6674
   948
          #include <usb.h>
gabomdq@6674
   949
          #endif
gabomdq@6674
   950
          #ifdef __DragonFly__
gabomdq@6674
   951
          #include <bus/usb/usb.h>
gabomdq@6674
   952
          #include <bus/usb/usbhid.h>
gabomdq@6674
   953
          #else
gabomdq@6674
   954
          #include <dev/usb/usb.h>
gabomdq@6674
   955
          #include <dev/usb/usbhid.h>
gabomdq@6674
   956
          #endif
gabomdq@6674
   957
          #if defined(HAVE_USBHID_H)
gabomdq@6674
   958
          #include <usbhid.h>
gabomdq@6674
   959
          #elif defined(HAVE_LIBUSB_H)
gabomdq@6674
   960
          #include <libusb.h>
gabomdq@6674
   961
          #elif defined(HAVE_LIBUSBHID_H)
gabomdq@6674
   962
          #include <libusbhid.h>
gabomdq@6674
   963
          #endif
gabomdq@6674
   964
          int main(int argc, char **argv) {
gabomdq@6674
   965
            report_desc_t d;
gabomdq@6674
   966
            hid_start_parse(d, 1, 1);
gabomdq@6674
   967
            return 0;
gabomdq@6674
   968
          }" HAVE_USBHID_NEW)
gabomdq@6674
   969
    if(HAVE_USBHID_NEW)
gabomdq@6674
   970
      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
icculus@9277
   971
    endif()
gabomdq@6674
   972
gabomdq@6674
   973
    check_c_source_compiles("
gabomdq@6674
   974
        #include <machine/joystick.h>
gabomdq@6674
   975
        int main(int argc, char** argv) {
gabomdq@6674
   976
            struct joystick t;
gabomdq@6674
   977
            return 0;
gabomdq@6674
   978
        }" HAVE_MACHINE_JOYSTICK)
gabomdq@6674
   979
    if(HAVE_MACHINE_JOYSTICK)
gabomdq@6674
   980
      set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1)
icculus@9277
   981
    endif()
gabomdq@6674
   982
    set(SDL_JOYSTICK_USBHID 1)
gabomdq@6674
   983
    file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
gabomdq@6674
   984
    set(SOURCE_FILES ${SOURCE_FILES} ${BSD_JOYSTICK_SOURCES})
gabomdq@6674
   985
    list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
gabomdq@6674
   986
    list(APPEND EXTRA_LIBS ${USB_LIBS})
gabomdq@6674
   987
    set(HAVE_SDL_JOYSTICK TRUE)
gabomdq@6674
   988
gabomdq@6674
   989
    set(CMAKE_REQUIRED_LIBRARIES)
jujjyl@10329
   990
    set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
icculus@9277
   991
  endif()
icculus@9277
   992
endmacro()
slouken@9077
   993
slouken@9077
   994
# Requires:
slouken@9077
   995
# - n/a
slouken@9077
   996
macro(CheckRPI)
slouken@9077
   997
  if(VIDEO_RPI)
slouken@9077
   998
    set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
slouken@9077
   999
    set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
slouken@9077
  1000
    set(VIDEO_RPI_LIBS bcm_host )
slouken@9077
  1001
    listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
slouken@9077
  1002
    listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
slouken@9077
  1003
jujjyl@10329
  1004
    set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
jujjyl@10329
  1005
    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
slouken@9077
  1006
    set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBS}")
slouken@9077
  1007
    check_c_source_compiles("
slouken@9077
  1008
        #include <bcm_host.h>
slouken@9077
  1009
        int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
jujjyl@10329
  1010
    set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
slouken@9077
  1011
    set(CMAKE_REQUIRED_LIBRARIES)
slouken@9077
  1012
slouken@9077
  1013
    if(SDL_VIDEO AND HAVE_VIDEO_RPI)
slouken@9077
  1014
      set(HAVE_SDL_VIDEO TRUE)
slouken@9077
  1015
      set(SDL_VIDEO_DRIVER_RPI 1)
slouken@9077
  1016
      file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
slouken@9077
  1017
      set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES})
slouken@9077
  1018
      list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBS})
slouken@9077
  1019
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
slouken@9077
  1020
    endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
slouken@9077
  1021
  endif(VIDEO_RPI)
slouken@9077
  1022
endmacro(CheckRPI)