CMakeLists.txt
author Ryan C. Gordon <icculus@icculus.org>
Sun, 28 Aug 2016 13:36:13 -0400
changeset 10286 3b884985835c
parent 10121 6b6ded44e6e0
permissions -rw-r--r--
Merge audio capture work back into the mainline.
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)
10012
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
     7
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
     8
# !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
     9
# !!! FIXME:  for the SDL2 shared library (so you get an
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
    10
# !!! FIXME:  install_name ("soname") of "@rpath/libSDL-whatever.dylib"
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
    11
# !!! FIXME:  instead of "/usr/local/lib/libSDL-whatever.dylib"), but I'm
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
    12
# !!! FIXME:  punting for now and leaving the existing behavior. Until this
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
    13
# !!! FIXME:  properly resolved, this line silences a warning in CMake 3.0+.
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
    14
# !!! FIXME:  remove it and this comment entirely once the problem is
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
    15
# !!! FIXME:  properly resolved.
10034
8764bcc13666 CMake: Turned off Mac OS X rpath warning kludge.
Ryan C. Gordon <icculus@icculus.org>
parents: 10013
diff changeset
    16
#cmake_policy(SET CMP0042 OLD)
10012
ed02c7a84612 CMake: use the old MACOSX_RPATH behavior (for now), silence the warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 10009
diff changeset
    17
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
include(CheckFunctionExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
include(CheckLibraryExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
include(CheckIncludeFiles)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    21
include(CheckIncludeFile)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    22
include(CheckSymbolExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    23
include(CheckCSourceRuns)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    24
include(CheckCCompilerFlag)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
include(CheckTypeSize)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
include(CheckStructHasMember)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
include(CMakeDependentOption)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
include(FindPkgConfig)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
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
    30
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
    31
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
    32
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    33
# General settings
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    34
# 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
    35
#   SDL_MICRO_VERSION += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
#   SDL_INTERFACE_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
#   SDL_BINARY_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
# 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
    39
# 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
    40
# 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
    41
set(SDL_MAJOR_VERSION 2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    42
set(SDL_MINOR_VERSION 0)
9121
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    43
set(SDL_MICRO_VERSION 4)
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    44
set(SDL_INTERFACE_AGE 0)
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    45
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
    46
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
    47
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
# 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
    49
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
    50
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
    51
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
    52
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
    53
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
    54
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
    55
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    56
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
    57
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
# General settings & flags
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
set(LIBRARY_OUTPUT_DIRECTORY "build")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
# 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
    61
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
    62
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
    63
  set(ARCH_64 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
  set(PROCESSOR_ARCH "x64")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
  set(ARCH_64 FALSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    67
  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
    68
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
set(LIBNAME SDL2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
if(NOT LIBTYPE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
  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
    72
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
# Get the platform
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
if(WIN32)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
  if(NOT WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
    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
    78
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
elseif(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
  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
    81
    set(LINUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
  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
    83
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
  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
    85
    set(NETBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
  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
    87
    set(OPENBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
  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
    89
    set(GNU TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
  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
    91
    set(BSDI TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
  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
    93
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
  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
    95
    set(SYSV5 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
  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
    97
    set(SOLARIS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
  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
    99
    set(HPUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
  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
   101
    set(AIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   102
  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
   103
    set(MINIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   104
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
elseif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
  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
   107
    set(DARWIN TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
  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
   109
    set(MACOSX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   110
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   111
  # 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
   112
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
   113
  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
   114
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
   115
  set(HAIKU TRUE)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   116
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   117
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   118
# 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
   119
if(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   120
  set(UNIX_SYS ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   121
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   122
  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
   123
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   124
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   125
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
   126
  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
   127
else()
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   128
  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
   129
endif()
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   130
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   131
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
   132
  set(SDL_PTHREADS_ENABLED_BY_DEFAULT ON)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   133
else()
9431
a9c73f29a15e Better fixes for CMake subsystem enabling (thanks, Sebastian!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9414
diff changeset
   134
  set(SDL_PTHREADS_ENABLED_BY_DEFAULT OFF)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   135
endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   136
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
# Default option knobs
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
if(APPLE OR ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
  set(OPT_DEF_SSEMATH ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
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
   142
  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
   143
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
# Compiler info
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   146
if(CMAKE_COMPILER_IS_GNUCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
  set(USE_GCC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
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
   150
  set(USE_CLANG TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   152
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
   153
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
  #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
   155
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   156
  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
   157
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   158
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   159
# 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
   160
if("$ENV{CFLAGS}" STREQUAL "")
10047
281d1bfdacb1 CMake: only set "-O3 -g" defaults if CMAKE_BUILD_TYPE wasn't set at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 10044
diff changeset
   161
  if(CMAKE_BUILD_TYPE STREQUAL "")
281d1bfdacb1 CMake: only set "-O3 -g" defaults if CMAKE_BUILD_TYPE wasn't set at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 10044
diff changeset
   162
    if(USE_GCC OR USE_CLANG)
281d1bfdacb1 CMake: only set "-O3 -g" defaults if CMAKE_BUILD_TYPE wasn't set at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 10044
diff changeset
   163
      set(CMAKE_C_FLAGS "-g -O3")
281d1bfdacb1 CMake: only set "-O3 -g" defaults if CMAKE_BUILD_TYPE wasn't set at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 10044
diff changeset
   164
    endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   165
  endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   166
else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   167
  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
   168
  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
   169
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   170
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
   171
  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
   172
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   173
8136
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   174
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
   175
  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
   176
  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
   177
    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
   178
        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
   179
        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
   180
      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
   181
        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
   182
      endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   183
    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
   184
  endif()
9994
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   185
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   186
  # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   187
  foreach(flag_var
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   188
      CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   189
      CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   190
    string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   191
  endforeach(flag_var)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   192
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
   193
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   194
# 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
   195
# etc. are created correctly.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   196
set(SDL_LIBS "-lSDL2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   197
set(SDL_CFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   198
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   199
# 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
   200
# 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
   201
# 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
   202
# 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
   203
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   204
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   205
if(CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   206
  # 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
   207
  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
   208
  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
   209
  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
   210
    HAVE_GCC_NO_CYGWIN)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   211
  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
   212
  if(HAVE_GCC_NO_CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   213
    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
   214
    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
   215
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   216
  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
   217
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   218
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   219
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
   220
# General includes
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   221
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
   222
9279
e1d1b6479a14 CMake: Minor cleanup up on the new SDL_*_ENABLED_BY_DEFAULT vars.
Ryan C. Gordon <icculus@icculus.org>
parents: 9278
diff changeset
   223
# 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
   224
#  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
   225
set(OPT_DEF_ASM TRUE)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   226
if(EMSCRIPTEN)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   227
  # 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
   228
  # 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
   229
  # loading architecture, low-level CPU inspection or multithreading.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   230
  set(OPT_DEF_ASM FALSE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   231
  set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   232
  set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   233
  set(SDL_THREADS_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   234
  set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   235
  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
   236
  set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   237
endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   238
9717
45a632fd9d83 CMake: default to shared library builds being enabled.
Ryan C. Gordon <icculus@icculus.org>
parents: 9571
diff changeset
   239
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
   240
    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
   241
endif()
45a632fd9d83 CMake: default to shared library builds being enabled.
Ryan C. Gordon <icculus@icculus.org>
parents: 9571
diff changeset
   242
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   243
set(SDL_SUBSYSTEMS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   244
    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
   245
    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
   246
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   247
  string(TOUPPER ${_SUB} _OPT)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   248
  if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   249
    set(SDL_${_OPT}_ENABLED_BY_DEFAULT ON)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   250
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   251
  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
   252
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   253
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   254
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
   255
#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
   256
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
   257
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
   258
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
   259
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
   260
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
   261
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
   262
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
   263
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
   264
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
   265
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
   266
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
   267
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
   268
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
   269
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
   270
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
   271
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
   272
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
   273
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
   274
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
   275
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
   276
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
   277
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
   278
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
   279
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
   280
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
   281
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
   282
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
   283
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
   284
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
   285
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
   286
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
   287
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
   288
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
   289
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
   290
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
   291
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
   292
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
   293
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
   294
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
   295
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
   296
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
   297
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
   298
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
   299
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
   300
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
   301
foreach(_SUB ${SDL_X11_OPTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   302
  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
   303
  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
   304
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   305
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
   306
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
   307
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
   308
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
   309
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   310
# 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
   311
# 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
   312
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
   313
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
   314
10013
9f758c4d746a CMake: Let static libraries optionally be built with Position Independent Code.
Ryan C. Gordon <icculus@icculus.org>
parents: 10012
diff changeset
   315
dep_option(SDL_STATIC_PIC      "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
9f758c4d746a CMake: Let static libraries optionally be built with Position Independent Code.
Ryan C. Gordon <icculus@icculus.org>
parents: 10012
diff changeset
   316
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   317
# General source files
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   318
file(GLOB SOURCE_FILES
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   319
  ${SDL2_SOURCE_DIR}/src/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   320
  ${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
   321
  ${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
   322
  ${SDL2_SOURCE_DIR}/src/cpuinfo/*.c
8094
9efaae827924 Implemented the Dynamic API magic.
Ryan C. Gordon <icculus@icculus.org>
parents: 8090
diff changeset
   323
  ${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
   324
  ${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
   325
  ${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
   326
  ${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
   327
  ${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
   328
  ${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
   329
  ${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
   330
  ${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
   331
  ${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
   332
  ${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
   333
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   334
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   335
if(ASSERTIONS STREQUAL "auto")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   336
  # 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
   337
elseif(ASSERTIONS STREQUAL "disabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   338
  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
   339
elseif(ASSERTIONS STREQUAL "release")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   340
  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
   341
elseif(ASSERTIONS STREQUAL "enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   342
  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
   343
elseif(ASSERTIONS STREQUAL "paranoid")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   344
  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
   345
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   346
  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
   347
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   348
set(HAVE_ASSERTIONS ${ASSERTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   349
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   350
# Compiler option evaluation
7999
2c9aedfba740 Fixed bug 2238 - Enable GCC atomics for clang
Sam Lantinga <slouken@libsdl.org>
parents: 7981
diff changeset
   351
if(USE_GCC OR USE_CLANG)
10009
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   352
  # Check for -Wall first, so later things can override pieces of it.
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   353
  check_c_compiler_flag(-Wall HAVE_GCC_WALL)
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   354
  if(HAVE_GCC_WALL)
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   355
    list(APPEND EXTRA_CFLAGS "-Wall")
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   356
    if(HAIKU)
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   357
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   358
    endif()
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   359
  endif()
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   360
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   361
  check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   362
  if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   363
    check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   364
    if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   365
      list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement")
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   366
    endif()
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   367
    list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement")
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   368
  endif()
8c6b05b0a27e Try to build with GCC's -Wdeclaration-after-statement.
Ryan C. Gordon <icculus@icculus.org>
parents: 10004
diff changeset
   369
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   370
  if(DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   371
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   372
        #if !defined(__GNUC__) || __GNUC__ < 3
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   373
        #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
   374
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   375
        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
   376
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   377
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   378
  if(GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   379
    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
   380
        int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   381
        void *x, *y, *z;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   382
        __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
   383
        __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
   384
        __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
   385
        __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
   386
        __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
   387
    if(NOT HAVE_GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   388
      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
   389
          int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   390
          __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
   391
          __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
   392
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   393
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   394
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   395
  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
   396
  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
   397
    HAVE_GCC_PREFERRED_STACK_BOUNDARY)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   398
  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
   399
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   400
  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
   401
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   402
      #if !defined(__GNUC__) || __GNUC__ < 4
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   403
      #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
   404
      #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   405
      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
   406
  if(HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   407
    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
   408
  endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   409
  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
   410
9081
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   411
  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
   412
  if(HAVE_GCC_WSHADOW)
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   413
    list(APPEND EXTRA_CFLAGS "-Wshadow")
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   414
  endif()
9082
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   415
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   416
  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
   417
  check_c_compiler_flag("" HAVE_NO_UNDEFINED)
9981
a443c97eb294 CMake: fixed a failure to reset CMAKE_REQUIRED_FLAGS (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9980
diff changeset
   418
  set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
9082
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   419
  if(HAVE_NO_UNDEFINED)
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   420
    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
   421
  endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   422
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   423
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   424
if(ASSEMBLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   425
  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
   426
    set(SDL_ASSEMBLY_ROUTINES 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   427
    # 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
   428
    # reworked for better compiler support
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   429
    set(HAVE_ASSEMBLY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   430
    if(MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   431
      set(CMAKE_REQUIRED_FLAGS "-mmmx")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   432
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   433
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   434
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   435
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   436
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   437
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   438
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   439
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   440
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   441
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   442
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   443
          #ifndef __MMX__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   444
          #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
   445
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   446
          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
   447
      if(HAVE_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   448
        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
   449
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   450
      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
   451
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   452
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   453
    if(3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   454
      set(CMAKE_REQUIRED_FLAGS "-m3dnow")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   455
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   456
          #include <mm3dnow.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   457
          #ifndef __3dNOW__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   458
          #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
   459
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   460
          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
   461
            void *p = 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   462
            _m_prefetch(p);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   463
          }" HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   464
      if(HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   465
        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
   466
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   467
      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
   468
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   469
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   470
    if(SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   471
      set(CMAKE_REQUIRED_FLAGS "-msse")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   472
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   473
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   474
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   475
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   476
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   477
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   478
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   479
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   480
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   481
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   482
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   483
          #ifndef __SSE__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   484
          #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
   485
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   486
          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
   487
      if(HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   488
        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
   489
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   490
      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
   491
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   492
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   493
    if(SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   494
      set(CMAKE_REQUIRED_FLAGS "-msse2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   495
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   496
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   497
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   498
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   499
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   500
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   501
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   502
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   503
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   504
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   505
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   506
          #ifndef __SSE2__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   507
          #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
   508
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   509
          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
   510
      if(HAVE_SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   511
        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
   512
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   513
      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
   514
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   515
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   516
    if(SSEMATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   517
      if(SSE OR SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   518
        if(USE_GCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   519
          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
   520
        endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   521
        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
   522
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   523
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   524
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   525
    if(ALTIVEC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   526
      set(CMAKE_REQUIRED_FLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   527
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   528
          #include <altivec.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   529
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   530
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   531
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   532
          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
   533
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   534
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   535
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   536
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   537
          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
   538
      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
   539
      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
   540
        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
   541
        list(APPEND EXTRA_CFLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   542
        set(SDL_ALTIVEC_BLITTERS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   543
        if(HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   544
          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
   545
        endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   546
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   547
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   548
  elseif(MSVC_VERSION GREATER 1500)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   549
    # 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
   550
    # 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
   551
    if(NOT ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   552
      set(HAVE_MMX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   553
      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
   554
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   555
    set(HAVE_SSE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   556
    set(HAVE_SSE2 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   557
    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
   558
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   559
# TODO:
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   560
#else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   561
#  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
   562
#    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
   563
#  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   564
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   565
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   566
# 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
   567
# anything.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   568
if(LIBC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   569
  if(WINDOWS AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   570
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   571
    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
   572
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   573
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   574
      set(${_HAVE_H} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   575
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   576
    set(HAVE_SIGNAL_H 1)
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
            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
   579
            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
   580
            _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
   581
            _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
   582
            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
   583
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   584
      set(HAVE_${_UPPER} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   585
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   586
    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
   587
      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
   588
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   589
    set(HAVE_M_PI 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   590
    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
   591
    set(STDC_HEADERS 1)
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   592
  else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   593
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   594
    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
   595
    foreach(_HEADER
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   596
            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
   597
            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
   598
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   599
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   600
      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
   601
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   602
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   603
    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
   604
    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
   605
    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
   606
    # TODO: refine the mprotect check
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   607
    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
   608
                             #include <sys/mman.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   609
                             int main() { }" HAVE_MPROTECT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   610
    foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   611
            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
   612
            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
   613
            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
   614
            _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
   615
            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
   616
            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
   617
            nanosleep sysconf sysctlbyname
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
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   620
      set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   621
      check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   622
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   623
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   624
    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
   625
    if(HAVE_LIBM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   626
      set(CMAKE_REQUIRED_LIBRARIES m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   627
      foreach(_FN
9080
2e4e71ec140f Removed SDL_round() because the license wasn't compatible with zlib
Sam Lantinga <slouken@libsdl.org>
parents: 9077
diff changeset
   628
              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
   629
              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
   630
        string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   631
        set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   632
        check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   633
      endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   634
      set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   635
      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
   636
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   637
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   638
    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
   639
    if(HAVE_LIBICONV)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   640
      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
   641
      set(HAVE_ICONV 1)
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   642
    endif()
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   643
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   644
    if(NOT APPLE)
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   645
      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
   646
      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
   647
    else()
669bf9fb901e Several corrections to the CMake project files (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9411
diff changeset
   648
      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
   649
      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
   650
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   651
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   652
    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
   653
  endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   654
else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   655
  if(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   656
    set(HAVE_STDARG_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   657
    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
   658
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   659
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   660
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   661
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   662
# 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
   663
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   664
  string(TOUPPER ${_SUB} _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   665
  if(NOT SDL_${_OPT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   666
    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
   667
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   668
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   669
if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   670
  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
   671
  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
   672
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   673
if(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   674
  if(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   675
    # 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
   676
    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
   677
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   678
  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
   679
  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
   680
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   681
if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   682
  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
   683
  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
   684
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   685
# 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
   686
# 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
   687
# 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
   688
# 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
   689
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   690
# 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
   691
if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   692
  # 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
   693
  if(DUMMYAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   694
    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
   695
    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
   696
    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
   697
    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
   698
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   699
  if(DISKAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   700
    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
   701
    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
   702
    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
   703
    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
   704
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   705
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   706
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   707
if(SDL_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   708
  # Relevant for Unix/Darwin only
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   709
  if(UNIX OR APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   710
    CheckDLOPEN()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   711
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   712
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   713
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   714
if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   715
  if(VIDEO_DUMMY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   716
    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
   717
    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
   718
    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
   719
    set(HAVE_VIDEO_DUMMY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   720
    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
   721
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   722
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   723
9982
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   724
if(ANDROID)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   725
  file(GLOB ANDROID_CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/android/*.c)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   726
  set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_CORE_SOURCES})
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   727
  file(GLOB ANDROID_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/android/*.c)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   728
  set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_MAIN_SOURCES})
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   729
  if(SDL_AUDIO)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   730
    set(SDL_AUDIO_DRIVER_ANDROID 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   731
    file(GLOB ANDROID_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/android/*.c)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   732
    set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_AUDIO_SOURCES})
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   733
    set(HAVE_SDL_AUDIO TRUE)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   734
  endif()
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   735
  if(SDL_FILESYSTEM)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   736
    set(SDL_FILESYSTEM_ANDROID 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   737
    file(GLOB ANDROID_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/android/*.c)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   738
    set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_FILESYSTEM_SOURCES})
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   739
    set(HAVE_SDL_FILESYSTEM TRUE)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   740
  endif()
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   741
  if(SDL_JOYSTICK)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   742
    set(SDL_JOYSTICK_ANDROID 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   743
    file(GLOB ANDROID_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/android/*.c)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   744
    set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_JOYSTICK_SOURCES})
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   745
    set(HAVE_SDL_JOYSTICK TRUE)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   746
  endif()
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   747
  if(SDL_POWER)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   748
    set(SDL_POWER_ANDROID 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   749
    file(GLOB ANDROID_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/android/*.c)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   750
    set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_POWER_SOURCES})
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   751
    set(HAVE_SDL_POWER TRUE)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   752
  endif()
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   753
  if(SDL_VIDEO)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   754
    set(SDL_VIDEO_DRIVER_ANDROID 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   755
    file(GLOB ANDROID_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/android/*.c)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   756
    set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_VIDEO_SOURCES})
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   757
    set(HAVE_SDL_VIDEO TRUE)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   758
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   759
    #enable gles
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   760
    if(VIDEO_OPENGLES)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   761
      set(SDL_VIDEO_OPENGL_EGL 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   762
      set(HAVE_VIDEO_OPENGLES TRUE)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   763
      set(SDL_VIDEO_OPENGL_ES2 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   764
      set(SDL_VIDEO_RENDER_OGL_ES2 1)
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   765
    endif()
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   766
  endif()
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   767
  list(APPEND EXTRA_LDFLAGS "-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit")
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   768
endif()
9145e51b15bb CMake: Changes to get CMake project to work with Android (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9981
diff changeset
   769
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   770
# Platform-specific options and settings
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   771
if(EMSCRIPTEN)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   772
  # 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
   773
  # 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
   774
  add_definitions(-Wno-warn-absolute-paths)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   775
  if(SDL_AUDIO)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   776
    set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   777
    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
   778
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_AUDIO_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   779
    set(HAVE_SDL_AUDIO TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   780
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   781
  if(SDL_FILESYSTEM)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   782
    set(SDL_FILESYSTEM_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   783
    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
   784
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_FILESYSTEM_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   785
    set(HAVE_SDL_FILESYSTEM TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   786
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   787
  if(SDL_JOYSTICK)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   788
    set(SDL_JOYSTICK_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   789
    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
   790
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_JOYSTICK_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   791
    set(HAVE_SDL_JOYSTICK TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   792
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   793
  if(SDL_POWER)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   794
    set(SDL_POWER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   795
    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
   796
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   797
    set(HAVE_SDL_POWER TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   798
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   799
  if(SDL_VIDEO)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   800
    set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   801
    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
   802
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_VIDEO_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   803
    set(HAVE_SDL_VIDEO TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   804
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   805
    #enable gles
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   806
    if(VIDEO_OPENGLES)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   807
      set(SDL_VIDEO_OPENGL_EGL 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   808
      set(HAVE_VIDEO_OPENGLES TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   809
      set(SDL_VIDEO_OPENGL_ES2 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   810
      set(SDL_VIDEO_RENDER_OGL_ES2 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   811
    endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   812
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   813
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
   814
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   815
    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
   816
        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
   817
        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
   818
        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
   819
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   820
    elseif(NETBSD OR OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   821
        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
   822
        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
   823
        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
   824
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   825
    elseif(AIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   826
        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
   827
        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
   828
        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
   829
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   830
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   831
    CheckOSS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   832
    CheckALSA()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   833
    CheckPulseAudio()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   834
    CheckESD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   835
    CheckARTS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   836
    CheckNAS()
7367
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 6774
diff changeset
   837
    CheckSNDIO()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   838
    CheckFusionSound()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   839
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   840
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   841
  if(SDL_VIDEO)
9077
28e6de55eb07 Fixed bug 2683 - Raspberry PI support using CMake
Sam Lantinga <slouken@libsdl.org>
parents: 9075
diff changeset
   842
    # 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
   843
    CheckRPI()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   844
    CheckX11()
8153
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8137
diff changeset
   845
    CheckMir()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   846
    CheckDirectFB()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   847
    CheckOpenGLX11()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   848
    CheckOpenGLESX11()
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8056
diff changeset
   849
    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
   850
    CheckVivante()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   851
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   852
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   853
  if(LINUX)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   854
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   855
        #include <linux/input.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   856
        #ifndef EVIOCGNAME
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   857
        #error EVIOCGNAME() ioctl not available
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   858
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   859
        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
   860
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   861
    check_c_source_compiles("
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   862
        #include <linux/kd.h>
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   863
        #include <linux/keyboard.h>
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   864
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   865
        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
   866
        {
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   867
            struct kbentry kbe;
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   868
            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
   869
            ioctl(0, KDGKBENT, &kbe);
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   870
        }" HAVE_INPUT_KD)
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   871
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
   872
    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
   873
    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
   874
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   875
    if(HAVE_INPUT_EVENTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   876
      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
   877
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   878
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   879
    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
   880
      set(SDL_HAPTIC_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   881
      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
   882
      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
   883
      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
   884
    endif()
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   885
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   886
    if(HAVE_INPUT_KD)
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   887
      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
   888
    endif()
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   889
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   890
    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
   891
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   892
    # !!! 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
   893
    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
   894
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   895
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   896
  if(INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   897
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   898
        #include \"tslib.h\"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   899
        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
   900
    if(HAVE_INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   901
      set(SDL_INPUT_TSLIB 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   902
      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
   903
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   904
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   905
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   906
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   907
    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
   908
    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
   909
      set(SDL_JOYSTICK_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   910
      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
   911
      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
   912
      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
   913
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   914
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   915
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   916
  CheckPTHREAD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   917
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   918
  if(CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   919
    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
   920
    if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   921
      list(APPEND EXTRA_LIBS rt)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   922
      set(HAVE_CLOCK_GETTIME 1)
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   923
    else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   924
      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
   925
      if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   926
        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
   927
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   928
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   929
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   930
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   931
  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
   932
  if(HAVE_LINUX_VERSION_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   933
    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
   934
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   935
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   936
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   937
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   938
      set(SDL_POWER_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   939
      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
   940
      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
   941
      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
   942
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   943
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   944
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   945
  if(SDL_FILESYSTEM)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   946
    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
   947
    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
   948
    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
   949
    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
   950
  endif()
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   951
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   952
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   953
    set(SDL_TIMER_UNIX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   954
    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
   955
    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
   956
    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
   957
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   958
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   959
  if(RPATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   960
    set(SDL_RLD_FLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   961
    if(BSDI OR FREEBSD OR LINUX OR NETBSD)
10043
24e8d042e532 Use --enable-new-dtags to set RUNPATH rather than RPATH so that LD_LIBRARY_PATH is not overridden by the application.
Sam Lantinga <slouken@libsdl.org>
parents: 10034
diff changeset
   962
      set(CMAKE_REQUIRED_FLAGS "-Wl,--enable-new-dtags")
24e8d042e532 Use --enable-new-dtags to set RUNPATH rather than RPATH so that LD_LIBRARY_PATH is not overridden by the application.
Sam Lantinga <slouken@libsdl.org>
parents: 10034
diff changeset
   963
      check_c_compiler_flag("" HAVE_ENABLE_NEW_DTAGS)
24e8d042e532 Use --enable-new-dtags to set RUNPATH rather than RPATH so that LD_LIBRARY_PATH is not overridden by the application.
Sam Lantinga <slouken@libsdl.org>
parents: 10034
diff changeset
   964
      set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
24e8d042e532 Use --enable-new-dtags to set RUNPATH rather than RPATH so that LD_LIBRARY_PATH is not overridden by the application.
Sam Lantinga <slouken@libsdl.org>
parents: 10034
diff changeset
   965
      if(HAVE_ENABLE_NEW_DTAGS)
10044
8fc20bbbed5c Fixed --enable-new-dtags check with cmake
Sam Lantinga <slouken@libsdl.org>
parents: 10043
diff changeset
   966
        set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir} -Wl,--enable-new-dtags")
8fc20bbbed5c Fixed --enable-new-dtags check with cmake
Sam Lantinga <slouken@libsdl.org>
parents: 10043
diff changeset
   967
      else()
8fc20bbbed5c Fixed --enable-new-dtags check with cmake
Sam Lantinga <slouken@libsdl.org>
parents: 10043
diff changeset
   968
        set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
10043
24e8d042e532 Use --enable-new-dtags to set RUNPATH rather than RPATH so that LD_LIBRARY_PATH is not overridden by the application.
Sam Lantinga <slouken@libsdl.org>
parents: 10034
diff changeset
   969
      endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   970
    elseif(SOLARIS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   971
      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
   972
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   973
    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
   974
    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
   975
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   976
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   977
elseif(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   978
  find_program(WINDRES windres)
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
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   981
    #include <windows.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   982
    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
   983
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
   984
  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
   985
  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
   986
9994
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   987
  if(MSVC)
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   988
    # Prevent codegen that would use the VC runtime libraries.
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   989
    add_definitions(/GS-)
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   990
    if(NOT ARCH_64)
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   991
      add_definitions(/arch:SSE)
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   992
    endif()
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   993
  endif()
d3e4f7b44d4d CMake: Fixed building for Windows with VS2015 (bug #3080).
Alex Szpakowski <slime73@gmail.com>
parents: 9982
diff changeset
   994
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   995
  # Check for DirectX
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   996
  if(DIRECTX)
9979
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
   997
    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
   998
        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
   999
    endif()
e3d651c5fe31 CMake: Fixed to work on Windows 8 SDK (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9854
diff changeset
  1000
    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
  1001
      if("$ENV{DXSDK_DIR}" STREQUAL "")
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1002
        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
  1003
      endif()
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1004
      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
  1005
    endif()
9853
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
  1006
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
  1007
    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
  1008
      # 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
  1009
      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
  1010
        #include <windows.h>
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
  1011
        #include <xinput.h>
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
  1012
        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
  1013
    else()
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
  1014
      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
  1015
    endif()
3d08cb641cd5 Fixed bug 3098: CMake project never enables xinput support on Windows.
Alex Szpakowski <slime73@gmail.com>
parents: 9758
diff changeset
  1016
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1017
    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
  1018
    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
  1019
    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
  1020
    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
  1021
    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
  1022
    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
  1023
    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
  1024
    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
  1025
      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
  1026
      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
  1027
      # 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
  1028
        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
  1029
        include_directories($ENV{DXSDK_DIR}\\Include)
cf4d3ee2b37b CMake fixes for MingW (thanks, Ozkan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9731
diff changeset
  1030
      endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1031
    endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
  1032
    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
  1033
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1034
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1035
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1036
    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
  1037
    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
  1038
    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
  1039
    set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1040
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1041
    if(HAVE_DSOUND_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1042
      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
  1043
      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
  1044
      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
  1045
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1046
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1047
    if(HAVE_XAUDIO2_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1048
      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
  1049
      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
  1050
      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
  1051
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1052
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1053
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1054
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1055
    # 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
  1056
    if(NOT SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1057
      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
  1058
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1059
    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
  1060
    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
  1061
    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
  1062
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1063
    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
  1064
      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
  1065
      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
  1066
    endif()
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
  1067
    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
  1068
      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
  1069
      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
  1070
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1071
    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
  1072
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1073
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1074
  if(SDL_THREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1075
    set(SDL_THREAD_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1076
    set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1077
      ${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
  1078
      ${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
  1079
      ${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
  1080
      ${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
  1081
      ${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
  1082
    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
  1083
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1084
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1085
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1086
    set(SDL_POWER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1087
    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
  1088
    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
  1089
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1090
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1091
  if(SDL_FILESYSTEM)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1092
    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
  1093
    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
  1094
    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
  1095
    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
  1096
  endif()
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1097
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1098
  # 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
  1099
  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
  1100
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1101
  # 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
  1102
  # 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
  1103
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1104
    set(SDL_TIMER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1105
    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
  1106
    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
  1107
    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
  1108
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1109
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1110
  if(SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1111
    set(SDL_LOADSO_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1112
    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
  1113
    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
  1114
    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
  1115
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1116
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1117
  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
  1118
  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
  1119
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1120
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1121
    if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1122
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1123
      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
  1124
      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
  1125
      set(HAVE_VIDEO_OPENGL TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.or