CMakeLists.txt
author Ryan C. Gordon <icculus@icculus.org>
Tue, 29 Dec 2015 00:24:37 -0500
changeset 9980 224187458d03
parent 9979 e3d651c5fe31
child 9981 a443c97eb294
permissions -rw-r--r--
CMake: don't try to use the Linux joystick code on Android (thanks, Martin!). Fixes Bugzilla #3201.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     1
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     2
  message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     3
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     4
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
     5
cmake_minimum_required(VERSION 2.8)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     6
project(SDL2 C)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     7
include(CheckFunctionExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     8
include(CheckLibraryExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     9
include(CheckIncludeFiles)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    10
include(CheckIncludeFile)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    11
include(CheckSymbolExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    12
include(CheckCSourceRuns)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    13
include(CheckCCompilerFlag)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    14
include(CheckTypeSize)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    15
include(CheckStructHasMember)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    16
include(CMakeDependentOption)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    17
include(FindPkgConfig)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    21
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    22
# General settings
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    23
# Edit include/SDL_version.h and change the version, then:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    24
#   SDL_MICRO_VERSION += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
#   SDL_INTERFACE_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
#   SDL_BINARY_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
# if any functions have been added, set SDL_INTERFACE_AGE to 0.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
# if backwards compatibility has been broken,
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    30
set(SDL_MAJOR_VERSION 2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    31
set(SDL_MINOR_VERSION 0)
9121
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    32
set(SDL_MICRO_VERSION 4)
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    33
set(SDL_INTERFACE_AGE 0)
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    34
set(SDL_BINARY_AGE 4)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    35
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
# Calculate a libtool-like version number
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    39
math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}")
8203
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    40
math(EXPR LT_MAJOR "${LT_CURRENT}- ${LT_AGE}")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    41
set(LT_REVISION "${SDL_INTERFACE_AGE}")
7525
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
    42
set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}")
8203
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    43
set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}")
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    44
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    45
message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    46
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    47
# General settings & flags
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
set(LIBRARY_OUTPUT_DIRECTORY "build")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    49
# Check for 64 or 32 bit
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    50
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    51
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    52
  set(ARCH_64 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    53
  set(PROCESSOR_ARCH "x64")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    54
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    55
  set(ARCH_64 FALSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    56
  set(PROCESSOR_ARCH "x86")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
    57
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
set(LIBNAME SDL2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
if(NOT LIBTYPE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
  set(LIBTYPE SHARED)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
    61
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    62
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    63
# Get the platform
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
if(WIN32)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
  if(NOT WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
    set(WINDOWS TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
    67
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    68
elseif(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
  if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
    set(LINUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
  elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    72
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
  elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
    set(NETBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
  elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
    set(OPENBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    78
    set(GNU TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
    set(BSDI TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
  elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    83
  elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
    set(SYSV5 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    85
  elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
    set(SOLARIS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    87
  elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
    set(HPUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    89
  elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
    set(AIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    91
  elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
    set(MINIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
elseif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
  if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
    set(DARWIN TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
    set(MACOSX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    99
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
  # TODO: iOS?
7981
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   101
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   102
  message_error("BeOS support has been removed as of SDL 2.0.2.")
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   103
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   104
  set(HAIKU TRUE)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   107
# Don't mistake osx for unix
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
if(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   109
  set(UNIX_SYS ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   110
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   111
  set(UNIX_SYS OFF)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   112
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   113
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   114
if(UNIX OR APPLE)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   115
  set(UNIX_OR_MAC_SYS ON)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   116
else()
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   117
  set(UNIX_OR_MAC_SYS OFF)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   118
endif()
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   119
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   120
if (UNIX_OR_MAC_SYS AND NOT EMSCRIPTEN) # JavaScript does not yet have threading support, so disable pthreads when building for Emscripten.
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   121
  set(SDL_PTHREADS_ENABLED_BY_DEFAULT ON)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   122
else()
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   123
  set(SDL_PTHREADS_ENABLED_BY_DEFAULT OFF)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   124
endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   125
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
# Default option knobs
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
if(APPLE OR ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   128
  set(OPT_DEF_SSEMATH ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   129
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   130
if(UNIX OR MINGW OR MSYS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   131
  set(OPT_DEF_LIBC ON)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   132
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   133
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   134
# Compiler info
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   135
if(CMAKE_COMPILER_IS_GNUCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   136
  set(USE_GCC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
  set(USE_CLANG TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   142
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   143
  #set(CMAKE_C_FLAGS "/ZI /WX- /
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
  set(OPT_DEF_ASM FALSE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   146
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
# Default flags, if not set otherwise
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
if("$ENV{CFLAGS}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
  if(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
    set(CMAKE_C_FLAGS "-g -O3")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   152
  endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   153
else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
  set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
  list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   156
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   157
if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   158
  list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   159
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   160
8136
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   161
if(MSVC)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   162
  option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   163
  if(FORCE_STATIC_VCRT)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   164
    foreach(flag_var
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   165
        CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   166
        CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   167
      if(${flag_var} MATCHES "/MD")
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   168
        string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   169
      endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   170
    endforeach()
8136
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   171
  endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   172
endif()
8136
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   173
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   174
# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   175
# etc. are created correctly.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   176
set(SDL_LIBS "-lSDL2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   177
set(SDL_CFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   178
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   179
# Emscripten toolchain has a nonempty default value for this, and the checks 
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   180
# in this file need to change that, so remember the original value, and 
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   181
# restore back to that afterwards. For check_function_exists() to work in
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   182
# Emscripten, this value must be at its default value.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   183
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   184
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   185
if(CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   186
  # We build SDL on cygwin without the UNIX emulation layer
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   187
  include_directories("-I/usr/include/mingw")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   188
  set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   189
  check_c_source_compiles("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
   190
    HAVE_GCC_NO_CYGWIN)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   191
  set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   192
  if(HAVE_GCC_NO_CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   193
    list(APPEND EXTRA_LDFLAGS "-mno-cygwin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   194
    list(APPEND SDL_LIBS "-mno-cygwin")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   195
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   196
  set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include/mingw")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   197
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   198
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   199
add_definitions(-DUSING_GENERATED_CONFIG_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   200
# General includes
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   201
include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   202
9279
e1d1b6479a14 CMake: Minor cleanup up on the new SDL_*_ENABLED_BY_DEFAULT vars.
Ryan C. Gordon <icculus@icculus.org>
parents: 9278
diff changeset
   203
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
e1d1b6479a14 CMake: Minor cleanup up on the new SDL_*_ENABLED_BY_DEFAULT vars.
Ryan C. Gordon <icculus@icculus.org>
parents: 9278
diff changeset
   204
#  you only need to have a platform override them if they are disabling.
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   205
set(OPT_DEF_ASM TRUE)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   206
if(EMSCRIPTEN)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   207
  # Set up default values for the currently supported set of subsystems:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   208
  # Emscripten/Javascript does not have assembly support, a dynamic library 
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   209
  # loading architecture, low-level CPU inspection or multithreading.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   210
  set(OPT_DEF_ASM FALSE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   211
  set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   212
  set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   213
  set(SDL_THREADS_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   214
  set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   215
  set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   216
  set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   217
endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   218
9717
45a632fd9d83 CMake: default to shared library builds being enabled.
Ryan C. Gordon <icculus@icculus.org>
parents: 9571
diff changeset
   219
if (NOT DEFINED SDL_SHARED_ENABLED_BY_DEFAULT)
45a632fd9d83 CMake: default to shared library builds being enabled.
Ryan C. Gordon <icculus@icculus.org>
parents: 9571
diff changeset
   220
    set(SDL_SHARED_ENABLED_BY_DEFAULT ON)
45a632fd9d83 CMake: default to shared library builds being enabled.
Ryan C. Gordon <icculus@icculus.org>
parents: 9571
diff changeset
   221
endif()
45a632fd9d83 CMake: default to shared library builds being enabled.
Ryan C. Gordon <icculus@icculus.org>
parents: 9571
diff changeset
   222
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   223
set(SDL_SUBSYSTEMS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   224
    Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   225
    File Loadso CPUinfo Filesystem Dlopen)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   226
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   227
  string(TOUPPER ${_SUB} _OPT)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   228
  if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   229
    set(SDL_${_OPT}_ENABLED_BY_DEFAULT ON)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   230
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   231
  option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ${SDL_${_OPT}_ENABLED_BY_DEFAULT})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   232
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   233
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   234
option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   235
#set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   236
set_option(LIBC                "Use the system C library" ${OPT_DEF_LIBC})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   237
set_option(GCC_ATOMICS         "Use gcc builtin atomics" ${USE_GCC})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   238
set_option(ASSEMBLY            "Enable assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   239
set_option(SSEMATH             "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   240
set_option(MMX                 "Use MMX assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   241
set_option(3DNOW               "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   242
set_option(SSE                 "Use SSE assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   243
set_option(SSE2                "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   244
set_option(ALTIVEC             "Use Altivec assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   245
set_option(DISKAUDIO           "Support the disk writer audio driver" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   246
set_option(DUMMYAUDIO          "Support the dummy audio driver" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   247
set_option(VIDEO_DIRECTFB      "Use DirectFB video driver" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   248
dep_option(DIRECTFB_SHARED     "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   249
set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
9466
510c9a2f0951 CMake: Dependency variable for FUSIONSOUND_SHARED was wrong (thanks, Kaleb!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9431
diff changeset
   250
dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   251
set_option(VIDEO_DUMMY         "Use dummy video driver" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   252
set_option(VIDEO_OPENGL        "Include OpenGL support" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   253
set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   254
set_option(PTHREADS            "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   255
dep_option(PTHREADS_SEM        "Use pthread semaphores" ON "PTHREADS" OFF)
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   256
set_option(SDL_DLOPEN          "Use dlopen for shared object loading" ${SDL_DLOPEN_ENABLED_BY_DEFAULT})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   257
set_option(OSS                 "Support the OSS audio API" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   258
set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   259
dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   260
set_option(ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   261
dep_option(ESD_SHARED          "Dynamically load ESD audio support" ON "ESD" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   262
set_option(PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   263
dep_option(PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "PULSEAUDIO" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   264
set_option(ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   265
dep_option(ARTS_SHARED         "Dynamically load aRts audio support" ON "ARTS" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   266
set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
8118
f0b6338dc866 Fixed dynamic loading of NAS in CMake project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8094
diff changeset
   267
set_option(NAS_SHARED          "Dynamically load NAS audio API" ${UNIX_SYS})
7367
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 6774
diff changeset
   268
set_option(SNDIO               "Support the sndio audio API" ${UNIX_SYS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   269
set_option(RPATH               "Use an rpath when linking SDL" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   270
set_option(CLOCK_GETTIME       "Use clock_gettime() instead of gettimeofday()" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   271
set_option(INPUT_TSLIB         "Use the Touchscreen library for input" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   272
set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
8680
eb1281b43b5d Re-enable Mir/Wayland support now that 2.0.3 has been released.
Brandon Schaefer <brandon.schaefer@canonical.com>
parents: 8606
diff changeset
   273
set_option(VIDEO_WAYLAND       "Use Wayland video driver" ${UNIX_SYS})
9409
9df20f292907 CMake project files no longer force you to link against Wayland or Mir libs.
Ryan C. Gordon <icculus@icculus.org>
parents: 9408
diff changeset
   274
dep_option(WAYLAND_SHARED      "Dynamically load Wayland support" ON "VIDEO_WAYLAND" OFF)
9df20f292907 CMake project files no longer force you to link against Wayland or Mir libs.
Ryan C. Gordon <icculus@icculus.org>
parents: 9408
diff changeset
   275
dep_option(VIDEO_WAYLAND_QT_TOUCH  "QtWayland server support for Wayland video driver" ON "VIDEO_WAYLAND" OFF)
8680
eb1281b43b5d Re-enable Mir/Wayland support now that 2.0.3 has been released.
Brandon Schaefer <brandon.schaefer@canonical.com>
parents: 8606
diff changeset
   276
set_option(VIDEO_MIR           "Use Mir video driver" ${UNIX_SYS})
9409
9df20f292907 CMake project files no longer force you to link against Wayland or Mir libs.
Ryan C. Gordon <icculus@icculus.org>
parents: 9408
diff changeset
   277
dep_option(MIR_SHARED          "Dynamically load Mir support" ON "VIDEO_MIR" OFF)
9077
28e6de55eb07 Fixed bug 2683 - Raspberry PI support using CMake
Sam Lantinga <slouken@libsdl.org>
parents: 9075
diff changeset
   278
set_option(VIDEO_RPI           "Use Raspberry Pi video driver" ${UNIX_SYS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   279
dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   280
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   281
foreach(_SUB ${SDL_X11_OPTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   282
  string(TOUPPER "VIDEO_X11_${_SUB}" _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   283
  dep_option(${_OPT}           "Enable ${_SUB} support" ON "VIDEO_X11" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   284
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   285
set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   286
set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   287
set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
9164
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9127
diff changeset
   288
set_option(VIDEO_VIVANTE       "Use Vivante EGL video driver" ${UNIX_SYS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   289
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   290
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   291
# The options below are for compatibility to configure's default behaviour.
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   292
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   293
set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   294
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   295
# General source files
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   296
file(GLOB SOURCE_FILES
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   297
  ${SDL2_SOURCE_DIR}/src/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   298
  ${SDL2_SOURCE_DIR}/src/atomic/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   299
  ${SDL2_SOURCE_DIR}/src/audio/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   300
  ${SDL2_SOURCE_DIR}/src/cpuinfo/*.c
8094
9efaae827924 Implemented the Dynamic API magic.
Ryan C. Gordon <icculus@icculus.org>
parents: 8090
diff changeset
   301
  ${SDL2_SOURCE_DIR}/src/dynapi/*.c
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   302
  ${SDL2_SOURCE_DIR}/src/events/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   303
  ${SDL2_SOURCE_DIR}/src/file/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   304
  ${SDL2_SOURCE_DIR}/src/libm/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   305
  ${SDL2_SOURCE_DIR}/src/render/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   306
  ${SDL2_SOURCE_DIR}/src/render/*/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   307
  ${SDL2_SOURCE_DIR}/src/stdlib/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   308
  ${SDL2_SOURCE_DIR}/src/thread/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   309
  ${SDL2_SOURCE_DIR}/src/timer/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   310
  ${SDL2_SOURCE_DIR}/src/video/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   311
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   312
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   313
if(ASSERTIONS STREQUAL "auto")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   314
  # Do nada - use optimization settings to determine the assertion level
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   315
elseif(ASSERTIONS STREQUAL "disabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   316
  set(SDL_DEFAULT_ASSERT_LEVEL 0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   317
elseif(ASSERTIONS STREQUAL "release")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   318
  set(SDL_DEFAULT_ASSERT_LEVEL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   319
elseif(ASSERTIONS STREQUAL "enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   320
  set(SDL_DEFAULT_ASSERT_LEVEL 2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   321
elseif(ASSERTIONS STREQUAL "paranoid")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   322
  set(SDL_DEFAULT_ASSERT_LEVEL 3)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   323
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   324
  message_error("unknown assertion level")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   325
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   326
set(HAVE_ASSERTIONS ${ASSERTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   327
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   328
# Compiler option evaluation
7999
2c9aedfba740 Fixed bug 2238 - Enable GCC atomics for clang
Sam Lantinga <slouken@libsdl.org>
parents: 7981
diff changeset
   329
if(USE_GCC OR USE_CLANG)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   330
  if(DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   331
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   332
        #if !defined(__GNUC__) || __GNUC__ < 3
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   333
        #error Dependency tracking requires GCC 3.0 or newer
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   334
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   335
        int main(int argc, char **argv) { }" HAVE_DEPENDENCY_TRACKING)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   336
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   337
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   338
  if(GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   339
    check_c_source_compiles("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
   340
        int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   341
        void *x, *y, *z;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   342
        __sync_lock_test_and_set(&a, 4);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   343
        __sync_lock_test_and_set(&x, y);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   344
        __sync_fetch_and_add(&a, 1);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   345
        __sync_bool_compare_and_swap(&a, 5, 10);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   346
        __sync_bool_compare_and_swap(&x, y, z); }" HAVE_GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   347
    if(NOT HAVE_GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   348
      check_c_source_compiles("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
   349
          int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   350
          __sync_lock_test_and_set(&a, 1);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   351
          __sync_lock_release(&a); }" HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   352
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   353
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   354
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   355
  set(CMAKE_REQUIRED_FLAGS "-mpreferred-stack-boundary=2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   356
  check_c_source_compiles("int x = 0; 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
   357
    HAVE_GCC_PREFERRED_STACK_BOUNDARY)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   358
  set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   359
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   360
  set(CMAKE_REQUIRED_FLAGS "-fvisibility=hidden -Werror")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   361
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   362
      #if !defined(__GNUC__) || __GNUC__ < 4
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   363
      #error SDL only uses visibility attributes in GCC 4 or newer
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   364
      #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   365
      int main(int argc, char **argv) {}" HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   366
  if(HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   367
    list(APPEND EXTRA_CFLAGS "-fvisibility=hidden")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   368
  endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   369
  set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   370
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   371
  check_c_compiler_flag(-Wall HAVE_GCC_WALL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   372
  if(HAVE_GCC_WALL)
9081
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   373
    list(APPEND EXTRA_CFLAGS "-Wall")
7981
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   374
    if(HAIKU)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   375
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   376
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   377
  endif()
9081
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   378
  check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   379
  if(HAVE_GCC_WSHADOW)
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   380
    list(APPEND EXTRA_CFLAGS "-Wshadow")
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   381
  endif()
9082
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   382
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   383
  set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   384
  check_c_compiler_flag("" HAVE_NO_UNDEFINED)
9083
029f8d643dbe Reset CMAKE_REQUIRED_FLAGS after test
Sam Lantinga <slouken@libsdl.org>
parents: 9082
diff changeset
   385
  set(CMAKE_REQUIRED_FLAGS)
9082
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   386
  if(HAVE_NO_UNDEFINED)
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   387
    list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   388
  endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   389
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   390
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   391
if(ASSEMBLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   392
  if(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   393
    set(SDL_ASSEMBLY_ROUTINES 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   394
    # TODO: Those all seem to be quite GCC specific - needs to be
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   395
    # reworked for better compiler support
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   396
    set(HAVE_ASSEMBLY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   397
    if(MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   398
      set(CMAKE_REQUIRED_FLAGS "-mmmx")
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
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   401
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   402
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   403
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   404
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   405
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   406
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   407
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   408
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   409
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   410
          #ifndef __MMX__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   411
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   412
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   413
          int main(int argc, char **argv) { }" HAVE_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   414
      if(HAVE_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   415
        list(APPEND EXTRA_CFLAGS "-mmmx")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   416
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   417
      set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   418
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   419
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   420
    if(3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   421
      set(CMAKE_REQUIRED_FLAGS "-m3dnow")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   422
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   423
          #include <mm3dnow.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   424
          #ifndef __3dNOW__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   425
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   426
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   427
          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
   428
            void *p = 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   429
            _m_prefetch(p);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   430
          }" HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   431
      if(HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   432
        list(APPEND EXTRA_CFLAGS "-m3dnow")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   433
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   434
      set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   435
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   436
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   437
    if(SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   438
      set(CMAKE_REQUIRED_FLAGS "-msse")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   439
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   440
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   441
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   442
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   443
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   444
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   445
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   446
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   447
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   448
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   449
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   450
          #ifndef __SSE__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   451
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   452
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   453
          int main(int argc, char **argv) { }" HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   454
      if(HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   455
        list(APPEND EXTRA_CFLAGS "-msse")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   456
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   457
      set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   458
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   459
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   460
    if(SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   461
      set(CMAKE_REQUIRED_FLAGS "-msse2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   462
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   463
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   464
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   465
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   466
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   467
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   468
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   469
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   470
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   471
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   472
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   473
          #ifndef __SSE2__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   474
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   475
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   476
          int main(int argc, char **argv) { }" HAVE_SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   477
      if(HAVE_SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   478
        list(APPEND EXTRA_CFLAGS "-msse2")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   479
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   480
      set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   481
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   482
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   483
    if(SSEMATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   484
      if(SSE OR SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   485
        if(USE_GCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   486
          list(APPEND EXTRA_CFLAGS "-mfpmath=387")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   487
        endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   488
        set(HAVE_SSEMATH TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   489
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   490
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   491
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   492
    if(ALTIVEC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   493
      set(CMAKE_REQUIRED_FLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   494
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   495
          #include <altivec.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   496
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   497
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   498
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   499
          int main(int argc, char **argv) { }" HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   500
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   501
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   502
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   503
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   504
          int main(int argc, char **argv) { }" HAVE_ALTIVEC)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   505
      set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   506
      if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   507
        set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   508
        list(APPEND EXTRA_CFLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   509
        set(SDL_ALTIVEC_BLITTERS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   510
        if(HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   511
          set(HAVE_ALTIVEC_H 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   512
        endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   513
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   514
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   515
  elseif(MSVC_VERSION GREATER 1500)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   516
    # TODO: SDL_cpuinfo.h needs to support the user's configuration wish
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   517
    # for MSVC - right now it is always activated
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   518
    if(NOT ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   519
      set(HAVE_MMX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   520
      set(HAVE_3DNOW TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   521
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   522
    set(HAVE_SSE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   523
    set(HAVE_SSE2 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   524
    set(SDL_ASSEMBLY_ROUTINES 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   525
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   526
# TODO:
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   527
#else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   528
#  if(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   529
#    list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   530
#  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   531
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   532
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   533
# TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   534
# anything.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   535
if(LIBC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   536
  if(WINDOWS AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   537
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   538
    foreach(_HEADER stdio.h string.h ctype.h math.h)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   539
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   540
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   541
      set(${_HAVE_H} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   542
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   543
    set(HAVE_SIGNAL_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   544
    foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   545
            malloc calloc realloc free qsort abs memset memcpy memmove memcmp
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   546
            strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   547
            _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
8056
abd9434c5d3e Hook up SDL_acos and SDL_asin properly.
Ryan C. Gordon <icculus@icculus.org>
parents: 8032
diff changeset
   548
            _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos
9080
2e4e71ec140f Removed SDL_round() because the license wasn't compatible with zlib
Sam Lantinga <slouken@libsdl.org>
parents: 9077
diff changeset
   549
            cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   550
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   551
      set(HAVE_${_UPPER} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   552
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   553
    if(NOT CYGWIN AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   554
      set(HAVE_ALLOCA 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   555
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   556
    set(HAVE_M_PI 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   557
    add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   558
    set(STDC_HEADERS 1)
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   559
  else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   560
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   561
    check_include_file(sys/types.h HAVE_SYS_TYPES_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   562
    foreach(_HEADER
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   563
            stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   564
            strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   565
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   566
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   567
      check_include_file("${_HEADER}" ${_HAVE_H})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   568
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   569
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   570
    check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" STDC_HEADERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   571
    check_type_size("size_t" SIZEOF_SIZE_T)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   572
    check_symbol_exists(M_PI math.h HAVE_M_PI)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   573
    # TODO: refine the mprotect check
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   574
    check_c_source_compiles("#include <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   575
                             #include <sys/mman.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   576
                             int main() { }" HAVE_MPROTECT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   577
    foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   578
            strtod malloc calloc realloc free getenv setenv putenv unsetenv
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   579
            qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   580
            strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   581
            _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   582
            atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
8090
0098d4459b7a We don't need to check for snprintf() anymore, we don't use it.
Ryan C. Gordon <icculus@icculus.org>
parents: 8089
diff changeset
   583
            vsscanf vsnprintf fseeko fseeko64 sigaction setjmp
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   584
            nanosleep sysconf sysctlbyname
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   585
            )
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   586
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   587
      set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   588
      check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   589
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   590
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   591
    check_library_exists(m pow "" HAVE_LIBM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   592
    if(HAVE_LIBM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   593
      set(CMAKE_REQUIRED_LIBRARIES m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   594
      foreach(_FN
9080
2e4e71ec140f Removed SDL_round() because the license wasn't compatible with zlib
Sam Lantinga <slouken@libsdl.org>
parents: 9077
diff changeset
   595
              atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
9414
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   596
              sinf sqrt sqrtf tan tanf acos asin)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   597
        string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   598
        set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   599
        check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   600
      endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   601
      set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   602
      list(APPEND EXTRA_LIBS m)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   603
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   604
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   605
    check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   606
    if(HAVE_LIBICONV)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   607
      list(APPEND EXTRA_LIBS iconv)
9414
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   608
      set(HAVE_ICONV 1)
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   609
    endif()
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   610
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   611
    if(NOT APPLE)
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   612
      check_include_file(alloca.h HAVE_ALLOCA_H)
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   613
      check_function_exists(alloca HAVE_ALLOCA)
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   614
    else()
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   615
      set(HAVE_ALLOCA_H 1)
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   616
      set(HAVE_ALLOCA 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   617
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   618
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   619
    check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   620
  endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   621
else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   622
  if(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   623
    set(HAVE_STDARG_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   624
    set(HAVE_STDDEF_H 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   625
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   626
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   627
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   628
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   629
# Enable/disable various subsystems of the SDL library
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   630
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   631
  string(TOUPPER ${_SUB} _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   632
  if(NOT SDL_${_OPT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   633
    set(SDL_${_OPT}_DISABLED 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   634
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   635
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   636
if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   637
  file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   638
  set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   639
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   640
if(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   641
  if(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   642
    # Haptic requires some private functions from the joystick subsystem.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   643
    message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   644
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   645
  file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   646
  set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   647
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   648
if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   649
  file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   650
  set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   651
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   652
# TODO: in configure.in, the test for LOADSO and SDL_DLOPEN is a bit weird:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   653
# if LOADSO is not wanted, SDL_LOADSO_DISABLED is set
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   654
# If however on Unix or APPLE dlopen() is detected via CheckDLOPEN(),
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   655
# SDL_LOADSO_DISABLED will not be set, regardless of the LOADSO settings
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   656
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   657
# General SDL subsystem options, valid for all platforms
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   658
if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   659
  # CheckDummyAudio/CheckDiskAudio - valid for all platforms
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   660
  if(DUMMYAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   661
    set(SDL_AUDIO_DRIVER_DUMMY 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   662
    file(GLOB DUMMYAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   663
    set(SOURCE_FILES ${SOURCE_FILES} ${DUMMYAUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   664
    set(HAVE_DUMMYAUDIO TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   665
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   666
  if(DISKAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   667
    set(SDL_AUDIO_DRIVER_DISK 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   668
    file(GLOB DISKAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/disk/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   669
    set(SOURCE_FILES ${SOURCE_FILES} ${DISKAUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   670
    set(HAVE_DISKAUDIO TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   671
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   672
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   673
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   674
if(SDL_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   675
  # Relevant for Unix/Darwin only
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   676
  if(UNIX OR APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   677
    CheckDLOPEN()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   678
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   679
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   680
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   681
if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   682
  if(VIDEO_DUMMY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   683
    set(SDL_VIDEO_DRIVER_DUMMY 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   684
    file(GLOB VIDEO_DUMMY_SOURCES ${SDL2_SOURCE_DIR}/src/video/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   685
    set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_DUMMY_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   686
    set(HAVE_VIDEO_DUMMY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   687
    set(HAVE_SDL_VIDEO TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   688
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   689
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   690
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   691
# Platform-specific options and settings
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   692
if(EMSCRIPTEN)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   693
  # Hide noisy warnings that intend to aid mostly during initial stages of porting a new
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   694
  # project. Uncomment at will for verbose cross-compiling -I/../ path info.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   695
  add_definitions(-Wno-warn-absolute-paths)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   696
  if(SDL_AUDIO)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   697
    set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   698
    file(GLOB EM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/emscripten/*.c)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   699
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_AUDIO_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   700
    set(HAVE_SDL_AUDIO TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   701
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   702
  if(SDL_FILESYSTEM)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   703
    set(SDL_FILESYSTEM_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   704
    file(GLOB EM_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/emscripten/*.c)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   705
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_FILESYSTEM_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   706
    set(HAVE_SDL_FILESYSTEM TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   707
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   708
  if(SDL_JOYSTICK)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   709
    set(SDL_JOYSTICK_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   710
    file(GLOB EM_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/emscripten/*.c)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   711
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_JOYSTICK_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   712
    set(HAVE_SDL_JOYSTICK TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   713
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   714
  if(SDL_POWER)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   715
    set(SDL_POWER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   716
    file(GLOB EM_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/emscripten/*.c)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   717
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   718
    set(HAVE_SDL_POWER TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   719
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   720
  if(SDL_VIDEO)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   721
    set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   722
    file(GLOB EM_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/emscripten/*.c)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   723
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_VIDEO_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   724
    set(HAVE_SDL_VIDEO TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   725
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   726
    #enable gles
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   727
    if(VIDEO_OPENGLES)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   728
      set(SDL_VIDEO_OPENGL_EGL 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   729
      set(HAVE_VIDEO_OPENGLES TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   730
      set(SDL_VIDEO_OPENGL_ES2 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   731
      set(SDL_VIDEO_RENDER_OGL_ES2 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   732
    endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   733
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   734
elseif(UNIX AND NOT APPLE)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   735
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   736
    if(SYSV5 OR SOLARIS OR HPUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   737
        set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   738
        file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   739
        set(SOURCE_FILES ${SOURCE_FILES} ${SUN_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   740
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   741
    elseif(NETBSD OR OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   742
        set(SDL_AUDIO_DRIVER_BSD 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   743
        file(GLOB BSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/bsd/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   744
        set(SOURCE_FILES ${SOURCE_FILES} ${BSD_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   745
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   746
    elseif(AIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   747
        set(SDL_AUDIO_DRIVER_PAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   748
        file(GLOB AIX_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/paudio/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   749
        set(SOURCE_FILES ${SOURCE_FILES} ${AIX_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   750
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   751
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   752
    CheckOSS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   753
    CheckALSA()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   754
    CheckPulseAudio()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   755
    CheckESD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   756
    CheckARTS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   757
    CheckNAS()
7367
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 6774
diff changeset
   758
    CheckSNDIO()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   759
    CheckFusionSound()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   760
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   761
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   762
  if(SDL_VIDEO)
9077
28e6de55eb07 Fixed bug 2683 - Raspberry PI support using CMake
Sam Lantinga <slouken@libsdl.org>
parents: 9075
diff changeset
   763
    # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
28e6de55eb07 Fixed bug 2683 - Raspberry PI support using CMake
Sam Lantinga <slouken@libsdl.org>
parents: 9075
diff changeset
   764
    CheckRPI()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   765
    CheckX11()
8153
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8137
diff changeset
   766
    CheckMir()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   767
    CheckDirectFB()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   768
    CheckOpenGLX11()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   769
    CheckOpenGLESX11()
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8056
diff changeset
   770
    CheckWayland()
9164
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9127
diff changeset
   771
    CheckVivante()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   772
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   773
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   774
  if(LINUX)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   775
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   776
        #include <linux/input.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   777
        #ifndef EVIOCGNAME
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   778
        #error EVIOCGNAME() ioctl not available
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   779
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   780
        int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS)
7903
4d3e6191c807 Fixed bug 2187 - CMake is not adding src/core/linux/*.c to the build, linking to SDL results in errors.
Sam Lantinga <slouken@libsdl.org>
parents: 7867
diff changeset
   781
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   782
    check_c_source_compiles("
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   783
        #include <linux/kd.h>
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   784
        #include <linux/keyboard.h>
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   785
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   786
        int main(int argc, char **argv) 
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   787
        {
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   788
            struct kbentry kbe;
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   789
            kbe.kb_table = KG_CTRL;
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   790
            ioctl(0, KDGKBENT, &kbe);
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   791
        }" HAVE_INPUT_KD)
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   792
7903
4d3e6191c807 Fixed bug 2187 - CMake is not adding src/core/linux/*.c to the build, linking to SDL results in errors.
Sam Lantinga <slouken@libsdl.org>
parents: 7867
diff changeset
   793
    file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/linux/*.c)
4d3e6191c807 Fixed bug 2187 - CMake is not adding src/core/linux/*.c to the build, linking to SDL results in errors.
Sam Lantinga <slouken@libsdl.org>
parents: 7867
diff changeset
   794
    set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
4d3e6191c807 Fixed bug 2187 - CMake is not adding src/core/linux/*.c to the build, linking to SDL results in errors.
Sam Lantinga <slouken@libsdl.org>
parents: 7867
diff changeset
   795
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   796
    if(HAVE_INPUT_EVENTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   797
      set(SDL_INPUT_LINUXEV 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   798
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   799
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   800
    if(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   801
      set(SDL_HAPTIC_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   802
      file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   803
      set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   804
      set(HAVE_SDL_HAPTIC TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   805
    endif()
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   806
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   807
    if(HAVE_INPUT_KD)
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   808
      set(SDL_INPUT_LINUXKD 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   809
    endif()
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   810
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   811
    check_include_file("libudev.h" HAVE_LIBUDEV_H)
6774
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   812
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   813
    # !!! FIXME: this needs pkg-config to find the include path, I think.
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   814
    check_include_file("dbus/dbus.h" HAVE_DBUS_DBUS_H)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   815
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   816
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   817
  if(INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   818
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   819
        #include \"tslib.h\"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   820
        int main(int argc, char** argv) { }" HAVE_INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   821
    if(HAVE_INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   822
      set(SDL_INPUT_TSLIB 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   823
      list(APPEND EXTRA_LIBS ts)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   824
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   825
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   826
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   827
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   828
    CheckUSBHID()   # seems to be BSD specific - limit the test to BSD only?
9980
224187458d03 CMake: don't try to use the Linux joystick code on Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9979
diff changeset
   829
    if(LINUX AND NOT ANDROID)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   830
      set(SDL_JOYSTICK_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   831
      file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   832
      set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   833
      set(HAVE_SDL_JOYSTICK TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   834
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   835
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   836
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   837
  CheckPTHREAD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   838
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   839
  if(CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   840
    check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   841
    if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   842
      list(APPEND EXTRA_LIBS rt)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   843
      set(HAVE_CLOCK_GETTIME 1)
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   844
    else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   845
      check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   846
      if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   847
        set(HAVE_CLOCK_GETTIME 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   848
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   849
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   850
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   851
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   852
  check_include_file(linux/version.h HAVE_LINUX_VERSION_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   853
  if(HAVE_LINUX_VERSION_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   854
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_LINUX_VERSION_H")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   855
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   856
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   857
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   858
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   859
      set(SDL_POWER_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   860
      file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/linux/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   861
      set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   862
      set(HAVE_SDL_POWER TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   863
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   864
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   865
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   866
  if(SDL_FILESYSTEM)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   867
    set(SDL_FILESYSTEM_UNIX 1)
7867
d9d50f52a686 Fixed bug 2061 - SDL_filesystem API not built using cmake
Sam Lantinga <slouken@libsdl.org>
parents: 7803
diff changeset
   868
    file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c)
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   869
    set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   870
    set(HAVE_SDL_FILESYSTEM TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   871
  endif()
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   872
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   873
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   874
    set(SDL_TIMER_UNIX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   875
    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   876
    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   877
    set(HAVE_SDL_TIMERS TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   878
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   879
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   880
  if(RPATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   881
    set(SDL_RLD_FLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   882
    if(BSDI OR FREEBSD OR LINUX OR NETBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   883
      set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   884
    elseif(SOLARIS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   885
      set(SDL_RLD_FLAGS "-R\${libdir}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   886
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   887
    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   888
    set(HAVE_RPATH TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   889
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   890
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   891
elseif(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   892
  find_program(WINDRES windres)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   893
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   894
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   895
    #include <windows.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   896
    int main(int argc, char **argv) { }" HAVE_WIN32_CC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   897
7903
4d3e6191c807 Fixed bug 2187 - CMake is not adding src/core/linux/*.c to the build, linking to SDL results in errors.
Sam Lantinga <slouken@libsdl.org>
parents: 7867
diff changeset
   898
  file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
4d3e6191c807 Fixed bug 2187 - CMake is not adding src/core/linux/*.c to the build, linking to SDL results in errors.
Sam Lantinga <slouken@libsdl.org>
parents: 7867
diff changeset
   899
  set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   900
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   901
  # Check for DirectX
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   902
  if(DIRECTX)
9979
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
   903
    if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
   904
        set(USE_WINSDK_DIRECTX TRUE)
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
   905
    endif()
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
   906
    if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
9758
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
   907
      if("$ENV{DXSDK_DIR}" STREQUAL "")
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
   908
        message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
   909
      endif()
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
   910
      set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   911
    endif()
9853
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   912
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   913
    if(HAVE_WIN32_CC)
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   914
      # xinput.h may need windows.h, but doesn't include it itself.
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   915
      check_c_source_compiles("
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   916
        #include <windows.h>
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   917
        #include <xinput.h>
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   918
        int main(int argc, char **argv) { }" HAVE_XINPUT_H)
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   919
    else()
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   920
      check_include_file(xinput.h HAVE_XINPUT_H)
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   921
    endif()
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
   922
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   923
    check_include_file(d3d9.h HAVE_D3D_H)
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
   924
    check_include_file(d3d11_1.h HAVE_D3D11_H)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   925
    check_include_file(ddraw.h HAVE_DDRAW_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   926
    check_include_file(dsound.h HAVE_DSOUND_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   927
    check_include_file(dinput.h HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   928
    check_include_file(xaudio2.h HAVE_XAUDIO2_H)
8751
e8c61640668d Fix build on Windows targets without dxgi.h, like MingW32.
Ryan C. Gordon <icculus@icculus.org>
parents: 8680
diff changeset
   929
    check_include_file(dxgi.h HAVE_DXGI_H)
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
   930
    if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   931
      set(HAVE_DIRECTX TRUE)
9979
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
   932
      if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   933
      # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
9758
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
   934
        link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
   935
        include_directories($ENV{DXSDK_DIR}\\Include)
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
   936
      endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   937
    endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   938
    set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   939
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   940
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   941
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   942
    set(SDL_AUDIO_DRIVER_WINMM 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   943
    file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   944
    set(SOURCE_FILES ${SOURCE_FILES} ${WINMM_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   945
    set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   946
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   947
    if(HAVE_DSOUND_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   948
      set(SDL_AUDIO_DRIVER_DSOUND 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   949
      file(GLOB DSOUND_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/directsound/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   950
      set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   951
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   952
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   953
    if(HAVE_XAUDIO2_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   954
      set(SDL_AUDIO_DRIVER_XAUDIO2 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   955
      file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   956
      set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   957
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   958
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   959
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   960
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   961
    # requires SDL_LOADSO on Windows (IME, DX, etc.)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   962
    if(NOT SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   963
      message_error("SDL_VIDEO requires SDL_LOADSO, which is not enabled")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   964
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   965
    set(SDL_VIDEO_DRIVER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   966
    file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   967
    set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   968
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   969
    if(RENDER_D3D AND HAVE_D3D_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   970
      set(SDL_VIDEO_RENDER_D3D 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   971
      set(HAVE_RENDER_D3D TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   972
    endif()
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
   973
    if(RENDER_D3D AND HAVE_D3D11_H)
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
   974
      set(SDL_VIDEO_RENDER_D3D11 1)
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
   975
      set(HAVE_RENDER_D3D TRUE)
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
   976
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   977
    set(HAVE_SDL_VIDEO TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   978
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   979
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   980
  if(SDL_THREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   981
    set(SDL_THREAD_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   982
    set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   983
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   984
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_syssem.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   985
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systhread.c
7395
c1b80390a820 Added src/thread/windows/SDL_systls.c to CMakeLists.txt (thanks, Charles!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7367
diff changeset
   986
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systls.c
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   987
      ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   988
    set(HAVE_SDL_THREADS TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   989
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   990
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   991
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   992
    set(SDL_POWER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   993
    set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   994
    set(HAVE_SDL_POWER TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   995
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   996
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   997
  if(SDL_FILESYSTEM)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   998
    set(SDL_FILESYSTEM_WINDOWS 1)
8031
edf58197a910 Fixes #2272, typo in CMakeLists.txt (thanks Boris Bendovsky!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7999
diff changeset
   999
    file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/windows/*.c)
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1000
    set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1001
    set(HAVE_SDL_FILESYSTEM TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1002
  endif()
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1003
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1004
  # Libraries for Win32 native and MinGW
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1005
  list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1006
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1007
  # TODO: in configure.in the check for timers is set on
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1008
  # cygwin | mingw32* - does this include mingw32CE?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1009
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1010
    set(SDL_TIMER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1011
    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1012
    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1013
    set(HAVE_SDL_TIMERS TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1014
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1015
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1016
  if(SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1017
    set(SDL_LOADSO_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1018
    file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1019
    set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1020
    set(HAVE_SDL_LOADSO TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1021
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1022
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1023
  file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1024
  set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1025
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1026
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1027
    if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1028
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1029
      set(SDL_VIDEO_OPENGL_WGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1030
      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
  1031
      set(HAVE_VIDEO_OPENGL TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1032
    endif()
9854
dbcbdc2940ef Fix bug 3081: CMake configuration auto-disables OpenGL ES support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9853
diff changeset
  1033
dbcbdc2940ef Fix bug 3081: CMake configuration auto-disables OpenGL ES support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9853
diff changeset
  1034
    if(VIDEO_OPENGLES)
dbcbdc2940ef Fix bug 3081: CMake configuration auto-disables OpenGL ES support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9853
diff changeset
  1035
      set(SDL_VIDEO_OPENGL_EGL 1)
dbcbdc2940ef Fix bug 3081: CMake configuration auto-disables OpenGL ES support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9853
diff changeset
  1036
      set(SDL_VIDEO_OPENGL_ES2 1)
dbcbdc2940ef Fix bug 3081: CMake configuration auto-disables OpenGL ES support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9853
diff changeset
  1037
      set(SDL_VIDEO_RENDER_OGL_ES2 1)
dbcbdc2940ef Fix bug 3081: CMake configuration auto-disables OpenGL ES support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9853
diff changeset
  1038
      set(HAVE_VIDEO_OPENGLES TRUE)
dbcbdc2940ef Fix bug 3081: CMake configuration auto-disables OpenGL ES support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9853
diff changeset
  1039
    endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1040
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1041
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1042
  if(SDL_JOYSTICK)
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1043
    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1044
    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1045
    if(HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1046
      set(SDL_JOYSTICK_DINPUT 1)
9758
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1047
      list(APPEND EXTRA_LIBS dinput8 dxguid)
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1048
      if(CMAKE_COMPILER_IS_MINGW)
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1049
        list(APPEND EXTRA_LIBS dxerr8)
9979
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
  1050
      elseif (NOT USE_WINSDK_DIRECTX)
9758
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1051
        list(APPEND EXTRA_LIBS dxerr)
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1052
      endif()
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1053
    endif()
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1054
    if(HAVE_XINPUT_H)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1055
      set(SDL_JOYSTICK_XINPUT 1)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1056
    endif()
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1057
    if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1058
      set(SDL_JOYSTICK_WINMM 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1059
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1060
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1061
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1062
    if(SDL_HAPTIC)
9731
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1063
      if(HAVE_DINPUT_H OR HAVE_XINPUT_H)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1064
        file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/windows/*.c)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1065
        if(HAVE_DINPUT_H)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1066
          set(SDL_HAPTIC_DINPUT 1)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1067
        endif()
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1068
        if(HAVE_XINPUT_H)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1069
          set(SDL_HAPTIC_XINPUT 1)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1070
        endif()
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1071
      else()
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1072
        file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1073
        set(SDL_HAPTIC_DUMMY 1)
a8140c580b85 Fixed bug 3009 - Cannot compile SDL2 on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 9717
diff changeset
  1074
      endif()
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1075
      set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1076
      set(HAVE_SDL_HAPTIC TRUE)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1077
    endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1078
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1079
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1080
  file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1081
  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1082
  if(MINGW OR CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1083
    list(APPEND EXTRA_LIBS mingw32)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1084
    list(APPEND EXTRA_LDFLAGS "-mwindows")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1085
    set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1086
    list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1087
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1088
elseif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1089
  # TODO: rework this for proper MacOS X, iOS and Darwin support
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1090
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1091
  # Requires the darwin file implementation
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1092
  if(SDL_FILE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1093
    file(GLOB EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/file/cocoa/*.m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1094
    set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1095
    set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1096
    set(HAVE_SDL_FILE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1097
    set(SDL_FRAMEWORK_COCOA 1)
9112
345a7d41dda9 Fixed bug 2696 - Mac: fix display mode refresh rate calculation
Sam Lantinga <slouken@libsdl.org>
parents: 9093
diff changeset
  1098
    set(SDL_FRAMEWORK_COREVIDEO 1)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1099
  else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1100
    message_error("SDL_FILE must be enabled to build on MacOS X")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1101
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1102
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1103
  if(SDL_AUDIO)
9312
705bdbbb1f37 Fixed bug 2807 - Not using CoreAudio on OS X when built via CMake
Felix H. Dahlke <fhd@ubercode.de>
parents: 9279
diff changeset
  1104
    set(SDL_AUDIO_DRIVER_COREAUDIO 1)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1105
    file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1106
    set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1107
    set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1108
    set(SDL_FRAMEWORK_COREAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1109
    set(SDL_FRAMEWORK_AUDIOUNIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1110
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1111
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1112
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1113
    set(SDL_JOYSTICK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1114
    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1115
    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1116
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1117
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1118
    set(SDL_FRAMEWORK_FF 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1119
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1120
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1121
  if(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1122
    set(SDL_HAPTIC_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1123
    file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1124
    set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1125
    set(HAVE_SDL_HAPTIC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1126
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1127
    set(SDL_FRAMEWORK_FF 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1128
    if(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1129
      message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1130
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1131
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1132
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1133
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1134
    set(SDL_POWER