blob: 5be176be74a89807812fa99b435e61b095ae51a0 [file] [log] [blame]
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -06001# The name of our project is "VULKAN". CMakeLists files in this project can
2# refer to the root source directory of the project as ${VULKAN_SOURCE_DIR} and
3# to the root binary directory of the project as ${VULKAN_BINARY_DIR}.
Chia-I Wuc3624592015-01-10 23:15:51 +08004cmake_minimum_required(VERSION 2.8.11)
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -06005project (VULKAN)
Courtney Goeltzenleuchter1d22ed82014-08-01 13:01:47 -06006# set (CMAKE_VERBOSE_MAKEFILE 1)
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -06007
Mark Lobodzinskib49b6e52015-11-26 10:59:58 -07008
9
David Pinedo0c083652015-07-09 12:44:38 -060010# The MAJOR number of the version we're building, used in naming
David Pinedo4bb0d302015-09-08 11:07:46 -060011# vulkan-<major>.dll (and other files).
David Pinedof2defe32016-01-06 16:34:27 -070012set(MAJOR "1")
David Pinedo0c083652015-07-09 12:44:38 -060013
Tony Barbour7ebd80c2016-02-25 15:44:10 -070014find_package(PythonInterp 3 REQUIRED)
Mark Lobodzinskie0204052015-12-15 09:25:29 -070015
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070016if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
Mark Lobodzinskib49b6e52015-11-26 10:59:58 -070017 add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
Mark Lobodzinskie0204052015-12-15 09:25:29 -070018 set(DisplayServer Win32)
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070019elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
20 add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
Mark Lobodzinskie0204052015-12-15 09:25:29 -070021 set(DisplayServer Android)
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070022elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080023 # TODO: Basic support is present for Xlib but is untested.
Jason Ekstranda5ebe8a2016-02-12 17:25:03 -080024 # Mir support is stubbed in but unimplemented and untested.
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080025 option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
26 option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" OFF)
27 option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" OFF)
28 option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" OFF)
29
Mark Lobodzinskie0204052015-12-15 09:25:29 -070030 set(DisplayServer Xcb)
31
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080032 if (BUILD_WSI_XCB_SUPPORT)
33 add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
34 endif()
Mark Lobodzinskie0204052015-12-15 09:25:29 -070035
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080036 if (BUILD_WSI_XLIB_SUPPORT)
37 add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
38 endif()
Mark Lobodzinskie0204052015-12-15 09:25:29 -070039
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080040 if (BUILD_WSI_WAYLAND_SUPPORT)
41 add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
42 endif()
Mark Lobodzinskie0204052015-12-15 09:25:29 -070043
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080044 if (BUILD_WSI_MIR_SUPPORT)
45 add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
46 endif()
Mark Lobodzinskifaa90812015-11-25 13:26:15 -070047else()
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070048 message(FATAL_ERROR "Unsupported Platform!")
Mark Lobodzinskifaa90812015-11-25 13:26:15 -070049endif()
50
Mark Lobodzinskie0204052015-12-15 09:25:29 -070051
52
53
54
Chia-I Wuc3624592015-01-10 23:15:51 +080055set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
56
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060057# Header file for CMake settings
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060058include_directories("${PROJECT_SOURCE_DIR}/include")
59
Tony Barbour89dc91c2015-12-16 14:57:33 -070060if(NOT WIN32)
61 include(FindPkgConfig)
62endif()
Chia-I Wu155be032014-08-02 09:14:28 +080063
Jon Ashburna0dffd62015-07-31 15:15:00 -060064set (CMAKE_INSTALL_PREFIX "")
65
Chia-I Wu084c8862015-02-17 09:55:34 -070066if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
Ian Elliott661dc372015-02-13 14:04:01 -070067 set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
Tony Barbourf4351602015-02-05 14:14:33 -070068 set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
Chia-I Wubba8fc02014-12-19 11:34:46 +080069 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
Adam Jackson77d5fd32015-06-23 15:33:48 -040070 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11")
Chia-I Wu19300602014-08-04 08:03:57 +080071 if (UNIX)
72 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
Chia-I Wu33ada632015-01-18 11:09:29 +080073 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
Chia-I Wu19300602014-08-04 08:03:57 +080074 endif()
75endif()
Chia-I Wu155be032014-08-02 09:14:28 +080076
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070077option(BUILD_LOADER "Build loader" ON)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070078option(BUILD_TESTS "Build tests" ON)
79option(BUILD_LAYERS "Build layers" ON)
80option(BUILD_DEMOS "Build demos" ON)
Antoine Labourd66cc922015-10-27 12:21:09 -070081option(BUILD_VKJSON "Build vkjson" ON)
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060082
Jon Ashburn7fa7e222016-02-02 12:08:10 -070083if (BUILD_TESTS)
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060084 # Hard code our glslang path for now
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070085 get_filename_component(GLSLANG_PREFIX ../glslang ABSOLUTE)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070086
87 if(NOT EXISTS ${GLSLANG_PREFIX})
88 message(FATAL_ERROR "Necessary glslang components do not exist: " ${GLSLANG_PREFIX})
89 endif()
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060090endif()
91
Tony Barbour500194c2015-05-21 11:07:47 -060092if(NOT WIN32)
Adam Jackson3869f412015-07-23 16:29:26 -040093 include(GNUInstallDirs)
James Jonesc28b0a12015-07-23 17:39:37 -070094 add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}")
95 add_definitions(-DDATADIR="${CMAKE_INSTALL_DATADIR}")
96 if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
Jon Ashburn86723b02015-07-31 15:47:59 -060097 elseif (CMAKE_INSTALL_PREFIX STREQUAL "")
James Jonesc28b0a12015-07-23 17:39:37 -070098 else()
99 add_definitions(-DLOCALPREFIX="${CMAKE_INSTALL_PREFIX}")
100 endif()
Tony Barbour500194c2015-05-21 11:07:47 -0600101 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Jon Ashburn1a97d6c2015-03-18 09:29:11 -0600102 set(PYTHON_CMD "python3")
103 endif()
104else()
Tony Barbour500194c2015-05-21 11:07:47 -0600105 set(PYTHON_CMD "py")
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -0600106endif()
107
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -0600108# loader: Generic VULKAN ICD loader
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -0600109# tests: VULKAN tests
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -0700110if(BUILD_LOADER)
111 add_subdirectory(loader)
112endif()
113
Tony Barboura05dbaa2015-07-09 17:31:46 -0600114if(BUILD_TESTS)
115 add_subdirectory(tests)
116endif()
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -0700117
118if(BUILD_LAYERS)
119 add_subdirectory(layers)
120endif()
121
122if(BUILD_DEMOS)
123 add_subdirectory(demos)
124endif()
125
Antoine Labourd66cc922015-10-27 12:21:09 -0700126if(BUILD_VKJSON)
127 add_subdirectory(libs/vkjson)
128endif()