cmake/sdlchecks.cmake
author Sam Lantinga <slouken@libsdl.org>
Sat, 27 Jul 2013 03:20:09 -0700
changeset 7526 6c0f0280149c
parent 7521 03bca9a4180d
child 7690 76d7b6007a64
permissions -rw-r--r--
Fixed bug 1272 - Bogus numlock key up/down events being reported on MacOS X Vern Jensen The problem is that in certain situations I'm getting THREE keyUp/keyDown events when I push certain keys. In my event code I added: case SDL_KEYUP: printf("SDL KeyScanCode for KEYUP event: %d\n", event->key.keysym.scancode ); … and case SDL_KEYDOWN: printf("SDL KeyScanCode for KEYDOWN event: %d\n", event->key.keysym.scancode ); … The result of one test run where I push 2 keys and then release them is this: SDL KeyScanCode for KEYDOWN event: 92 // Pushed keypad 4 SDL KeyScanCode for KEYDOWN event: 83 // Pushed left shift SDL KeyScanCode for KEYUP event: 83 SDL KeyScanCode for KEYDOWN event: 225 SDL KeyScanCode for KEYUP event: 92 // Released keypad 4 SDL KeyScanCode for KEYDOWN event: 83 SDL KeyScanCode for KEYUP event: 83 SDL KeyScanCode for KEYUP event: 225 // Released left shift There *should* be only a total of 4 events above… 2 for each key being pushed, and 2 for each being released. But instead some bogus events for numlock being pushed/released are sent from SDL. These events did not occur. I did not push numlock. The value above for numlock is 83. Comments above show when I pushed each key. As you can see, when I push left shift, THREE events are instantly sent to my application, keyDown and then keyUp for numlock, and then the valid event for left shift (the key that was actually pushed). You could replace keypad 4 with pretty much any keyPad key and it'll still happen. You can also replace it with any arrow key and it'll happen. However, when trying it with normal letter keys on the main keyboard it didn't. It happens with other modifier keys too, not just left shift. The order in which the keys are pressed matter. For instance, if I do: 1) keypad 4 2) left shift 3) release left shift 4) release keypad 4 Then at step 2, I get the 3 events above (when there should be only one), but steps 3 and 4 work properly… I don't get extra keyUp/keyDown events for steps 3 or 4. Thereas if the order of steps 3 and 4 are reversed, I get the bogus extra events for numlock. Also, the problem can occur even when pushing just a single key by itself. If I push left shift, then keypad 4, then release left shift, then release keypad 4, then the following push of left shift will cause the bug. If I continue pushing and releasing left shift though, it won't happen again until I again involve keypad keys. --- Sam Lantinga According to the Apple documentation, NSNumericPadKeyMask is set for any arrow or numeric keypad event. Indeed this is what's happening. I verified that we get the correct events for the numlock key and the mod state gets set correcly, so it should be safe to remove this bogus code.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     1
macro(CheckDLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     2
  check_function_exists(dlopen HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     3
  if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     4
    foreach(_LIBNAME dl tdl)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     5
      check_library_exists("${_LIBNAME}" "dlopen" "" DLOPEN_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     6
      if(DLOPEN_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     7
        list(APPEND EXTRA_LIBS ${_LIBNAME})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     8
        set(_DLLIB ${_LIBNAME})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     9
        set(HAVE_DLOPEN TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    10
        break()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    11
      endif(DLOPEN_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    12
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    13
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    14
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    15
  if(HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    16
    if(_DLLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    17
      set(CMAKE_REQUIRED_LIBRARIES ${_DLLIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
       #include <dlfcn.h>
7507
885b4aab4190 Mac: Codify SDK and OS requirements, and clean up.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7438
diff changeset
    21
       int main(int argc, char **argv) {
7521
03bca9a4180d Fix cmake breakage (thanks Marcus)
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7507
diff changeset
    22
         void *handle = dlopen(\"\", RTLD_NOW);
7507
885b4aab4190 Mac: Codify SDK and OS requirements, and clean up.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7438
diff changeset
    23
         const char *loaderror = (char *) dlerror();
885b4aab4190 Mac: Codify SDK and OS requirements, and clean up.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7438
diff changeset
    24
       }" HAVE_DLOPEN)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
    set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
  if (HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
    set(SDL_LOADSO_DLOPEN 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    30
    set(HAVE_SDL_DLOPEN TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    31
    file(GLOB DLOPEN_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    32
    set(SOURCE_FILES ${SOURCE_FILES} ${DLOPEN_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    33
    set(HAVE_SDL_LOADSO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    34
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    35
endmacro(CheckDLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
# - n/a
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    39
macro(CheckOSS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    40
  if(OSS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    41
    set(OSS_HEADER_FILE "sys/soundcard.h")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    42
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    43
        #include <sys/soundcard.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    44
        int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    45
    if(NOT OSS_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    46
      set(OSS_HEADER_FILE "soundcard.h")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    47
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
          #include <soundcard.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    49
          int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    50
    endif(NOT OSS_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    51
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    52
    if(OSS_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    53
      set(HAVE_OSS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    54
      file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    55
      if(OSS_HEADER_FILE STREQUAL "soundcard.h")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    56
        set(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    57
      endif(OSS_HEADER_FILE STREQUAL "soundcard.h")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
      set(SDL_AUDIO_DRIVER_OSS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
      set(SOURCE_FILES ${SOURCE_FILES} ${OSS_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
      if(NETBSD OR OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    61
        list(APPEND EXTRA_LIBS ossaudio)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    62
      endif(NETBSD OR OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    63
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
    endif(OSS_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
  endif(OSS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
endmacro(CheckOSS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    67
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    68
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
# - n/a
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
# - ALSA_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    72
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
macro(CheckALSA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
  if(ALSA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
    CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
    if(HAVE_ASOUNDLIB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
      CHECK_LIBRARY_EXISTS(asound snd_pcm_open "" HAVE_LIBASOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    78
      set(HAVE_ALSA TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
      file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
      set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
      set(SDL_AUDIO_DRIVER_ALSA 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
      if(ALSA_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    83
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
          message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    85
        else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
          find_library(_ALSA_LIB asound)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    87
          get_filename_component(F_ALSA_LIB ${_ALSA_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
          set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${F_ALSA_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    89
          set(HAVE_ALSA_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    91
      else(ALSA_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
        list(APPEND EXTRA_LIBS asound)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
      endif(ALSA_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
    endif(HAVE_ASOUNDLIB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
  endif(ALSA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
endmacro(CheckALSA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    99
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
# - PkgCheckModules
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   101
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   102
# - PULSEAUDIO_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   103
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   104
macro(CheckPulseAudio)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
  if(PULSEAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
    pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   107
    if(PKG_PULSEAUDIO_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
      set(HAVE_PULSEAUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   109
      file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   110
      set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   111
      set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   112
      list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   113
      if(PULSEAUDIO_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   114
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   115
          message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   116
        else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   117
          find_library(D_PULSE_LIB pulse-simple)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   118
          get_filename_component(F_PULSE_LIB ${D_PULSE_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   119
          set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${F_PULSE_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   120
          set(HAVE_PULSEAUDIO_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   121
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   122
      else(PULSEAUDIO_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   123
        list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   124
      endif(PULSEAUDIO_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   125
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
    endif(PKG_PULSEAUDIO_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
  endif(PULSEAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   128
endmacro(CheckPulseAudio)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   129
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   130
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   131
# - PkgCheckModules
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   132
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   133
# - ESD_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   134
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   135
macro(CheckESD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   136
  if(ESD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
    pkg_check_modules(PKG_ESD esound)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
    if(PKG_ESD_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
      set(HAVE_ESD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
      file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
      set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   142
      set(SDL_AUDIO_DRIVER_ESD 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   143
      list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
      if(ESD_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   146
          message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
        else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
          find_library(D_ESD_LIB esd)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
          get_filename_component(F_ESD_LIB ${D_ESD_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
          set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${F_ESD_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
          set(HAVE_ESD_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   152
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   153
      else(ESD_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
        list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
      endif(ESD_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   156
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   157
    endif(PKG_ESD_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   158
  endif(ESD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   159
endmacro(CheckESD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   160
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   161
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   162
# - n/a
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   163
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   164
# - ARTS_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   165
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   166
macro(CheckARTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   167
  if(ARTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   168
    find_program(ARTS_CONFIG arts-config)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   169
    if(ARTS_CONFIG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   170
      execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   171
        OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   172
      list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   173
      execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   174
        OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   175
      file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   176
      set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   177
      set(SDL_AUDIO_DRIVER_ARTS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   178
      set(HAVE_ARTS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   179
      if(ARTS_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   180
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   181
          message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   182
        else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   183
          # TODO
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   184
          find_library(D_ARTS_LIB artsc)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   185
          get_filename_component(F_ARTS_LIB ${D_ARTS_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   186
          set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${F_ARTS_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   187
          set(HAVE_ARTS_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   188
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   189
      else(ARTS_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   190
        list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   191
      endif(ARTS_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   192
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   193
    endif(ARTS_CONFIG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   194
  endif(ARTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   195
endmacro(CheckARTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   196
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   197
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   198
# - n/a
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   199
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   200
# - NAS_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   201
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   202
macro(CheckNAS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   203
  if(NAS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   204
    # TODO: set include paths properly, so the NAS headers are found
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   205
    check_include_file(audio/audiolib.h HAVE_NAS_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   206
    find_library(D_NAS_LIB audio)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   207
    if(HAVE_NAS_H AND D_NAS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   208
      set(HAVE_NAS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   209
      file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   210
      set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   211
      set(SDL_AUDIO_DRIVER_NAS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   212
      if(NAS_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   213
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   214
          message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   215
        else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   216
          get_filename_component(F_NAS_LIB ${D_NAS_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   217
          set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${F_NAS_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   218
          set(HAVE_NAS_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   219
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   220
      else(NAS_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   221
        list(APPEND EXTRA_LIBS ${D_NAS_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   222
      endif(NAS_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   223
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   224
    endif(HAVE_NAS_H AND D_NAS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   225
  endif(NAS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   226
endmacro(CheckNAS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   227
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   228
# Requires:
7367
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   229
# - n/a
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   230
# Optional:
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   231
# - SNDIO_SHARED opt
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   232
# - HAVE_DLOPEN opt
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   233
macro(CheckSNDIO)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   234
  if(SNDIO)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   235
    # TODO: set include paths properly, so the sndio headers are found
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   236
    check_include_file(sndio.h HAVE_SNDIO_H)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   237
    find_library(D_SNDIO_LIB audio)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   238
    if(HAVE_SNDIO_H AND D_SNDIO_LIB)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   239
      set(HAVE_SNDIO TRUE)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   240
      file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   241
      set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   242
      set(SDL_AUDIO_DRIVER_SNDIO 1)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   243
      if(SNDIO_SHARED)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   244
        if(NOT HAVE_DLOPEN)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   245
          message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   246
        else()
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   247
          get_filename_component(F_SNDIO_LIB ${D_SNDIO_LIB} NAME)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   248
          set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${F_SNDIO_LIB}\"")
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   249
          set(HAVE_SNDIO_SHARED TRUE)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   250
        endif(NOT HAVE_DLOPEN)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   251
      else(SNDIO_SHARED)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   252
        list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   253
      endif(SNDIO_SHARED)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   254
      set(HAVE_SDL_AUDIO TRUE)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   255
    endif(HAVE_SNDIO_H AND D_SNDIO_LIB)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   256
  endif(SNDIO)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   257
endmacro(CheckSNDIO)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   258
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   259
# Requires:
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   260
# - PkgCheckModules
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   261
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   262
# - FUSIONSOUND_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   263
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   264
macro(CheckFusionSound)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   265
  if(FUSIONSOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   266
    pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   267
    if(PKG_FUSIONSOUND_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   268
      set(HAVE_FUSIONSOUND TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   269
      file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   270
      set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   271
      set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   272
      list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   273
      if(FUSIONSOUND_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   274
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   275
          message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   276
        else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   277
          find_library(D_FUSIONSOUND_LIB fusionsound)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   278
          get_filename_component(F_FUSIONSOUND_LIB ${D_FUSIONSOUND_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   279
          set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${F_FUSIONSOUND_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   280
          set(HAVE_FUSIONSOUND_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   281
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   282
      else(FUSIONSOUND_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   283
        list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   284
      endif(FUSIONSOUND_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   285
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   286
    endif(PKG_FUSIONSOUND_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   287
  endif(FUSIONSOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   288
endmacro(CheckFusionSound)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   289
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   290
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   291
# - n/a
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   292
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   293
# - X11_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   294
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   295
macro(CheckX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   296
  if(VIDEO_X11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   297
    foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   298
      string(TOUPPER ${_LIB} _LNAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   299
      find_library(${_LNAME}_LIB ${_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   300
      if(${_LNAME}_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   301
        # reduce the library name for shared linking
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   302
        get_filename_component(_TMP ${${_LNAME}_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   303
        set(${_LNAME}_LIB ${_TMP})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   304
      endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   305
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   306
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   307
    check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   308
    check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   309
    check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   310
    check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   311
    check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   312
    check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   313
    check_include_file(X11/extensions/shape.h HAVE_XSHAPE_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   314
    check_include_files("X11/Xlib.h;X11/extensions/xf86vmode.h" HAVE_XF86VM_H)
7438
97c35b3811d1 Explicitly check for Xext.h in the CMake project, fail if missing.
Ryan C. Gordon <icculus@icculus.org>
parents: 7400
diff changeset
   315
    check_include_files("X11/Xlib.h;X11/Xproto.h;X11/extensions/Xext.h" HAVE_XEXT_H)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   316
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   317
    if(X11_LIB)
7438
97c35b3811d1 Explicitly check for Xext.h in the CMake project, fail if missing.
Ryan C. Gordon <icculus@icculus.org>
parents: 7400
diff changeset
   318
      if(NOT HAVE_XEXT_H)
97c35b3811d1 Explicitly check for Xext.h in the CMake project, fail if missing.
Ryan C. Gordon <icculus@icculus.org>
parents: 7400
diff changeset
   319
        message_error("Missing Xext.h, maybe you need to install the libxext-dev package?")
97c35b3811d1 Explicitly check for Xext.h in the CMake project, fail if missing.
Ryan C. Gordon <icculus@icculus.org>
parents: 7400
diff changeset
   320
      endif()
97c35b3811d1 Explicitly check for Xext.h in the CMake project, fail if missing.
Ryan C. Gordon <icculus@icculus.org>
parents: 7400
diff changeset
   321
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   322
      set(HAVE_VIDEO_X11 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   323
      set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   324
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   325
      file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   326
      set(SOURCE_FILES ${SOURCE_FILES} ${X11_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   327
      set(SDL_VIDEO_DRIVER_X11 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   328
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   329
      if(HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   330
        set(X11_SYMBOLS_PRIVATE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   331
      else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   332
        set(X11_SYMBOLS_PRIVATE FALSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   333
      endif(HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   334
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   335
      if(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   336
        set(X11_SHARED OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   337
        set(X11_SYMBOLS_PRIVATE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   338
      endif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   339
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   340
      check_function_exists("shmat" HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   341
      if(NOT HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   342
        check_library_exists(ipc shmat "" HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   343
        if(HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   344
          list(APPEND EXTRA_LIBS ipc)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   345
        endif(HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   346
        if(NOT HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   347
          add_definitions(-DNO_SHARED_MEMORY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   348
        endif(NOT HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   349
      endif(NOT HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   350
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   351
      if(X11_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   352
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   353
          message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   354
          set(HAVE_X11_SHARED FALSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   355
          if(X11_SYMBOLS_PRIVATE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   356
            message_warn("You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   357
            set(HAVE_X11_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   358
          endif(X11_SYMBOLS_PRIVATE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   359
        else(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   360
          set(HAVE_X11_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   361
        endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   362
        if(HAVE_X11_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   363
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   364
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   365
        else(HAVE_X11_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   366
          list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   367
        endif(HAVE_X11_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   368
      endif(X11_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   369
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   370
      set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   371
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   372
          #include <X11/Xlib.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   373
          #include <X11/Xproto.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   374
          #include <X11/extensions/Xext.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   375
          #include <X11/extensions/extutil.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   376
          extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   377
          int main(int argc, char **argv) {}" HAVE_CONST_XEXT_ADDDISPLAY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   378
      if(HAVE_CONST_XEXT_ADDDISPLAY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   379
        set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   380
      endif(HAVE_CONST_XEXT_ADDDISPLAY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   381
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   382
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   383
          #include <X11/Xlib.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   384
          int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   385
            Display *display;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   386
            XEvent event;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   387
            XGenericEventCookie *cookie = &event.xcookie;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   388
            XNextEvent(display, &event);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   389
            XGetEventData(display, cookie);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   390
            XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   391
      if(HAVE_XGENERICEVENT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   392
        set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   393
      endif(HAVE_XGENERICEVENT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   394
7266
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   395
      check_c_source_compiles("
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   396
          #include <X11/Xlibint.h>
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   397
          extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   398
          int main(int argc, char **argv) {}" HAVE_CONST_XDATA32)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   399
      if(HAVE_CONST_XDATA32)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   400
        set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   401
      endif(HAVE_CONST_XDATA32)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   402
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   403
      check_function_exists(XkbKeycodeToKeysym SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   404
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   405
      if(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   406
        set(HAVE_VIDEO_X11_XCURSOR TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   407
        if(HAVE_X11_SHARED AND XCURSOR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   408
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   409
        else(HAVE_X11_SHARED AND XCURSOR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   410
          list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   411
        endif(HAVE_X11_SHARED AND XCURSOR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   412
        set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   413
      endif(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   414
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   415
      if(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   416
        set(HAVE_VIDEO_X11_XINERAMA TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   417
        if(HAVE_X11_SHARED AND XINERAMA_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   418
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   419
        else(HAVE_X11_SHARED AND XINERAMA_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   420
          list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   421
        endif(HAVE_X11_SHARED AND XINERAMA_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   422
        set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   423
      endif(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   424
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   425
      if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   426
        set(HAVE_VIDEO_X11_XINPUT TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   427
        if(HAVE_X11_SHARED AND XI_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   428
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   429
        else(HAVE_X11_SHARED AND XI_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   430
          list(APPEND EXTRA_LIBS ${XI_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   431
        endif(HAVE_X11_SHARED AND XI_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   432
        set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   433
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   434
        # Check for multitouch
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   435
        check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   436
            #include <X11/Xlib.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   437
            #include <X11/Xproto.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   438
            #include <X11/extensions/XInput2.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   439
            int event_type = XI_TouchBegin;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   440
            XITouchClassInfo *t;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   441
            Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   442
            {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   443
              return (Status)0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   444
            }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   445
            int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   446
        if(HAVE_XINPUT2_MULTITOUCH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   447
          set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   448
        endif(HAVE_XINPUT2_MULTITOUCH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   449
      endif(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   450
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   451
      if(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   452
        if(HAVE_X11_SHARED AND XRANDR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   453
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   454
        else(HAVE_X11_SHARED AND XRANDR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   455
          list(APPEND EXTRA_LIBS ${XRANDR_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   456
        endif(HAVE_X11_SHARED AND XRANDR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   457
        set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   458
        set(HAVE_VIDEO_X11_XRANDR TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   459
      endif(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   460
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   461
      if(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   462
        if(HAVE_X11_SHARED AND XSS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   463
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   464
        else(HAVE_X11_SHARED AND XSS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   465
          list(APPEND EXTRA_LIBS ${XSS_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   466
        endif(HAVE_X11_SHARED AND XSS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   467
        set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   468
        set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   469
      endif(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   470
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   471
      if(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   472
        set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   473
        set(HAVE_VIDEO_X11_XSHAPE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   474
      endif(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   475
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   476
      if(VIDEO_X11_XVM AND HAVE_XF86VM_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   477
        if(HAVE_X11_SHARED AND XF86VMODE_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   478
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XF86VMODE_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   479
        else(HAVE_X11_SHARED AND XF86VMODE_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   480
          list(APPEND EXTRA_LIBS ${XF86VMODE_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   481
        endif(HAVE_X11_SHARED AND XF86VMODE_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   482
        set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   483
        set(HAVE_VIDEO_X11_XVM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   484
      endif(VIDEO_X11_XVM AND HAVE_XF86VM_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   485
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   486
      set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   487
    endif(X11_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   488
  endif(VIDEO_X11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   489
endmacro(CheckX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   490
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   491
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   492
# - n/a
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   493
#
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   494
macro(CheckCOCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   495
  if(VIDEO_COCOA)
7182
1089a8a701c3 Fixed bug 1839 - SDL2 Cmake: VIDEO_COCOA check fails on OS X; VIDEO_COCOA sources aren't compiled.
Sam Lantinga <slouken@libsdl.org>
parents: 7078
diff changeset
   496
    check_objc_source_compiles("
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   497
        #import <Cocoa/Cocoa.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   498
        int main (int argc, char** argv) {}" HAVE_VIDEO_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   499
    if(HAVE_VIDEO_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   500
      file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
7182
1089a8a701c3 Fixed bug 1839 - SDL2 Cmake: VIDEO_COCOA check fails on OS X; VIDEO_COCOA sources aren't compiled.
Sam Lantinga <slouken@libsdl.org>
parents: 7078
diff changeset
   501
      set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   502
      set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   503
      set(SDL_VIDEO_DRIVER_COCOA 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   504
      set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   505
    endif(HAVE_VIDEO_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   506
  endif(VIDEO_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   507
endmacro(CheckCOCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   508
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   509
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   510
# - PkgCheckModules
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   511
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   512
# - DIRECTFB_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   513
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   514
macro(CheckDirectFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   515
  if(VIDEO_DIRECTFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   516
    pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   517
    if(PKG_DIRECTFB_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   518
      set(HAVE_VIDEO_DIRECTFB TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   519
      file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   520
      set(SOURCE_FILES ${SOURCE_FILES} ${DIRECTFB_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   521
      set(SDL_VIDEO_DRIVER_DIRECTFB 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   522
      set(SDL_VIDEO_RENDER_DIRECTFB 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   523
      list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   524
      if(DIRECTFB_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   525
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   526
          message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   527
        else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   528
          find_library(D_DIRECTFB_LIB directfb)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   529
          get_filename_component(F_DIRECTFB_LIB ${D_DIRECTFB_LIB} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   530
          set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${F_DIRECTFB_LIB}\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   531
          set(HAVE_DIRECTFB_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   532
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   533
      else(DIRECTFB_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   534
        list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   535
      endif(DIRECTFB_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   536
      set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   537
    endif(PKG_DIRECTFB_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   538
  endif(VIDEO_DIRECTFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   539
endmacro(CheckDirectFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   540
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   541
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   542
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   543
macro(CheckOpenGLX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   544
  if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   545
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   546
        #include <GL/gl.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   547
        #include <GL/glx.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   548
        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   549
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   550
    if(HAVE_VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   551
      set(HAVE_VIDEO_OPENGL TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   552
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   553
      set(SDL_VIDEO_OPENGL_GLX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   554
      set(SDL_VIDEO_RENDER_OGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   555
      list(APPEND EXTRA_LIBS GL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   556
    endif(HAVE_VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   557
  endif(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   558
endmacro(CheckOpenGLX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   559
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   560
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   561
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   562
macro(CheckOpenGLESX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   563
  if(VIDEO_OPENGLES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   564
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   565
        #include <EGL/egl.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   566
        int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   567
    if(HAVE_VIDEO_OPENGLES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   568
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   569
          #include <GLES/gl.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   570
          #include <GLES/glext.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   571
          int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   572
      if(HAVE_VIDEO_OPENGLES_V1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   573
        set(SDL_VIDEO_OPENGL_ES 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   574
        set(SDL_VIDEO_RENDER_OGL_ES 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   575
      endif(HAVE_VIDEO_OPENGLES_V1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   576
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   577
          #include <GLES2/gl2.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   578
          #include <GLES2/gl2ext.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   579
          int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   580
      if(HAVE_VIDEO_OPENGLES_V2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   581
        set(SDL_VIDEO_OPENGL_ES2 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   582
        set(SDL_VIDEO_RENDER_OGL_ES2 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   583
      endif(HAVE_VIDEO_OPENGLES_V2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   584
    endif(HAVE_VIDEO_OPENGLES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   585
  endif(VIDEO_OPENGLES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   586
endmacro(CheckOpenGLESX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   587
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   588
# Rquires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   589
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   590
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   591
# - THREADS opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   592
# Sets:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   593
# PTHREAD_CFLAGS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   594
# PTHREAD_LIBS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   595
macro(CheckPTHREAD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   596
  if(PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   597
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   598
      set(PTHREAD_CFLAGS "-D_REENTRANT")
7078
a2bddc1fb02f Fixes bug #1709, pthread tests fixes for CMake (Thanks Scott Percival!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6674
diff changeset
   599
      set(PTHREAD_LDFLAGS "-pthread")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   600
    elseif(BSDI)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   601
      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   602
      set(PTHREAD_LDFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   603
    elseif(DARWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   604
      set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   605
      # causes Carbon.p complaints?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   606
      # set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   607
      set(PTHREAD_LDFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   608
    elseif(FREEBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   609
      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   610
      set(PTHREAD_LDFLAGS "-pthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   611
    elseif(NETBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   612
      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   613
      set(PTHREAD_LDFLAGS "-lpthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   614
    elseif(OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   615
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   616
      set(PTHREAD_LDFLAGS "-pthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   617
    elseif(SOLARIS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   618
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   619
      set(PTHREAD_LDFLAGS "-pthread -lposix4")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   620
    elseif(SYSV5)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   621
      set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   622
      set(PTHREAD_LDFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   623
    elseif(AIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   624
      set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   625
      set(PTHREAD_LDFLAGS "-pthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   626
    elseif(HPUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   627
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   628
      set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   629
    else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   630
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   631
      set(PTHREAD_LDFLAGS "-lpthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   632
    endif(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   633
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   634
    # Run some tests
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   635
    set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   636
    check_c_source_runs("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   637
        #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   638
        int main(int argc, char** argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   639
          pthread_attr_t type;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   640
          pthread_attr_init(&type);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   641
          return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   642
        }" HAVE_PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   643
    if(HAVE_PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   644
      set(SDL_THREAD_PTHREAD 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   645
      list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   646
      list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   647
      set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   648
      list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   649
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   650
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   651
        #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   652
        int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   653
          pthread_mutexattr_t attr;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   654
          pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
7078
a2bddc1fb02f Fixes bug #1709, pthread tests fixes for CMake (Thanks Scott Percival!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6674
diff changeset
   655
          return 0;
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   656
        }" HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   657
      if(HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   658
        set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   659
      else(HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   660
        check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   661
            #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   662
            int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   663
              pthread_mutexattr_t attr;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   664
              pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
7078
a2bddc1fb02f Fixes bug #1709, pthread tests fixes for CMake (Thanks Scott Percival!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6674
diff changeset
   665
              return 0;
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   666
            }" HAVE_RECURSIVE_MUTEXES_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   667
        if(HAVE_RECURSIVE_MUTEXES_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   668
          set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   669
        endif(HAVE_RECURSIVE_MUTEXES_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   670
      endif(HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   671
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   672
      if(PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   673
        check_c_source_compiles("#include <pthread.h>
7078
a2bddc1fb02f Fixes bug #1709, pthread tests fixes for CMake (Thanks Scott Percival!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6674
diff changeset
   674
                                 #include <semaphore.h>
a2bddc1fb02f Fixes bug #1709, pthread tests fixes for CMake (Thanks Scott Percival!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6674
diff changeset
   675
                                 int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   676
        if(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   677
          check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   678
              #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   679
              #include <semaphore.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   680
              int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   681
                  sem_timedwait(NULL, NULL);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   682
                  return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   683
              }" HAVE_SEM_TIMEDWAIT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   684
        endif(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   685
      endif(PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   686
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   687
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   688
          #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   689
          int main(int argc, char** argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   690
              pthread_spin_trylock(NULL);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   691
              return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   692
          }" HAVE_PTHREAD_SPINLOCK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   693
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   694
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   695
          #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   696
          #include <pthread_np.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   697
          int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   698
      check_function_exists(pthread_setname_np HAVE_PTHREAD_setNAME_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   699
      check_function_exists(pthread_set_name_np HAVE_PTHREAD_set_NAME_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   700
      set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   701
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   702
      set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   703
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   704
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c   # Can be faked, if necessary
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   705
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c    # Can be faked, if necessary
7400
243dad4e5f29 Added src/thread/pthread/SDL_systls.c to the CMake scripts.
Ryan C. Gordon <icculus@icculus.org>
parents: 7367
diff changeset
   706
          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systls.c
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   707
          )
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   708
      if(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   709
        set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   710
            ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   711
      else(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   712
        set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   713
            ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   714
      endif(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   715
      set(HAVE_SDL_THREADS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   716
    endif(HAVE_PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   717
  endif(PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   718
endmacro(CheckPTHREAD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   719
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   720
# Requires
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   721
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   722
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   723
# Sets:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   724
# USB_LIBS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   725
# USB_CFLAGS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   726
macro(CheckUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   727
  check_library_exists(usbhid hid_init "" LIBUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   728
  if(LIBUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   729
    check_include_file(usbhid.h HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   730
    if(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   731
      set(USB_CFLAGS "-DHAVE_USBHID_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   732
    endif(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   733
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   734
    check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   735
    if(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   736
      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   737
    endif(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   738
    set(USB_LIBS ${USB_LIBS} usbhid)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   739
  else(LIBUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   740
    check_include_file(usb.h HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   741
    if(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   742
      set(USB_CFLAGS "-DHAVE_USB_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   743
    endif(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   744
    check_include_file(libusb.h HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   745
    if(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   746
      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   747
    endif(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   748
    check_library_exists(usb hid_init "" LIBUSB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   749
    if(LIBUSB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   750
      set(USB_LIBS ${USB_LIBS} usb)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   751
    endif(LIBUSB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   752
  endif(LIBUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   753
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   754
  set(CMAKE_REQUIRED_FLAGS "${USB_CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   755
  set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   756
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   757
       #include <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   758
        #if defined(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   759
        #include <usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   760
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   761
        #ifdef __DragonFly__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   762
        # include <bus/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   763
        # include <bus/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   764
        #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   765
        # include <dev/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   766
        # include <dev/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   767
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   768
        #if defined(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   769
        #include <usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   770
        #elif defined(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   771
        #include <libusb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   772
        #elif defined(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   773
        #include <libusbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   774
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   775
        int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   776
          struct report_desc *repdesc;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   777
          struct usb_ctl_report *repbuf;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   778
          hid_kind_t hidkind;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   779
          return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   780
        }" HAVE_USBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   781
  if(HAVE_USBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   782
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   783
          #include <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   784
          #if defined(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   785
          #include <usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   786
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   787
          #ifdef __DragonFly__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   788
          # include <bus/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   789
          # include <bus/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   790
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   791
          # include <dev/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   792
          # include <dev/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   793
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   794
          #if defined(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   795
          #include <usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   796
          #elif defined(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   797
          #include <libusb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   798
          #elif defined(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   799
          #include <libusbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   800
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   801
          int main(int argc, char** argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   802
            struct usb_ctl_report buf;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   803
            if (buf.ucr_data) { }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   804
            return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   805
          }" HAVE_USBHID_UCR_DATA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   806
    if(HAVE_USBHID_UCR_DATA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   807
      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   808
    endif(HAVE_USBHID_UCR_DATA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   809
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   810
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   811
          #include <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   812
          #if defined(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   813
          #include <usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   814
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   815
          #ifdef __DragonFly__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   816
          #include <bus/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   817
          #include <bus/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   818
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   819
          #include <dev/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   820
          #include <dev/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   821
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   822
          #if defined(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   823
          #include <usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   824
          #elif defined(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   825
          #include <libusb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   826
          #elif defined(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   827
          #include <libusbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   828
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   829
          int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   830
            report_desc_t d;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   831
            hid_start_parse(d, 1, 1);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   832
            return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   833
          }" HAVE_USBHID_NEW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   834
    if(HAVE_USBHID_NEW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   835
      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   836
    endif(HAVE_USBHID_NEW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   837
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   838
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   839
        #include <machine/joystick.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   840
        int main(int argc, char** argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   841
            struct joystick t;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   842
            return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   843
        }" HAVE_MACHINE_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   844
    if(HAVE_MACHINE_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   845
      set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   846
    endif(HAVE_MACHINE_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   847
    set(SDL_JOYSTICK_USBHID 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   848
    file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   849
    set(SOURCE_FILES ${SOURCE_FILES} ${BSD_JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   850
    list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   851
    list(APPEND EXTRA_LIBS ${USB_LIBS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   852
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   853
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   854
    set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   855
    set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   856
  endif(HAVE_USBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   857
endmacro(CheckUSBHID)