CMakeLists.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. include_directories(include)
  2. # Define source files
  3. file (GLOB C_FILES
  4. src/*.c src/atomic/*.c src/audio/*.c src/audio/disk/*.c src/audio/dummy/*.c src/cpuinfo/*.c src/events/*.c src/file/*.c
  5. src/haptic/*.c src/joystick/*.c src/libm/*.c src/power/*.c src/stdlib/*.c
  6. src/thread/*.c src/timer/*.c src/video/*.c src/video/dummy/*.c
  7. )
  8. if (WIN32)
  9. # New MinGW versions may evaluate whether to use A or W postfix on functions before SDL gets to define UNICODE on its own,
  10. # so make sure it is already defined
  11. if (MINGW)
  12. add_definitions (-DUNICODE=1)
  13. endif ()
  14. #CHECK_INCLUDE_FILES (wbemcli.h HAVE_WBEMCLI_H)
  15. #if (HAVE_WBEMCLI_H)
  16. add_definitions (-DSDL_JOYSTICK_DINPUT)
  17. add_definitions (-DSDL_HAPTIC_DINPUT)
  18. set (HAPTIC_DRIVER windows)
  19. #else ()
  20. # message (STATUS "Building SDL without DX joystick support due to missing wbemcli.h")
  21. # message (STATUS "For MSVC, get it from Windows 7 SDK. For MinGW, get it from eg. Wine sources or #from MinGW-w64")
  22. # add_definitions (-DSDL_JOYSTICK_WINMM)
  23. # add_definitions (-DSDL_HAPTIC_DUMMY)
  24. # set (HAPTIC_DRIVER dummy)
  25. #endif ()
  26. file (GLOB SYS_C_FILES
  27. src/audio/directsound/*.c src/haptic/${HAPTIC_DRIVER}/*.c src/joystick/windows/*.c src/core/windows/*.c src/loadso/windows/*.c
  28. src/power/windows/*.c src/thread/windows/*.c src/thread/generic/SDL_syscond.c src/timer/windows/*.c src/video/windows/*.c src/joystick/dummy/*.c
  29. src/filesystem/windows/*.c
  30. )
  31. elseif (IOS)
  32. file (GLOB SYS_C_FILES
  33. src/audio/coreaudio/*.c src/file/cocoa/*.m src/joystick/iphoneos/*.m src/loadso/dlopen/*.c src/power/uikit/*.m
  34. src/thread/pthread/*.c src/timer/unix/*.c src/video/uikit/*.m src/video/uikit/*.c src/haptic/dummy/*.c
  35. src/filesystem/cocoa/*.m
  36. )
  37. elseif (APPLE)
  38. file (GLOB SYS_C_FILES
  39. src/audio/coreaudio/*.c src/file/cocoa/*.m src/haptic/darwin/*.c src/joystick/darwin/*.c src/loadso/dlopen/*.c
  40. src/power/macosx/*.c src/thread/pthread/*.c src/timer/unix/*.c src/video/cocoa/*.m src/filesystem/cocoa/*.m
  41. )
  42. elseif (ANDROID)
  43. file (GLOB SYS_C_FILES
  44. src/audio/android/*.c src/core/android/*.c src/joystick/android/*.c src/loadso/dlopen/*.c src/power/android/*.c
  45. src/thread/pthread/*.c src/timer/unix/*.c src/video/android/*.c src/haptic/dummy/*.c src/filesystem/dummy/*.c
  46. )
  47. else ()
  48. # On Linux, make sure development libraries exist, and use their include file directories
  49. if (RPI)
  50. file (GLOB VIDEO_DRIVER_C_FILES src/video/raspberry/*.c src/core/linux/*.c)
  51. else ()
  52. find_package (OpenGL REQUIRED)
  53. include_directories (${OpenGL_INCLUDE_DIRS})
  54. find_package (X11 REQUIRED)
  55. if (NOT X11_Xrandr_FOUND)
  56. message (FATAL_ERROR "Could not find XRandR (libxrandr-dev)")
  57. endif ()
  58. include_directories (${X11_INCLUDE_DIRS})
  59. if (NOT DEFINED HAVE_CONST_XEXT_ADDDISPLAY)
  60. message (STATUS "Following tests check whether X11 library installed in this system uses _Xconst in below functions")
  61. message (STATUS "A failed test result simply means the installed X11 library does not use _Xconst")
  62. message (STATUS "It is OK to proceed to build Urho3D regardless of the test result")
  63. endif ()
  64. include (CheckCSourceCompiles)
  65. set (CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
  66. check_c_source_compiles ("
  67. #include <X11/Xlib.h>
  68. #include <X11/Xproto.h>
  69. #include <X11/extensions/Xext.h>
  70. #include <X11/extensions/extutil.h>
  71. extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
  72. int main(int argc, char **argv) {}" HAVE_CONST_XEXT_ADDDISPLAY)
  73. if (HAVE_CONST_XEXT_ADDDISPLAY)
  74. add_definitions (-DSDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY)
  75. endif ()
  76. check_c_source_compiles ("
  77. #include <X11/Xlibint.h>
  78. extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
  79. int main(int argc, char **argv) {}" HAVE_CONST_XDATA32)
  80. if (HAVE_CONST_XDATA32)
  81. add_definitions (-DSDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32)
  82. endif ()
  83. set (CMAKE_REQUIRED_LIBRARIES)
  84. file (GLOB VIDEO_DRIVER_C_FILES src/video/x11/*.c)
  85. endif ()
  86. find_package (ALSA REQUIRED)
  87. # todo: remove this fix when the minimum CMake version has been raised to higher than 2.8.7
  88. # There is a bug in older version of FindALSA.cmake module where it erroneously include 'alsa' directory component into the variable
  89. # For cross-compiling build to work correctly, this extra directory component must be removed
  90. if (ALSA_INCLUDE_DIRS MATCHES .*/alsa)
  91. get_filename_component (ALSA_INCLUDE_DIRS ${ALSA_INCLUDE_DIRS} PATH)
  92. endif ()
  93. # end todo
  94. include_directories (${ALSA_INCLUDE_DIRS})
  95. file (GLOB SYS_C_FILES
  96. src/audio/alsa/*.c src/audio/dma/*.c src/audio/dsp/*.c src/haptic/linux/*.c src/joystick/linux/*.c src/loadso/dlopen/*.c
  97. src/power/linux/*.c src/thread/pthread/*.c src/timer/unix/*.c src/filesystem/unix/*.c
  98. )
  99. set (SYS_C_FILES ${SYS_C_FILES} ${VIDEO_DRIVER_C_FILES})
  100. endif ()
  101. file (GLOB H_FILES include/*.h)
  102. # Define source files
  103. set_source_files_properties (${C_FILES} PROPERTIES LANGUAGE C)
  104. set_source_files_properties (${SYS_C_FILES} PROPERTIES LANGUAGE C)
  105. set (SOURCE_FILES ${C_FILES} ${SYS_C_FILES} ${H_FILES})
  106. add_library(SDL ${SOURCE_FILES})