2015-04-14 20:55:44 +00:00
|
|
|
# The name of our project is "VULKAN". CMakeLists files in this project can
|
|
|
|
# refer to the root source directory of the project as ${VULKAN_SOURCE_DIR} and
|
|
|
|
# to the root binary directory of the project as ${VULKAN_BINARY_DIR}.
|
2015-01-10 15:15:51 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.11)
|
2015-04-14 20:55:44 +00:00
|
|
|
project (VULKAN)
|
2014-08-01 19:01:47 +00:00
|
|
|
# set (CMAKE_VERBOSE_MAKEFILE 1)
|
2014-07-24 14:36:15 +00:00
|
|
|
|
2015-07-09 18:44:38 +00:00
|
|
|
# The MAJOR number of the version we're building, used in naming
|
2015-09-08 17:07:46 +00:00
|
|
|
# vulkan-<major>.dll (and other files).
|
2016-01-06 23:34:27 +00:00
|
|
|
set(MAJOR "1")
|
2015-07-09 18:44:38 +00:00
|
|
|
|
2016-02-25 22:44:10 +00:00
|
|
|
find_package(PythonInterp 3 REQUIRED)
|
2015-12-15 16:25:29 +00:00
|
|
|
|
2015-12-10 23:25:21 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
2015-11-26 17:59:58 +00:00
|
|
|
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
|
2015-12-15 16:25:29 +00:00
|
|
|
set(DisplayServer Win32)
|
2015-12-10 23:25:21 +00:00
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
|
|
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
|
2015-12-15 16:25:29 +00:00
|
|
|
set(DisplayServer Android)
|
2015-12-10 23:25:21 +00:00
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2016-02-20 16:13:28 +00:00
|
|
|
# TODO: Basic support is present for Xlib but is untested.
|
2016-02-13 01:25:03 +00:00
|
|
|
# Mir support is stubbed in but unimplemented and untested.
|
2016-02-20 16:13:28 +00:00
|
|
|
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
|
2016-03-31 19:21:02 +00:00
|
|
|
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" OFF)
|
2016-02-20 16:13:28 +00:00
|
|
|
option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" OFF)
|
|
|
|
option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" OFF)
|
2015-12-15 16:25:29 +00:00
|
|
|
|
2016-02-20 16:13:28 +00:00
|
|
|
if (BUILD_WSI_XCB_SUPPORT)
|
|
|
|
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
|
2016-02-22 11:32:17 +00:00
|
|
|
set(DisplayServer Xcb)
|
2016-02-20 16:13:28 +00:00
|
|
|
endif()
|
2015-12-15 16:25:29 +00:00
|
|
|
|
2016-02-20 16:13:28 +00:00
|
|
|
if (BUILD_WSI_XLIB_SUPPORT)
|
|
|
|
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
|
2016-03-08 15:07:13 +00:00
|
|
|
set(DisplayServer Xlib)
|
2016-02-20 16:13:28 +00:00
|
|
|
endif()
|
2015-12-15 16:25:29 +00:00
|
|
|
|
2016-02-20 16:13:28 +00:00
|
|
|
if (BUILD_WSI_WAYLAND_SUPPORT)
|
|
|
|
add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
|
2016-02-22 11:32:17 +00:00
|
|
|
set(DisplayServer Wayland)
|
2016-02-20 16:13:28 +00:00
|
|
|
endif()
|
2015-12-15 16:25:29 +00:00
|
|
|
|
2016-02-20 16:13:28 +00:00
|
|
|
if (BUILD_WSI_MIR_SUPPORT)
|
|
|
|
add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
|
2016-02-22 11:32:17 +00:00
|
|
|
set(DisplayServer Mir)
|
2016-02-20 16:13:28 +00:00
|
|
|
endif()
|
2015-11-25 20:26:15 +00:00
|
|
|
else()
|
2015-12-10 23:25:21 +00:00
|
|
|
message(FATAL_ERROR "Unsupported Platform!")
|
2015-11-25 20:26:15 +00:00
|
|
|
endif()
|
|
|
|
|
2015-01-10 15:15:51 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
|
2014-07-24 14:36:15 +00:00
|
|
|
# Header file for CMake settings
|
|
|
|
include_directories("${PROJECT_SOURCE_DIR}/include")
|
|
|
|
|
2015-12-16 21:57:33 +00:00
|
|
|
if(NOT WIN32)
|
|
|
|
include(FindPkgConfig)
|
|
|
|
endif()
|
2014-08-02 01:14:28 +00:00
|
|
|
|
2015-07-31 21:15:00 +00:00
|
|
|
set (CMAKE_INSTALL_PREFIX "")
|
|
|
|
|
2015-02-17 16:55:34 +00:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2015-02-13 21:04:01 +00:00
|
|
|
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
|
2015-02-05 21:14:33 +00:00
|
|
|
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
|
2014-12-19 03:34:46 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
|
2015-06-23 19:33:48 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11")
|
2014-08-04 00:03:57 +00:00
|
|
|
if (UNIX)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
|
2015-01-18 03:09:29 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
2014-08-04 00:03:57 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2014-08-02 01:14:28 +00:00
|
|
|
|
2016-03-15 21:39:08 +00:00
|
|
|
if(NOT WIN32)
|
|
|
|
find_package(XCB REQUIRED)
|
|
|
|
set (BUILDTGT_DIR build)
|
|
|
|
set (BINDATA_DIR Bin)
|
|
|
|
set (LIBSOURCE_DIR Lib)
|
|
|
|
else()
|
|
|
|
# For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory.
|
|
|
|
# 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the
|
|
|
|
# appropriate data at build time.
|
|
|
|
if (CMAKE_CL_64)
|
|
|
|
set (BUILDTGT_DIR build)
|
|
|
|
set (BINDATA_DIR Bin)
|
|
|
|
set (LIBSOURCE_DIR Lib)
|
|
|
|
else()
|
|
|
|
set (BUILDTGT_DIR build32)
|
|
|
|
set (BINDATA_DIR Bin32)
|
|
|
|
set (LIBSOURCE_DIR Lib32)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-10-10 15:43:07 +00:00
|
|
|
option(BUILD_LOADER "Build loader" ON)
|
|
|
|
option(BUILD_TESTS "Build tests" ON)
|
|
|
|
option(BUILD_LAYERS "Build layers" ON)
|
|
|
|
option(BUILD_DEMOS "Build demos" ON)
|
2015-10-27 19:21:09 +00:00
|
|
|
option(BUILD_VKJSON "Build vkjson" ON)
|
2015-10-10 15:43:07 +00:00
|
|
|
|
2016-03-15 21:39:08 +00:00
|
|
|
find_program(GLSLANG_VALIDATOR NAMES glslangValidator
|
|
|
|
HINTS "${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/install/bin"
|
|
|
|
"${PROJECT_SOURCE_DIR}/../${BINDATA_DIR}" )
|
|
|
|
|
|
|
|
find_path(GLSLANG_SPIRV_INCLUDE_DIR SPIRV/spirv.hpp HINTS "${CMAKE_SOURCE_DIR}/../glslang" DOC "Path to SPIRV/spirv.hpp")
|
|
|
|
find_path(SPIRV_TOOLS_INCLUDE_DIR spirv-tools/libspirv.h HINTS "${CMAKE_SOURCE_DIR}/../spirv-tools/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../source/spirv-tools/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../spirv-tools/external/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../source/spirv-tools/external/include"
|
|
|
|
DOC "Path to spirv-tools/libspirv.h")
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set (GLSLANG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/Release"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Release"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/OGLCompilersDLL/Release"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/SPIRV/Release" )
|
2016-04-01 20:20:14 +00:00
|
|
|
set (SPIRV_TOOLS_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/${BUILDTGT_DIR}/source/Release")
|
2016-03-15 21:39:08 +00:00
|
|
|
else()
|
|
|
|
set (GLSLANG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../glslang/build/install/lib" "${CMAKE_SOURCE_DIR}/../x86_64/lib/glslang" )
|
2016-04-01 20:20:14 +00:00
|
|
|
set (SPIRV_TOOLS_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/build/source" "${CMAKE_SOURCE_DIR}/../x86_64/lib/spirv-tools" )
|
2016-03-15 21:39:08 +00:00
|
|
|
endif()
|
2015-10-10 15:43:07 +00:00
|
|
|
|
2016-03-15 21:39:08 +00:00
|
|
|
find_library(GLSLANG_LIB NAMES glslang
|
|
|
|
HINTS ${GLSLANG_SEARCH_PATH} )
|
|
|
|
|
|
|
|
find_library(OGLCompiler_LIB NAMES OGLCompiler
|
|
|
|
HINTS ${GLSLANG_SEARCH_PATH} )
|
|
|
|
|
|
|
|
find_library(OSDependent_LIB NAMES OSDependent
|
|
|
|
HINTS ${GLSLANG_SEARCH_PATH} )
|
|
|
|
|
|
|
|
find_library(SPIRV_LIB NAMES SPIRV
|
|
|
|
HINTS ${GLSLANG_SEARCH_PATH} )
|
|
|
|
|
|
|
|
find_library(SPIRV_TOOLS_LIB NAMES SPIRV-Tools
|
|
|
|
HINTS ${SPIRV_TOOLS_SEARCH_PATH} )
|
|
|
|
|
|
|
|
# On Windows, we must pair Debug and Release appropriately
|
|
|
|
if (WIN32)
|
|
|
|
set (GLSLANG_DEBUG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/Debug"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Debug"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/OGLCompilersDLL/Debug"
|
|
|
|
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/SPIRV/Debug")
|
2016-04-01 20:20:14 +00:00
|
|
|
set (SPIRV_TOOLS_DEBUG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/${BUILDTGT_DIR}/source/Debug")
|
2016-03-15 21:39:08 +00:00
|
|
|
|
|
|
|
add_library(glslang STATIC IMPORTED)
|
|
|
|
add_library(OGLCompiler STATIC IMPORTED)
|
|
|
|
add_library(OSDependent STATIC IMPORTED)
|
|
|
|
add_library(SPIRV STATIC IMPORTED)
|
|
|
|
add_library(Loader STATIC IMPORTED)
|
|
|
|
add_library(SPIRV-Tools STATIC IMPORTED)
|
|
|
|
|
|
|
|
find_library(GLSLANG_DLIB NAMES glslang
|
|
|
|
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
|
|
|
|
find_library(OGLCompiler_DLIB NAMES OGLCompiler
|
|
|
|
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
|
|
|
|
find_library(OSDependent_DLIB NAMES OSDependent
|
|
|
|
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
|
|
|
|
find_library(SPIRV_DLIB NAMES SPIRV
|
|
|
|
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
|
|
|
|
find_library(SPIRV_TOOLS_DLIB NAMES SPIRV-Tools
|
|
|
|
HINTS ${SPIRV_TOOLS_DEBUG_SEARCH_PATH} )
|
|
|
|
|
|
|
|
set_target_properties(glslang PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${GLSLANG_LIB}"
|
|
|
|
IMPORTED_LOCATION_DEBUG "${GLSLANG_DLIB}")
|
|
|
|
set_target_properties(OGLCompiler PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${OGLCompiler_LIB}"
|
|
|
|
IMPORTED_LOCATION_DEBUG "${OGLCompiler_DLIB}")
|
|
|
|
set_target_properties(OSDependent PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${OSDependent_LIB}"
|
|
|
|
IMPORTED_LOCATION_DEBUG "${OSDependent_DLIB}")
|
|
|
|
set_target_properties(SPIRV PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${SPIRV_LIB}"
|
|
|
|
IMPORTED_LOCATION_DEBUG "${SPIRV_DLIB}")
|
|
|
|
set_target_properties(SPIRV-Tools PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${SPIRV_TOOLS_LIB}"
|
|
|
|
IMPORTED_LOCATION_DEBUG "${SPIRV_TOOLS_DLIB}")
|
|
|
|
|
|
|
|
set (GLSLANG_LIBRARIES glslang OGLCompiler OSDependent SPIRV)
|
|
|
|
set (SPIRV_TOOLS_LIBRARIES SPIRV-Tools)
|
|
|
|
else ()
|
|
|
|
set (GLSLANG_LIBRARIES ${GLSLANG_LIB} ${OGLCompiler_LIB} ${OSDependent_LIB} ${SPIRV_LIB})
|
|
|
|
set (SPIRV_TOOLS_LIBRARIES ${SPIRV_TOOLS_LIB})
|
2015-10-14 23:00:44 +00:00
|
|
|
endif()
|
|
|
|
|
2016-03-01 23:40:39 +00:00
|
|
|
set (PYTHON_CMD ${PYTHON_EXECUTABLE})
|
|
|
|
|
2015-05-21 17:07:47 +00:00
|
|
|
if(NOT WIN32)
|
2015-07-23 20:29:26 +00:00
|
|
|
include(GNUInstallDirs)
|
2015-07-24 00:39:37 +00:00
|
|
|
add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}")
|
|
|
|
add_definitions(-DDATADIR="${CMAKE_INSTALL_DATADIR}")
|
|
|
|
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
2015-07-31 21:47:59 +00:00
|
|
|
elseif (CMAKE_INSTALL_PREFIX STREQUAL "")
|
2015-07-24 00:39:37 +00:00
|
|
|
else()
|
|
|
|
add_definitions(-DLOCALPREFIX="${CMAKE_INSTALL_PREFIX}")
|
|
|
|
endif()
|
2014-10-03 21:34:53 +00:00
|
|
|
endif()
|
|
|
|
|
2015-04-14 20:55:44 +00:00
|
|
|
# loader: Generic VULKAN ICD loader
|
|
|
|
# tests: VULKAN tests
|
2015-10-10 15:43:07 +00:00
|
|
|
if(BUILD_LOADER)
|
|
|
|
add_subdirectory(loader)
|
|
|
|
endif()
|
|
|
|
|
2015-07-09 23:31:46 +00:00
|
|
|
if(BUILD_TESTS)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
2015-10-10 15:43:07 +00:00
|
|
|
|
|
|
|
if(BUILD_LAYERS)
|
|
|
|
add_subdirectory(layers)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_DEMOS)
|
|
|
|
add_subdirectory(demos)
|
|
|
|
endif()
|
|
|
|
|
2015-10-27 19:21:09 +00:00
|
|
|
if(BUILD_VKJSON)
|
|
|
|
add_subdirectory(libs/vkjson)
|
|
|
|
endif()
|