cmake/sdlchecks.cmake
author Ryan C. Gordon <icculus@icculus.org>
Sun, 23 Feb 2014 01:10:33 -0500
changeset 8244 bfea1a568a0a
parent 8159 427e8fdf6f69
child 8991 13b0df1793e8
permissions -rw-r--r--
CMake: Just assume Apple platforms have Cocoa support. Fixes Bugzilla #2056.
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()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    42
      endif(DLOPEN_LIB)
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()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
endmacro(CheckDLOPEN)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
    endif(NOT OSS_FOUND)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
      endif(OSS_HEADER_FILE STREQUAL "soundcard.h")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
      endif(NETBSD OR OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
      set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
    endif(OSS_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
  endif(OSS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
endmacro(CheckOSS)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   120
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   121
      else(ALSA_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   123
      endif(ALSA_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   125
    endif(HAVE_ASOUNDLIB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
  endif(ALSA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
endmacro(CheckALSA)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
      else(PULSEAUDIO_SHARED)
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})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   153
      endif(PULSEAUDIO_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
    endif(PKG_PULSEAUDIO_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   156
  endif(PULSEAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   157
endmacro(CheckPulseAudio)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   180
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   181
      else(ESD_SHARED)
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})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   183
      endif(ESD_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   185
    endif(PKG_ESD_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   186
  endif(ESD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   187
endmacro(CheckESD)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   215
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   216
      else(ARTS_SHARED)
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})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   218
      endif(ARTS_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   220
    endif(ARTS_CONFIG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   221
  endif(ARTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   222
endmacro(CheckARTS)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   246
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   247
      else(NAS_SHARED)
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})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   249
      endif(NAS_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   251
    endif(HAVE_NAS_H AND D_NAS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   252
  endif(NAS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   253
endmacro(CheckNAS)
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)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   277
        endif(NOT HAVE_DLOPEN)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   278
      else(SNDIO_SHARED)
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})
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   280
      endif(SNDIO_SHARED)
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)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   282
    endif(HAVE_SNDIO_H AND D_SNDIO_LIB)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   283
  endif(SNDIO)
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 7266
diff changeset
   284
endmacro(CheckSNDIO)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   307
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   308
      else(FUSIONSOUND_SHARED)
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})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   310
      endif(FUSIONSOUND_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   312
    endif(PKG_FUSIONSOUND_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   313
  endif(FUSIONSOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   314
endmacro(CheckFusionSound)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   356
      endif(APPLE)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   363
        endif(HAVE_SHMAT)
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")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   367
        endif(NOT HAVE_SHMAT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   368
      endif(NOT HAVE_SHMAT)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   374
        else(NOT HAVE_DLOPEN)
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}\"")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   380
        else(HAVE_X11_SHARED)
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})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   382
        endif(HAVE_X11_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   383
      endif(X11_SHARED)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   397
      endif(HAVE_CONST_XEXT_ADDDISPLAY)
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)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   410
      endif(HAVE_XGENERICEVENT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   411
7266
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   412
      check_c_source_compiles("
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   413
          #include <X11/Xlibint.h>
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   414
          extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   415
          int main(int argc, char **argv) {}" HAVE_CONST_XDATA32)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   416
      if(HAVE_CONST_XDATA32)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   417
        set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   418
      endif(HAVE_CONST_XDATA32)
6caad66a4966 Fix compilation with libX11 >= 1.5.99.902.
Azamat H. Hackimov <azamat.hackimov@gmail.com>
parents: 7182
diff changeset
   419
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   420
      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
   421
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   422
      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
   423
        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
   424
        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
   425
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   426
        else(HAVE_X11_SHARED AND XCURSOR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   427
          list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   428
        endif(HAVE_X11_SHARED AND XCURSOR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   429
        set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   430
      endif(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   431
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   432
      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
   433
        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
   434
        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
   435
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB_SONAME}\"")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   436
        else(HAVE_X11_SHARED AND XINERAMA_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   437
          list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   438
        endif(HAVE_X11_SHARED AND XINERAMA_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   439
        set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   440
      endif(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   441
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   442
      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
   443
        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
   444
        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
   445
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   446
        else(HAVE_X11_SHARED AND XI_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   447
          list(APPEND EXTRA_LIBS ${XI_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   448
        endif(HAVE_X11_SHARED AND XI_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   449
        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
   450
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   451
        # Check for multitouch
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   452
        check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   453
            #include <X11/Xlib.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   454
            #include <X11/Xproto.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   455
            #include <X11/extensions/XInput2.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   456
            int event_type = XI_TouchBegin;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   457
            XITouchClassInfo *t;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   458
            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
   459
            {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   460
              return (Status)0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   461
            }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   462
            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
   463
        if(HAVE_XINPUT2_MULTITOUCH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   464
          set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   465
        endif(HAVE_XINPUT2_MULTITOUCH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   466
      endif(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   467
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   468
      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
   469
        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
   470
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   471
        else(HAVE_X11_SHARED AND XRANDR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   472
          list(APPEND EXTRA_LIBS ${XRANDR_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   473
        endif(HAVE_X11_SHARED AND XRANDR_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   474
        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
   475
        set(HAVE_VIDEO_X11_XRANDR TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   476
      endif(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   477
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   478
      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
   479
        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
   480
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   481
        else(HAVE_X11_SHARED AND XSS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   482
          list(APPEND EXTRA_LIBS ${XSS_LIB})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   483
        endif(HAVE_X11_SHARED AND XSS_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   484
        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
   485
        set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   486
      endif(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   487
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   488
      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
   489
        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
   490
        set(HAVE_VIDEO_X11_XSHAPE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   491
      endif(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   492
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   493
      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
   494
        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
   495
          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XXF86VM_LIB_SONAME}\"")
c858be546e5a Fixed XF86 VidMode extension dynamic loading with CMake project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8062
diff changeset
   496
        else(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
   497
          list(APPEND EXTRA_LIBS ${XXF86VM_LIB})
c858be546e5a Fixed XF86 VidMode extension dynamic loading with CMake project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8062
diff changeset
   498
        endif(HAVE_X11_SHARED AND XXF86VM_LIB)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   499
        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
   500
        set(HAVE_VIDEO_X11_XVM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   501
      endif(VIDEO_X11_XVM AND HAVE_XF86VM_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   502
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   503
      set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   504
    endif(X11_LIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   505
  endif(VIDEO_X11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   506
endmacro(CheckX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   507
8153
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   508
macro(CheckMir)
8159
427e8fdf6f69 Hooked up dynamic loading for Mir.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   509
# !!! FIXME: hook up dynamic loading here.
8153
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   510
    if(VIDEO_MIR)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   511
        find_library(MIR_LIB mirclient mircommon egl)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   512
        pkg_check_modules(MIR_TOOLKIT mirclient mircommon)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   513
        pkg_check_modules(EGL egl)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   514
        pkg_check_modules(XKB xkbcommon)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   515
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   516
        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
   517
            set(HAVE_VIDEO_MIR TRUE)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   518
            set(HAVE_SDL_VIDEO TRUE)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   519
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   520
            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
   521
            set(SOURCE_FILES ${SOURCE_FILES} ${MIR_SOURCES})
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   522
            set(SDL_VIDEO_DRIVER_MIR 1)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   523
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   524
            list(APPEND EXTRA_CFLAGS ${MIR_TOOLKIT_CFLAGS} ${EGL_CLFAGS} ${XKB_CLFLAGS})
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   525
            list(APPEND EXTRA_LDFLAGS ${MIR_TOOLKIT_LDFLAGS} ${EGL_LDLAGS} ${XKB_LDLAGS})
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   526
        endif (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
   527
    endif(VIDEO_MIR)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   528
endmacro(CheckMir)
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8120
diff changeset
   529
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   530
# Requires:
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   531
# - EGL
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   532
macro(CheckWayland)
8159
427e8fdf6f69 Hooked up dynamic loading for Mir.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   533
# !!! FIXME: hook up dynamic loading here.
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   534
  if(VIDEO_WAYLAND)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   535
    pkg_check_modules(WAYLAND wayland-client wayland-cursor wayland-egl egl xkbcommon)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   536
    if(WAYLAND_FOUND)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   537
      link_directories(
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   538
          ${WAYLAND_LIBRARY_DIRS}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   539
      )
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   540
      include_directories(
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   541
          ${WAYLAND_INCLUDE_DIRS}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   542
      )
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   543
      set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   544
      set(HAVE_VIDEO_WAYLAND TRUE)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   545
      set(HAVE_SDL_VIDEO TRUE)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   546
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   547
      file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   548
      set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   549
      set(SDL_VIDEO_DRIVER_WAYLAND 1)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   550
    endif(WAYLAND_FOUND)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   551
  endif(VIDEO_WAYLAND)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   552
endmacro(CheckWayland)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   553
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8017
diff changeset
   554
# Requires:
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   555
# - n/a
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   556
#
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   557
macro(CheckCOCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   558
  if(VIDEO_COCOA)
8244
bfea1a568a0a CMake: Just assume Apple platforms have Cocoa support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8159
diff changeset
   559
    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
   560
      set(HAVE_VIDEO_COCOA TRUE)
bfea1a568a0a CMake: Just assume Apple platforms have Cocoa support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8159
diff changeset
   561
    endif(APPLE)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   562
    if(HAVE_VIDEO_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   563
      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
   564
      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
   565
      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
   566
      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
   567
      set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   568
    endif(HAVE_VIDEO_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   569
  endif(VIDEO_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   570
endmacro(CheckCOCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   571
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   572
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   573
# - PkgCheckModules
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   574
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   575
# - DIRECTFB_SHARED opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   576
# - HAVE_DLOPEN opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   577
macro(CheckDirectFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   578
  if(VIDEO_DIRECTFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   579
    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
   580
    if(PKG_DIRECTFB_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   581
      set(HAVE_VIDEO_DIRECTFB TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   582
      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
   583
      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
   584
      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
   585
      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
   586
      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
   587
      if(DIRECTFB_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   588
        if(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   589
          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
   590
        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
   591
          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
   592
          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
   593
          set(HAVE_DIRECTFB_SHARED TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   594
        endif(NOT HAVE_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   595
      else(DIRECTFB_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   596
        list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   597
      endif(DIRECTFB_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   598
      set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   599
    endif(PKG_DIRECTFB_FOUND)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   600
  endif(VIDEO_DIRECTFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   601
endmacro(CheckDirectFB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   602
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   603
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   604
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   605
macro(CheckOpenGLX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   606
  if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   607
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   608
        #include <GL/gl.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   609
        #include <GL/glx.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   610
        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
   611
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   612
    if(HAVE_VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   613
      set(HAVE_VIDEO_OPENGL TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   614
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   615
      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
   616
      set(SDL_VIDEO_RENDER_OGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   617
      list(APPEND EXTRA_LIBS GL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   618
    endif(HAVE_VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   619
  endif(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   620
endmacro(CheckOpenGLX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   621
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   622
# Requires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   623
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   624
macro(CheckOpenGLESX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   625
  if(VIDEO_OPENGLES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   626
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   627
        #include <EGL/egl.h>
7690
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   628
        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
   629
    if(HAVE_VIDEO_OPENGL_EGL)
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   630
        set(SDL_VIDEO_OPENGL_EGL 1)
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   631
    endif(HAVE_VIDEO_OPENGL_EGL) 
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   632
    check_c_source_compiles("
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   633
      #include <GLES/gl.h>
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   634
      #include <GLES/glext.h>
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   635
      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
   636
    if(HAVE_VIDEO_OPENGLES_V1)
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   637
        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
   638
        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
   639
        set(SDL_VIDEO_RENDER_OGL_ES 1)
7690
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   640
    endif(HAVE_VIDEO_OPENGLES_V1)
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   641
    check_c_source_compiles("
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   642
      #include <GLES2/gl2.h>
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   643
      #include <GLES2/gl2ext.h>
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   644
      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
   645
    if(HAVE_VIDEO_OPENGLES_V2)
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   646
        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
   647
        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
   648
        set(SDL_VIDEO_RENDER_OGL_ES2 1)
7690
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   649
    endif(HAVE_VIDEO_OPENGLES_V2)
76d7b6007a64 Separate EGL / GL ES detection in CMake
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7521
diff changeset
   650
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   651
  endif(VIDEO_OPENGLES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   652
endmacro(CheckOpenGLESX11)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   653
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   654
# Rquires:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   655
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   656
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   657
# - THREADS opt
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   658
# Sets:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   659
# PTHREAD_CFLAGS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   660
# PTHREAD_LIBS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   661
macro(CheckPTHREAD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   662
  if(PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   663
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   664
      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
   665
      set(PTHREAD_LDFLAGS "-pthread")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   666
    elseif(BSDI)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   667
      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
   668
      set(PTHREAD_LDFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   669
    elseif(DARWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   670
      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
   671
      # causes Carbon.p complaints?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   672
      # 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
   673
      set(PTHREAD_LDFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   674
    elseif(FREEBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   675
      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
   676
      set(PTHREAD_LDFLAGS "-pthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   677
    elseif(NETBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   678
      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
   679
      set(PTHREAD_LDFLAGS "-lpthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   680
    elseif(OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   681
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   682
      set(PTHREAD_LDFLAGS "-pthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   683
    elseif(SOLARIS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   684
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   685
      set(PTHREAD_LDFLAGS "-pthread -lposix4")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   686
    elseif(SYSV5)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   687
      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
   688
      set(PTHREAD_LDFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   689
    elseif(AIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   690
      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
   691
      set(PTHREAD_LDFLAGS "-pthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   692
    elseif(HPUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   693
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   694
      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
   695
    elseif(HAIKU)
7977
5272ae8fccd7 Started BeOS removal: merged BeOS thread and pthread code.
Ryan C. Gordon <icculus@icculus.org>
parents: 7835
diff changeset
   696
      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
   697
      set(PTHREAD_LDFLAGS "")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   698
    else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   699
      set(PTHREAD_CFLAGS "-D_REENTRANT")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   700
      set(PTHREAD_LDFLAGS "-lpthread")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   701
    endif(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   702
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   703
    # Run some tests
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   704
    set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   705
    check_c_source_runs("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   706
        #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   707
        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
   708
          pthread_attr_t type;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   709
          pthread_attr_init(&type);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   710
          return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   711
        }" HAVE_PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   712
    if(HAVE_PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   713
      set(SDL_THREAD_PTHREAD 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   714
      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
   715
      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
   716
      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
   717
      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
   718
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   719
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   720
        #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   721
        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
   722
          pthread_mutexattr_t attr;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   723
          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
   724
          return 0;
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   725
        }" HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   726
      if(HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   727
        set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   728
      else(HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   729
        check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   730
            #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   731
            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
   732
              pthread_mutexattr_t attr;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   733
              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
   734
              return 0;
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   735
            }" HAVE_RECURSIVE_MUTEXES_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   736
        if(HAVE_RECURSIVE_MUTEXES_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   737
          set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   738
        endif(HAVE_RECURSIVE_MUTEXES_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   739
      endif(HAVE_RECURSIVE_MUTEXES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   740
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   741
      if(PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   742
        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
   743
                                 #include <semaphore.h>
a2bddc1fb02f Fixes bug #1709, pthread tests fixes for CMake (Thanks Scott Percival!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6674
diff changeset
   744
                                 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
   745
        if(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   746
          check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   747
              #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   748
              #include <semaphore.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   749
              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
   750
                  sem_timedwait(NULL, NULL);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   751
                  return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   752
              }" HAVE_SEM_TIMEDWAIT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   753
        endif(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   754
      endif(PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   755
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   756
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   757
          #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   758
          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
   759
              pthread_spin_trylock(NULL);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   760
              return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   761
          }" HAVE_PTHREAD_SPINLOCK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   762
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   763
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   764
          #include <pthread.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   765
          #include <pthread_np.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   766
          int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   767
      check_function_exists(pthread_setname_np HAVE_PTHREAD_setNAME_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   768
      check_function_exists(pthread_set_name_np HAVE_PTHREAD_set_NAME_NP)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   769
      set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   770
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   771
      set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   772
          ${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
   773
          ${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
   774
          ${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
   775
          ${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
   776
          )
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   777
      if(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   778
        set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   779
            ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   780
      else(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   781
        set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   782
            ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   783
      endif(HAVE_PTHREADS_SEM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   784
      set(HAVE_SDL_THREADS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   785
    endif(HAVE_PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   786
  endif(PTHREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   787
endmacro(CheckPTHREAD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   788
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   789
# Requires
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   790
# - nada
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   791
# Optional:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   792
# Sets:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   793
# USB_LIBS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   794
# USB_CFLAGS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   795
macro(CheckUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   796
  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
   797
  if(LIBUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   798
    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
   799
    if(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   800
      set(USB_CFLAGS "-DHAVE_USBHID_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   801
    endif(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   802
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   803
    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
   804
    if(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   805
      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   806
    endif(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   807
    set(USB_LIBS ${USB_LIBS} usbhid)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   808
  else(LIBUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   809
    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
   810
    if(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   811
      set(USB_CFLAGS "-DHAVE_USB_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   812
    endif(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   813
    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
   814
    if(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   815
      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   816
    endif(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   817
    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
   818
    if(LIBUSB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   819
      set(USB_LIBS ${USB_LIBS} usb)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   820
    endif(LIBUSB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   821
  endif(LIBUSBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   822
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   823
  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
   824
  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
   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 <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   827
        #if defined(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   828
        #include <usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   829
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   830
        #ifdef __DragonFly__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   831
        # include <bus/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   832
        # include <bus/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   833
        #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   834
        # include <dev/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   835
        # include <dev/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   836
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   837
        #if defined(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   838
        #include <usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   839
        #elif defined(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   840
        #include <libusb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   841
        #elif defined(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   842
        #include <libusbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   843
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   844
        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
   845
          struct report_desc *repdesc;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   846
          struct usb_ctl_report *repbuf;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   847
          hid_kind_t hidkind;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   848
          return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   849
        }" HAVE_USBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   850
  if(HAVE_USBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   851
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   852
          #include <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   853
          #if defined(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   854
          #include <usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   855
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   856
          #ifdef __DragonFly__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   857
          # include <bus/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   858
          # include <bus/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   859
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   860
          # include <dev/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   861
          # include <dev/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   862
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   863
          #if defined(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   864
          #include <usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   865
          #elif defined(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   866
          #include <libusb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   867
          #elif defined(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   868
          #include <libusbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   869
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   870
          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
   871
            struct usb_ctl_report buf;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   872
            if (buf.ucr_data) { }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   873
            return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   874
          }" HAVE_USBHID_UCR_DATA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   875
    if(HAVE_USBHID_UCR_DATA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   876
      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   877
    endif(HAVE_USBHID_UCR_DATA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   878
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   879
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   880
          #include <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   881
          #if defined(HAVE_USB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   882
          #include <usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   883
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   884
          #ifdef __DragonFly__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   885
          #include <bus/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   886
          #include <bus/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   887
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   888
          #include <dev/usb/usb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   889
          #include <dev/usb/usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   890
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   891
          #if defined(HAVE_USBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   892
          #include <usbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   893
          #elif defined(HAVE_LIBUSB_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   894
          #include <libusb.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   895
          #elif defined(HAVE_LIBUSBHID_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   896
          #include <libusbhid.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   897
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   898
          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
   899
            report_desc_t d;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   900
            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
   901
            return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   902
          }" HAVE_USBHID_NEW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   903
    if(HAVE_USBHID_NEW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   904
      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   905
    endif(HAVE_USBHID_NEW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   906
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   907
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   908
        #include <machine/joystick.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   909
        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
   910
            struct joystick t;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   911
            return 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   912
        }" HAVE_MACHINE_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   913
    if(HAVE_MACHINE_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   914
      set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   915
    endif(HAVE_MACHINE_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   916
    set(SDL_JOYSTICK_USBHID 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   917
    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
   918
    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
   919
    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
   920
    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
   921
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   922
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   923
    set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   924
    set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   925
  endif(HAVE_USBHID)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   926
endmacro(CheckUSBHID)