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