CMakeLists.txt
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Fri, 30 Jan 2015 23:18:14 +0100
changeset 9322 a45110bca65e
parent 9313 6f04557c6e1f
child 9408 93ba64cb5e16
permissions -rw-r--r--
Changed static variable to local variable in implementation for Android.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     1
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     2
  message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     3
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     4
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
     5
cmake_minimum_required(VERSION 2.8)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     6
project(SDL2 C)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     7
include(CheckFunctionExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     8
include(CheckLibraryExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     9
include(CheckIncludeFiles)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    10
include(CheckIncludeFile)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    11
include(CheckSymbolExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    12
include(CheckCSourceRuns)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    13
include(CheckCCompilerFlag)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    14
include(CheckTypeSize)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    15
include(CheckStructHasMember)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    16
include(CMakeDependentOption)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    17
include(FindPkgConfig)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    21
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    22
# General settings
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    23
# Edit include/SDL_version.h and change the version, then:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    24
#   SDL_MICRO_VERSION += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
#   SDL_INTERFACE_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
#   SDL_BINARY_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
# if any functions have been added, set SDL_INTERFACE_AGE to 0.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
# if backwards compatibility has been broken,
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    30
set(SDL_MAJOR_VERSION 2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    31
set(SDL_MINOR_VERSION 0)
9121
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    32
set(SDL_MICRO_VERSION 4)
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    33
set(SDL_INTERFACE_AGE 0)
00d99eff96a6 Updated version to 2.0.4
Sam Lantinga <slouken@libsdl.org>
parents: 9112
diff changeset
    34
set(SDL_BINARY_AGE 4)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    35
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
# Calculate a libtool-like version number
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    39
math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}")
8203
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    40
math(EXPR LT_MAJOR "${LT_CURRENT}- ${LT_AGE}")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    41
set(LT_REVISION "${SDL_INTERFACE_AGE}")
7525
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
    42
set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}")
8203
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    43
set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}")
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    44
5c9ac454116e Fix Cmake so generated SOname matches autoconf's #.
Edward Rudd <urkle@outoforder.cc>
parents: 8197
diff changeset
    45
message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    46
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    47
# General settings & flags
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
set(LIBRARY_OUTPUT_DIRECTORY "build")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    49
# Check for 64 or 32 bit
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    50
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    51
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    52
  set(ARCH_64 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    53
  set(PROCESSOR_ARCH "x64")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    54
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    55
  set(ARCH_64 FALSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    56
  set(PROCESSOR_ARCH "x86")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
    57
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
set(LIBNAME SDL2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
if(NOT LIBTYPE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
  set(LIBTYPE SHARED)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
    61
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    62
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    63
# Get the platform
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
if(WIN32)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
  if(NOT WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
    set(WINDOWS TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
    67
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    68
elseif(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
  if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
    set(LINUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
  elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    72
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
  elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
    set(NETBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
  elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
    set(OPENBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    78
    set(GNU TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
    set(BSDI TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
  elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    83
  elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
    set(SYSV5 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    85
  elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
    set(SOLARIS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    87
  elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
    set(HPUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    89
  elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
    set(AIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    91
  elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
    set(MINIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
elseif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
  if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
    set(DARWIN TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
    set(MACOSX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    99
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
  # TODO: iOS?
7981
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   101
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   102
  message_error("BeOS support has been removed as of SDL 2.0.2.")
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   103
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   104
  set(HAIKU TRUE)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   107
# Don't mistake osx for unix
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
if(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   109
  set(UNIX_SYS ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   110
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   111
  set(UNIX_SYS OFF)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   112
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   113
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   114
if(UNIX OR APPLE)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   115
  set(UNIX_OR_MAC_SYS ON)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   116
else()
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   117
  set(UNIX_OR_MAC_SYS OFF)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   118
endif()
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   119
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   120
if (UNIX_OR_MAC_SYS AND NOT EMSCRIPTEN) # JavaScript does not yet have threading support, so disable pthreads when building for Emscripten.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   121
  set(PTHREADS_ENABLED_BY_DEFAULT ON)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   122
else()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   123
  set(PTHREADS_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   124
endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   125
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
# Default option knobs
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
if(APPLE OR ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   128
  set(OPT_DEF_SSEMATH ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   129
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   130
if(UNIX OR MINGW OR MSYS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   131
  set(OPT_DEF_LIBC ON)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   132
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   133
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   134
# Compiler info
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   135
if(CMAKE_COMPILER_IS_GNUCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   136
  set(USE_GCC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
  set(USE_CLANG TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   142
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   143
  #set(CMAKE_C_FLAGS "/ZI /WX- /
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
  set(OPT_DEF_ASM FALSE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   146
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
# Default flags, if not set otherwise
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
if("$ENV{CFLAGS}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
  if(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
    set(CMAKE_C_FLAGS "-g -O3")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   152
  endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   153
else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
  set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
  list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   156
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   157
if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   158
  list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   159
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   160
8136
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   161
if(MSVC)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   162
  option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   163
  if(FORCE_STATIC_VCRT)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   164
    foreach(flag_var
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   165
        CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   166
        CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   167
      if(${flag_var} MATCHES "/MD")
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   168
        string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   169
      endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   170
    endforeach()
8136
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   171
  endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   172
endif()
8136
175cac5d90a6 Some CMake fixes for static linking on Windows from the OpenFL project.
Ryan C. Gordon <icculus@icculus.org>
parents: 8133
diff changeset
   173
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   174
# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   175
# etc. are created correctly.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   176
set(SDL_LIBS "-lSDL2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   177
set(SDL_CFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   178
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   179
# Emscripten toolchain has a nonempty default value for this, and the checks 
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   180
# in this file need to change that, so remember the original value, and 
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   181
# restore back to that afterwards. For check_function_exists() to work in
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   182
# Emscripten, this value must be at its default value.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   183
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   184
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   185
if(CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   186
  # We build SDL on cygwin without the UNIX emulation layer
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   187
  include_directories("-I/usr/include/mingw")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   188
  set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   189
  check_c_source_compiles("int main(int argc, char **argv) {}"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   190
    HAVE_GCC_NO_CYGWIN)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   191
  set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   192
  if(HAVE_GCC_NO_CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   193
    list(APPEND EXTRA_LDFLAGS "-mno-cygwin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   194
    list(APPEND SDL_LIBS "-mno-cygwin")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   195
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   196
  set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include/mingw")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   197
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   198
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   199
add_definitions(-DUSING_GENERATED_CONFIG_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   200
# General includes
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   201
include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   202
9279
e1d1b6479a14 CMake: Minor cleanup up on the new SDL_*_ENABLED_BY_DEFAULT vars.
Ryan C. Gordon <icculus@icculus.org>
parents: 9278
diff changeset
   203
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
e1d1b6479a14 CMake: Minor cleanup up on the new SDL_*_ENABLED_BY_DEFAULT vars.
Ryan C. Gordon <icculus@icculus.org>
parents: 9278
diff changeset
   204
#  you only need to have a platform override them if they are disabling.
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   205
if(EMSCRIPTEN)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   206
  # 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
   207
  # 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
   208
  # loading architecture, low-level CPU inspection or multithreading.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   209
  set(OPT_DEF_ASM FALSE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   210
  set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   211
  set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   212
  set(SDL_THREADS_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   213
  set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   214
  set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   215
  set(DLOPEN_ENABLED_BY_DEFAULT OFF)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   216
endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   217
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   218
set(SDL_SUBSYSTEMS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   219
    Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   220
    File Loadso CPUinfo Filesystem)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   221
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   222
  string(TOUPPER ${_SUB} _OPT)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   223
  if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   224
    set(SDL_${_OPT}_ENABLED_BY_DEFAULT ON)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   225
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   226
  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
   227
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   228
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   229
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
   230
#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
   231
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
   232
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
   233
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
   234
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
   235
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
   236
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
   237
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
   238
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
   239
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
   240
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
   241
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
   242
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
   243
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
   244
set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   245
dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND_SHARED" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   246
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
   247
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
   248
set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   249
set_option(PTHREADS            "Use POSIX threads for multi-threading" ${PTHREADS_ENABLED_BY_DEFAULT})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   250
dep_option(PTHREADS_SEM        "Use pthread semaphores" ON "PTHREADS" OFF)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   251
set_option(SDL_DLOPEN          "Use dlopen for shared object loading" ${DLOPEN_ENABLED_BY_DEFAULT})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   252
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
   253
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
   254
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
   255
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
   256
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
   257
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
   258
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
   259
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
   260
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
   261
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
   262
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
   263
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
   264
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
   265
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
   266
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
   267
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
   268
set_option(VIDEO_WAYLAND       "Use Wayland video driver" ${UNIX_SYS})
eb1281b43b5d Re-enable Mir/Wayland support now that 2.0.3 has been released.
Brandon Schaefer <brandon.schaefer@canonical.com>
parents: 8606
diff changeset
   269
set_option(VIDEO_MIR           "Use Mir video driver" ${UNIX_SYS})
9077
28e6de55eb07 Fixed bug 2683 - Raspberry PI support using CMake
Sam Lantinga <slouken@libsdl.org>
parents: 9075
diff changeset
   270
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
   271
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
   272
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
   273
foreach(_SUB ${SDL_X11_OPTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   274
  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
   275
  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
   276
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   277
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
   278
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
   279
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
   280
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
   281
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   282
# 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
   283
# 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
   284
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
   285
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
   286
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   287
# General source files
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   288
file(GLOB SOURCE_FILES
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   289
  ${SDL2_SOURCE_DIR}/src/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   290
  ${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
   291
  ${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
   292
  ${SDL2_SOURCE_DIR}/src/cpuinfo/*.c
8094
9efaae827924 Implemented the Dynamic API magic.
Ryan C. Gordon <icculus@icculus.org>
parents: 8090
diff changeset
   293
  ${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
   294
  ${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
   295
  ${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
   296
  ${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
   297
  ${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
   298
  ${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
   299
  ${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
   300
  ${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
   301
  ${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
   302
  ${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
   303
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   304
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   305
if(ASSERTIONS STREQUAL "auto")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   306
  # 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
   307
elseif(ASSERTIONS STREQUAL "disabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   308
  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
   309
elseif(ASSERTIONS STREQUAL "release")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   310
  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
   311
elseif(ASSERTIONS STREQUAL "enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   312
  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
   313
elseif(ASSERTIONS STREQUAL "paranoid")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   314
  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
   315
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   316
  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
   317
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   318
set(HAVE_ASSERTIONS ${ASSERTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   319
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   320
# Compiler option evaluation
7999
2c9aedfba740 Fixed bug 2238 - Enable GCC atomics for clang
Sam Lantinga <slouken@libsdl.org>
parents: 7981
diff changeset
   321
if(USE_GCC OR USE_CLANG)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   322
  if(DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   323
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   324
        #if !defined(__GNUC__) || __GNUC__ < 3
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   325
        #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
   326
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   327
        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
   328
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   329
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   330
  if(GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   331
    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
   332
        int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   333
        void *x, *y, *z;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   334
        __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
   335
        __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
   336
        __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
   337
        __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
   338
        __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
   339
    if(NOT HAVE_GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   340
      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
   341
          int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   342
          __sync_lock_test_and_set(&a, 1);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   343
          __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
   344
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   345
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   346
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   347
  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
   348
  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
   349
    HAVE_GCC_PREFERRED_STACK_BOUNDARY)
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   350
  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
   351
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   352
  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
   353
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   354
      #if !defined(__GNUC__) || __GNUC__ < 4
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   355
      #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
   356
      #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   357
      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
   358
  if(HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   359
    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
   360
  endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   361
  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
   362
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   363
  check_c_compiler_flag(-Wall HAVE_GCC_WALL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   364
  if(HAVE_GCC_WALL)
9081
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   365
    list(APPEND EXTRA_CFLAGS "-Wall")
7981
6d538bc1b395 Renamed things named after BeOS to be named after Haiku instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 7977
diff changeset
   366
    if(HAIKU)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   367
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   368
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   369
  endif()
9081
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   370
  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
   371
  if(HAVE_GCC_WSHADOW)
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   372
    list(APPEND EXTRA_CFLAGS "-Wshadow")
39eb61ccbc82 cmake: add -Wall/-Wshadow to GCC compilation flags
Sam Lantinga <slouken@libsdl.org>
parents: 9080
diff changeset
   373
  endif()
9082
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   374
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   375
  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
   376
  check_c_compiler_flag("" HAVE_NO_UNDEFINED)
9083
029f8d643dbe Reset CMAKE_REQUIRED_FLAGS after test
Sam Lantinga <slouken@libsdl.org>
parents: 9082
diff changeset
   377
  set(CMAKE_REQUIRED_FLAGS)
9082
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   378
  if(HAVE_NO_UNDEFINED)
22232029f074 cmake: add -Wl,--no-undefined to GCC linker flags
Sam Lantinga <slouken@libsdl.org>
parents: 9081
diff changeset
   379
    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
   380
  endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   381
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   382
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   383
if(ASSEMBLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   384
  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
   385
    set(SDL_ASSEMBLY_ROUTINES 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   386
    # 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
   387
    # reworked for better compiler support
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   388
    set(HAVE_ASSEMBLY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   389
    if(MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   390
      set(CMAKE_REQUIRED_FLAGS "-mmmx")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   391
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   392
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   393
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   394
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   395
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   396
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   397
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   398
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   399
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   400
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   401
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   402
          #ifndef __MMX__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   403
          #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
   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_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   406
      if(HAVE_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   407
        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
   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})
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   410
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   411
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   412
    if(3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   413
      set(CMAKE_REQUIRED_FLAGS "-m3dnow")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   414
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   415
          #include <mm3dnow.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   416
          #ifndef __3dNOW__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   417
          #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
   418
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   419
          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
   420
            void *p = 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   421
            _m_prefetch(p);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   422
          }" HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   423
      if(HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   424
        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
   425
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   426
      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
   427
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   428
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   429
    if(SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   430
      set(CMAKE_REQUIRED_FLAGS "-msse")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   431
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   432
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   433
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   434
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   435
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   436
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   437
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   438
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   439
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   440
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   441
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   442
          #ifndef __SSE__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   443
          #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
   444
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   445
          int main(int argc, char **argv) { }" HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   446
      if(HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   447
        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
   448
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   449
      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
   450
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   451
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   452
    if(SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   453
      set(CMAKE_REQUIRED_FLAGS "-msse2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   454
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   455
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   456
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   457
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   458
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   459
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   460
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   461
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   462
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   463
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   464
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   465
          #ifndef __SSE2__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   466
          #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
   467
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   468
          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
   469
      if(HAVE_SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   470
        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
   471
      endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   472
      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
   473
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   474
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   475
    if(SSEMATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   476
      if(SSE OR SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   477
        if(USE_GCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   478
          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
   479
        endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   480
        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
   481
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   482
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   483
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   484
    if(ALTIVEC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   485
      set(CMAKE_REQUIRED_FLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   486
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   487
          #include <altivec.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   488
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   489
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   490
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   491
          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
   492
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   493
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   494
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   495
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   496
          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
   497
      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
   498
      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
   499
        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
   500
        list(APPEND EXTRA_CFLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   501
        set(SDL_ALTIVEC_BLITTERS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   502
        if(HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   503
          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
   504
        endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   505
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   506
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   507
  elseif(MSVC_VERSION GREATER 1500)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   508
    # 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
   509
    # 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
   510
    if(NOT ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   511
      set(HAVE_MMX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   512
      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
   513
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   514
    set(HAVE_SSE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   515
    set(HAVE_SSE2 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   516
    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
   517
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   518
# TODO:
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   519
#else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   520
#  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
   521
#    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
   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
# 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
   526
# anything.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   527
if(LIBC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   528
  if(WINDOWS AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   529
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   530
    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
   531
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   532
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   533
      set(${_HAVE_H} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   534
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   535
    set(HAVE_SIGNAL_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   536
    foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   537
            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
   538
            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
   539
            _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
   540
            _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
   541
            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
   542
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   543
      set(HAVE_${_UPPER} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   544
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   545
    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
   546
      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
   547
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   548
    set(HAVE_M_PI 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   549
    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
   550
    set(STDC_HEADERS 1)
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   551
  else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   552
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   553
    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
   554
    foreach(_HEADER
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   555
            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
   556
            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
   557
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   558
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   559
      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
   560
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   561
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   562
    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
   563
    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
   564
    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
   565
    # TODO: refine the mprotect check
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   566
    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
   567
                             #include <sys/mman.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   568
                             int main() { }" HAVE_MPROTECT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   569
    foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   570
            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
   571
            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
   572
            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
   573
            _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
   574
            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
   575
            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
   576
            nanosleep sysconf sysctlbyname
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   577
            )
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   578
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   579
      set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   580
      check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   581
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   582
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   583
    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
   584
    if(HAVE_LIBM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   585
      set(CMAKE_REQUIRED_LIBRARIES m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   586
      foreach(_FN
9080
2e4e71ec140f Removed SDL_round() because the license wasn't compatible with zlib
Sam Lantinga <slouken@libsdl.org>
parents: 9077
diff changeset
   587
              atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
8842
f587255157cf Fixed building on command line Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 8751
diff changeset
   588
              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
   589
        string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   590
        set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   591
        check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   592
      endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   593
      set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   594
      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
   595
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   596
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   597
    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
   598
    if(HAVE_LIBICONV)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   599
      list(APPEND EXTRA_LIBS iconv)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   600
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   601
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   602
    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
   603
  endif()
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   604
else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   605
  if(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   606
    set(HAVE_STDARG_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   607
    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
   608
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   609
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   610
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   611
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   612
# 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
   613
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   614
  string(TOUPPER ${_SUB} _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   615
  if(NOT SDL_${_OPT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   616
    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
   617
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   618
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   619
if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   620
  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
   621
  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
   622
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   623
if(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   624
  if(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   625
    # 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
   626
    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
   627
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   628
  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
   629
  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
   630
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   631
if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   632
  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
   633
  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
   634
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   635
# 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
   636
# 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
   637
# 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
   638
# 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
   639
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   640
# 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
   641
if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   642
  # 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
   643
  if(DUMMYAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   644
    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
   645
    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
   646
    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
   647
    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
   648
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   649
  if(DISKAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   650
    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
   651
    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
   652
    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
   653
    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
   654
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   655
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   656
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   657
if(SDL_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   658
  # Relevant for Unix/Darwin only
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   659
  if(UNIX OR APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   660
    CheckDLOPEN()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   661
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   662
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   663
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   664
if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   665
  if(VIDEO_DUMMY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   666
    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
   667
    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
   668
    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
   669
    set(HAVE_VIDEO_DUMMY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   670
    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
   671
  endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   672
endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   673
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   674
# Platform-specific options and settings
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   675
if(EMSCRIPTEN)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   676
  # 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
   677
  # 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
   678
  add_definitions(-Wno-warn-absolute-paths)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   679
  if(SDL_AUDIO)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   680
    set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   681
    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
   682
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_AUDIO_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   683
    set(HAVE_SDL_AUDIO TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   684
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   685
  if(SDL_FILESYSTEM)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   686
    set(SDL_FILESYSTEM_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   687
    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
   688
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_FILESYSTEM_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   689
    set(HAVE_SDL_FILESYSTEM TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   690
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   691
  if(SDL_JOYSTICK)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   692
    set(SDL_JOYSTICK_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   693
    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
   694
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_JOYSTICK_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   695
    set(HAVE_SDL_JOYSTICK TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   696
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   697
  if(SDL_POWER)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   698
    set(SDL_POWER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   699
    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
   700
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   701
    set(HAVE_SDL_POWER TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   702
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   703
  if(SDL_VIDEO)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   704
    set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   705
    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
   706
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_VIDEO_SOURCES})
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   707
    set(HAVE_SDL_VIDEO TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   708
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   709
    #enable gles
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   710
    if(VIDEO_OPENGLES)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   711
      set(SDL_VIDEO_OPENGL_EGL 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   712
      set(HAVE_VIDEO_OPENGLES TRUE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   713
      set(SDL_VIDEO_OPENGL_ES2 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   714
      set(SDL_VIDEO_RENDER_OGL_ES2 1)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   715
    endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   716
  endif()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   717
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
   718
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   719
    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
   720
        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
   721
        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
   722
        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
   723
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   724
    elseif(NETBSD OR OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   725
        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
   726
        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
   727
        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
   728
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   729
    elseif(AIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   730
        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
   731
        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
   732
        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
   733
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   734
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   735
    CheckOSS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   736
    CheckALSA()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   737
    CheckPulseAudio()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   738
    CheckESD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   739
    CheckARTS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   740
    CheckNAS()
7367
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 6774
diff changeset
   741
    CheckSNDIO()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   742
    CheckFusionSound()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   743
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   744
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   745
  if(SDL_VIDEO)
9077
28e6de55eb07 Fixed bug 2683 - Raspberry PI support using CMake
Sam Lantinga <slouken@libsdl.org>
parents: 9075
diff changeset
   746
    # 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
   747
    CheckRPI()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   748
    CheckX11()
8153
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8137
diff changeset
   749
    CheckMir()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   750
    CheckDirectFB()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   751
    CheckOpenGLX11()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   752
    CheckOpenGLESX11()
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8056
diff changeset
   753
    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
   754
    CheckVivante()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   755
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   756
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   757
  if(LINUX)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   758
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   759
        #include <linux/input.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   760
        #ifndef EVIOCGNAME
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   761
        #error EVIOCGNAME() ioctl not available
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   762
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   763
        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
   764
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   765
    check_c_source_compiles("
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   766
        #include <linux/kd.h>
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   767
        #include <linux/keyboard.h>
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   768
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   769
        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
   770
        {
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   771
            struct kbentry kbe;
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   772
            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
   773
            ioctl(0, KDGKBENT, &kbe);
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   774
        }" HAVE_INPUT_KD)
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   775
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
   776
    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
   777
    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
   778
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   779
    if(HAVE_INPUT_EVENTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   780
      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
   781
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   782
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   783
    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
   784
      set(SDL_HAPTIC_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   785
      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
   786
      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
   787
      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
   788
    endif()
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   789
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   790
    if(HAVE_INPUT_KD)
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   791
      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
   792
    endif()
8032
e2096994e8b8 Fixes #2271, Add KD detection under CMake by Scott Percival
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8031
diff changeset
   793
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   794
    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
   795
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   796
    # !!! 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
   797
    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
   798
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   799
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   800
  if(INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   801
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   802
        #include \"tslib.h\"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   803
        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
   804
    if(HAVE_INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   805
      set(SDL_INPUT_TSLIB 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   806
      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
   807
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   808
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   809
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   810
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   811
    CheckUSBHID()   # seems to be BSD specific - limit the test to BSD only?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   812
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   813
      set(SDL_JOYSTICK_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   814
      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
   815
      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
   816
      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
   817
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   818
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   819
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   820
  CheckPTHREAD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   821
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   822
  if(CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   823
    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
   824
    if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   825
      list(APPEND EXTRA_LIBS rt)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   826
      set(HAVE_CLOCK_GETTIME 1)
9277
f0bd40782fc7 CMake: Replace "else(condition)" with "else()", etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   827
    else()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   828
      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
   829
      if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   830
        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
   831
      endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   832
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   833
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   834
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   835
  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
   836
  if(HAVE_LINUX_VERSION_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   837
    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
   838
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   839
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   840
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   841
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   842
      set(SDL_POWER_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   843
      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
   844
      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
   845
      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
   846
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   847
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   848
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   849
  if(SDL_FILESYSTEM)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   850
    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
   851
    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
   852
    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
   853
    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
   854
  endif()
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   855
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   856
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   857
    set(SDL_TIMER_UNIX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   858
    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
   859
    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
   860
    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
   861
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   862
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   863
  if(RPATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   864
    set(SDL_RLD_FLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   865
    if(BSDI OR FREEBSD OR LINUX OR NETBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   866
      set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   867
    elseif(SOLARIS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   868
      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
   869
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   870
    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
   871
    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
   872
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   873
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   874
elseif(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   875
  find_program(WINDRES windres)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   876
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   877
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   878
    #include <windows.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   879
    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
   880
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
   881
  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
   882
  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
   883
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   884
  # Check for DirectX
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   885
  if(DIRECTX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   886
    if("$ENV{DXSDK_DIR}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   887
      message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   888
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   889
    set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   890
    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
   891
    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
   892
    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
   893
    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
   894
    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
   895
    check_include_file(xaudio2.h HAVE_XAUDIO2_H)
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
   896
    check_include_file(xinput.h HAVE_XINPUT_H)
8751
e8c61640668d Fix build on Windows targets without dxgi.h, like MingW32.
Ryan C. Gordon <icculus@icculus.org>
parents: 8680
diff changeset
   897
    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
   898
    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
   899
      set(HAVE_DIRECTX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   900
      # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   901
      link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   902
      include_directories($ENV{DXSDK_DIR}\\Include)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   903
    endif()
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9277
diff changeset
   904
    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
   905
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   906
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   907
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   908
    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
   909
    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
   910
    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
   911
    set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   912
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   913
    if(HAVE_DSOUND_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   914
      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
   915
      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
   916
      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
   917
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   918
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   919
    if(HAVE_XAUDIO2_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   920
      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
   921
      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
   922
      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
   923
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   924
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   925
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   926
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   927
    # 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
   928
    if(NOT SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   929
      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
   930
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   931
    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
   932
    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
   933
    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
   934
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   935
    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
   936
      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
   937
      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
   938
    endif()
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8303
diff changeset
   939
    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
   940
      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
   941
      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
   942
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   943
    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
   944
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   945
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   946
  if(SDL_THREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   947
    set(SDL_THREAD_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   948
    set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   949
      ${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
   950
      ${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
   951
      ${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
   952
      ${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
   953
      ${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
   954
    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
   955
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   956
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   957
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   958
    set(SDL_POWER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   959
    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
   960
    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
   961
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   962
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   963
  if(SDL_FILESYSTEM)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   964
    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
   965
    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
   966
    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
   967
    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
   968
  endif()
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
   969
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   970
  # 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
   971
  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
   972
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   973
  # 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
   974
  # 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
   975
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   976
    set(SDL_TIMER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   977
    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
   978
    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
   979
    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
   980
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   981
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   982
  if(SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   983
    set(SDL_LOADSO_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   984
    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
   985
    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
   986
    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
   987
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   988
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   989
  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
   990
  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
   991
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   992
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   993
    if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   994
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   995
      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
   996
      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
   997
      set(HAVE_VIDEO_OPENGL TRUE)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   998
    endif()
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
   999
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1000
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1001
  if(SDL_JOYSTICK)
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1002
    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1003
    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1004
    if(HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1005
      set(SDL_JOYSTICK_DINPUT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1006
      list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1007
    endif()
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1008
    if(HAVE_XINPUT_H)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1009
      set(SDL_JOYSTICK_XINPUT 1)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1010
    endif()
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1011
    if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1012
      set(SDL_JOYSTICK_WINMM 1)
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1013
    endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1014
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1015
9073
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1016
    if(SDL_HAPTIC)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1017
      file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/windows/*.c)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1018
      set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1019
      if(HAVE_DINPUT_H)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1020
        set(SDL_HAPTIC_DINPUT 1)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1021
      endif()
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1022
      if(HAVE_XINPUT_H)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1023
        set(SDL_HAPTIC_XINPUT 1)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1024
      endif()
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1025
      set(HAVE_SDL_HAPTIC TRUE)
98d13a381299 Fixed building on Windows with CMake
Sam Lantinga <slouken@libsdl.org>
parents: 8910
diff changeset
  1026
    endif()
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1027
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1028
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1029
  file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1030
  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1031
  if(MINGW OR CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1032
    list(APPEND EXTRA_LIBS mingw32)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1033
    list(APPEND EXTRA_LDFLAGS "-mwindows")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1034
    set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1035
    list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
8137
6dbd80731aa0 Move to no-argument version of "endif()" in CMakeLists.txt.
Ryan C. Gordon <icculus@icculus.org>
parents: 8136
diff changeset
  1036
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1037
elseif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1038
  # TODO: rework this for proper MacOS X, iOS and Darwin support
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1039
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1040
  # Requires the darwin file implementation
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1041
  if(SDL_FILE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1042
    file(GLOB EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/file/cocoa/*.m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1043
    set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1044
    set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1045
    set(HAVE_SDL_FILE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1046
    set(SDL_FRAMEWORK_COCOA 1)
9112
345a7d41dda9 Fixed bug 2696 - Mac: fix display mode refresh rate calculation
Sam Lantinga <slouken@libsdl.org>
parents: 9093
diff changeset
  1047
    set(SDL_FRAMEWORK_COREVIDEO 1)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1048
  else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1049
    message_error("SDL_FILE must be enabled to build on MacOS X")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1050
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1051
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1052
  if(SDL_AUDIO)
9312
705bdbbb1f37 Fixed bug 2807 - Not using CoreAudio on OS X when built via CMake
Felix H. Dahlke <fhd@ubercode.de>
parents: 9279
diff changeset
  1053
    set(SDL_AUDIO_DRIVER_COREAUDIO 1)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1054
    file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1055
    set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1056
    set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1057
    set(SDL_FRAMEWORK_COREAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1058
    set(SDL_FRAMEWORK_AUDIOUNIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1059
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1060
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1061
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1062
    set(SDL_JOYSTICK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1063
    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1064
    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
  1065
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1066
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1067
    set(SDL_FRAMEWORK_FF 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1068
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1069
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1070
  if(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1071
    set(SDL_HAPTIC_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1072
    file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1073
    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
  1074
    set(HAVE_SDL_HAPTIC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1075
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1076
    set(SDL_FRAMEWORK_FF 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1077
    if(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1078
      message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1079
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1080
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1081
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1082
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1083
    set(SDL_POWER_MACOSX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1084
    file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1085
    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
  1086
    set(HAVE_SDL_POWER TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1087
    set(SDL_FRAMEWORK_CARBON 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1088
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1089
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1090
8133
f24acf2403c0 CMake: Enable missing timer subsystem on Mac OS X and Haiku.
Ryan C. Gordon <icculus@icculus.org>
parents: 8126
diff changeset
  1091
  if(SDL_TIMERS)
f24acf2403c0 CMake: Enable missing timer subsystem on Mac OS X and Haiku.
Ryan C. Gordon <icculus@icculus.org>
parents: 8126
diff changeset
  1092
    set(SDL_TIMER_UNIX 1)
f24acf2403c0 CMake: Enable missing timer subsystem on Mac OS X and Haiku.
Ryan C. Gordon <icculus@icculus.org>
parents: 8126
diff changeset
  1093
    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
f24acf2403c0 CMake: Enable missing timer subsystem on Mac OS X and Haiku.
Ryan C. Gordon <icculus@icculus.org>
parents: 8126
diff changeset
  1094
    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
f24acf2403c0 CMake: Enable missing timer subsystem on Mac OS X and Haiku.
Ryan C. Gordon <icculus@icculus.org>
parents: 8126
diff changeset
  1095
    set(HAVE_SDL_TIMERS TRUE)
f24acf2403c0 CMake: Enable missing timer subsystem on Mac OS X and Haiku.
Ryan C. Gordon <icculus@icculus.org>
parents: 8126
diff changeset
  1096
  endif(SDL_TIMERS)
f24acf2403c0 CMake: Enable missing timer subsystem on Mac OS X and Haiku.
Ryan C. Gordon <icculus@icculus.org>
parents: 8126
diff changeset
  1097
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1098
  if(SDL_FILESYSTEM)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1099
    set(SDL_FILESYSTEM_COCOA 1)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1100
    file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
8248
427d0a6f5af7 CMake: Fixed build on Mac OS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 8203
diff changeset
  1101
    set_source_files_properties(${FILESYSTEM_SOURCES} PROPERTIES LANGUAGE C)
7667
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1102
    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
  1103
    set(HAVE_SDL_FILESYSTEM TRUE)
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1104
  endif()
be1cc6f55840 Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module.
Ryan C. Gordon <icculus@icculus.org>
parents: 7666
diff changeset
  1105
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1106
  # Actually load the frameworks at the end so we don't duplicate include.
9112
345a7d41dda9 Fixed bug 2696 - Mac: fix display mode refresh rate calculation
Sam Lantinga <slouken@libsdl.org>
parents: 9093
diff changeset
  1107
  if(SDL_FRAMEWORK_COREVIDEO)
345a7d41dda9 Fixed bug 2696 - Mac: fix display mode refresh rate calculation
Sam Lantinga <slouken@libsdl.org>
parents: 9093
diff changeset
  1108
    find_library(COREVIDEO CoreVideo)
345a7d41dda9 Fixed bug 2696 - Mac: fix display mode refresh rate calculation
Sam Lantinga <slouken@libsdl.org>
parents: 9093
diff changeset
  1109
    list(APPEND EXTRA_LIBS ${COREVIDEO})
345a7d41dda9 Fixed bug 2696 - Mac: fix display mode refresh rate calculation
Sam Lantinga <slouken@libsdl.org>
parents: 9093
diff changeset
  1110
  endif()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1111
  if(SDL_FRAMEWORK_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1112
    find_library(COCOA_LIBRARY Cocoa)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1113
    list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1114
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1115
  if(SDL_FRAMEWORK_IOKIT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1116
    find_library(IOKIT IOKit)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1117
    list(APPEND EXTRA_LIBS ${IOKIT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1118
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1119
  if(SDL_FRAMEWORK_FF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1120
    find_library(FORCEFEEDBACK ForceFeedback)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1121
    list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1122
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1123
  if(SDL_FRAMEWORK_CARBON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1124
    find_library(CARBON_LIBRARY Carbon)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1125
    list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1126
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1127
  if(SDL_FRAMEWORK_COREAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1128
    find_library(COREAUDIO CoreAudio)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1129
    list(APPEND EXTRA_LIBS ${COREAUDIO})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1130
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1131
  if(SDL_FRAMEWORK_AUDIOUNIT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1132
    find_library(AUDIOUNIT AudioUnit)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1133
    list(APPEND EXTRA_LIBS ${AUDIOUNIT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1134
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1135
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1136
  # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1137
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1138
    CheckCOCOA()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1139
    if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1140
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1141
      set(SDL_VIDEO_OPENGL_CGL 1)
45a21e50ba5e Adds CMake build syste