CMakeLists.txt
changeset 11365 a9bd2625fa01
parent 11353 598839965877
child 11367 e8fc755a89e8
     1.1 --- a/CMakeLists.txt	Sun Aug 27 19:10:30 2017 -0700
     1.2 +++ b/CMakeLists.txt	Sun Aug 27 22:15:57 2017 -0400
     1.3 @@ -20,6 +20,7 @@
     1.4  include(CheckIncludeFiles)
     1.5  include(CheckIncludeFile)
     1.6  include(CheckSymbolExists)
     1.7 +include(CheckCSourceCompiles)
     1.8  include(CheckCSourceRuns)
     1.9  include(CheckCCompilerFlag)
    1.10  include(CheckTypeSize)
    1.11 @@ -324,9 +325,14 @@
    1.12  set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
    1.13  set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
    1.14  set_option(VIDEO_VIVANTE       "Use Vivante EGL video driver" ${UNIX_SYS})
    1.15 +dep_option(VIDEO_VULKAN        "Enable Vulkan surface creation" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
    1.16  set_option(VIDEO_KMSDRM        "Use KMS DRM video driver" ${UNIX_SYS})
    1.17  dep_option(KMSDRM_SHARED       "Dynamically load KMS DRM support" ON "VIDEO_KMSDRM" OFF)
    1.18  
    1.19 +if(VIDEO_VULKAN)
    1.20 +  set(VULKAN_SDK $ENV{VULKAN_SDK} CACHE PATH "Location of Vulkan headers' grandparent, e.g. /foo when headers are in /foo/include/vulkan.")
    1.21 +endif()
    1.22 +
    1.23  # TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
    1.24  # The options below are for compatibility to configure's default behaviour.
    1.25  set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
    1.26 @@ -855,6 +861,22 @@
    1.27        find_library(OpenGLES2_LIBRARY GLESv2)
    1.28        list(APPEND EXTRA_LIBS ${OpenGLES1_LIBRARY} ${OpenGLES2_LIBRARY})
    1.29      endif()
    1.30 +
    1.31 +    CHECK_C_SOURCE_COMPILES("
    1.32 +    #if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
    1.33 +    #error Vulkan doesn't work on this configuration
    1.34 +    #endif
    1.35 +    int main()
    1.36 +    {
    1.37 +        return 0;
    1.38 +    }
    1.39 +    " VULKAN_PASSED_ANDROID_CHECKS)
    1.40 +    if(NOT VULKAN_PASSED_ANDROID_CHECKS)
    1.41 +      set(VIDEO_VULKAN OFF)
    1.42 +      message(STATUS "Vulkan doesn't work on this configuration")
    1.43 +    else()
    1.44 +      CheckVulkanHeaders()
    1.45 +    endif()
    1.46    endif()
    1.47  
    1.48    CheckPTHREAD()
    1.49 @@ -1020,6 +1042,7 @@
    1.50  
    1.51      check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)
    1.52  
    1.53 +    CheckVulkanHeaders()
    1.54    endif()
    1.55  
    1.56    if(INPUT_TSLIB)
    1.57 @@ -1278,6 +1301,8 @@
    1.58        set(SDL_VIDEO_RENDER_OGL_ES2 1)
    1.59        set(HAVE_VIDEO_OPENGLES TRUE)
    1.60      endif()
    1.61 +
    1.62 +    CheckVulkanHeaders()
    1.63    endif()
    1.64  
    1.65    if(SDL_JOYSTICK)
    1.66 @@ -1419,6 +1444,13 @@
    1.67    endif()
    1.68  
    1.69    # Actually load the frameworks at the end so we don't duplicate include.
    1.70 +  if (VIDEO_VULKAN)
    1.71 +    CheckVulkanHeaders()
    1.72 +    if(HAVE_VULKAN_H)
    1.73 +      find_library(QUARTZCORE QuartzCore)
    1.74 +      list(APPEND EXTRA_LIBS ${QUARTZCORE})
    1.75 +    endif()
    1.76 +  endif()
    1.77    if(SDL_FRAMEWORK_COREVIDEO)
    1.78      find_library(COREVIDEO CoreVideo)
    1.79      list(APPEND EXTRA_LIBS ${COREVIDEO})
    1.80 @@ -1498,6 +1530,10 @@
    1.81    CheckPTHREAD()
    1.82  endif()
    1.83  
    1.84 +if(VIDEO_VULKAN AND HAVE_VULKAN_H AND (NOT APPLE OR QUARTZCORE))
    1.85 +  set(SDL_VIDEO_VULKAN_SURFACE 1)
    1.86 +endif()
    1.87 +
    1.88  # Dummies
    1.89  # configure.in does it differently:
    1.90  # if not have X