blob: 120bf39a48288268ac02f9827963376edfefd84c [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
Mark Lobodzinskie0204052015-12-15 09:25:29 -070014
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070015if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
Mark Lobodzinskib49b6e52015-11-26 10:59:58 -070016 add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
Mark Lobodzinskie0204052015-12-15 09:25:29 -070017 set(DisplayServer Win32)
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070018elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
19 add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
Mark Lobodzinskie0204052015-12-15 09:25:29 -070020 set(DisplayServer Android)
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070021elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080022 # TODO: Basic support is present for Xlib but is untested.
23 # Wayland/Mir support is stubbed in but unimplemented and untested.
24 option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
25 option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" OFF)
26 option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" OFF)
27 option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" OFF)
28
Mark Lobodzinskie0204052015-12-15 09:25:29 -070029 set(DisplayServer Xcb)
30
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080031 if (BUILD_WSI_XCB_SUPPORT)
32 add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
33 endif()
Mark Lobodzinskie0204052015-12-15 09:25:29 -070034
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080035 if (BUILD_WSI_XLIB_SUPPORT)
36 add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
37 endif()
Mark Lobodzinskie0204052015-12-15 09:25:29 -070038
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080039 if (BUILD_WSI_WAYLAND_SUPPORT)
40 add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
41 endif()
Mark Lobodzinskie0204052015-12-15 09:25:29 -070042
Jason Ekstrand5cd6a912016-02-20 08:13:28 -080043 if (BUILD_WSI_MIR_SUPPORT)
44 add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
45 endif()
Mark Lobodzinskifaa90812015-11-25 13:26:15 -070046else()
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070047 message(FATAL_ERROR "Unsupported Platform!")
Mark Lobodzinskifaa90812015-11-25 13:26:15 -070048endif()
49
Mark Lobodzinskie0204052015-12-15 09:25:29 -070050
51
52
53
Chia-I Wuc3624592015-01-10 23:15:51 +080054set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
55
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060056# Header file for CMake settings
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060057include_directories("${PROJECT_SOURCE_DIR}/include")
58
Tony Barbour89dc91c2015-12-16 14:57:33 -070059if(NOT WIN32)
60 include(FindPkgConfig)
61endif()
Chia-I Wu155be032014-08-02 09:14:28 +080062
Jon Ashburna0dffd62015-07-31 15:15:00 -060063set (CMAKE_INSTALL_PREFIX "")
64
Chia-I Wu084c8862015-02-17 09:55:34 -070065if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
Ian Elliott661dc372015-02-13 14:04:01 -070066 set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
Tony Barbourf4351602015-02-05 14:14:33 -070067 set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
Chia-I Wubba8fc02014-12-19 11:34:46 +080068 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
Adam Jackson77d5fd32015-06-23 15:33:48 -040069 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11")
Chia-I Wu19300602014-08-04 08:03:57 +080070 if (UNIX)
71 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
Chia-I Wu33ada632015-01-18 11:09:29 +080072 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
Chia-I Wu19300602014-08-04 08:03:57 +080073 endif()
74endif()
Chia-I Wu155be032014-08-02 09:14:28 +080075
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070076option(BUILD_LOADER "Build loader" ON)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070077option(BUILD_TESTS "Build tests" ON)
78option(BUILD_LAYERS "Build layers" ON)
79option(BUILD_DEMOS "Build demos" ON)
Antoine Labourd66cc922015-10-27 12:21:09 -070080option(BUILD_VKJSON "Build vkjson" ON)
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060081
Jon Ashburn7fa7e222016-02-02 12:08:10 -070082if (BUILD_TESTS)
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060083 # Hard code our glslang path for now
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070084 get_filename_component(GLSLANG_PREFIX ../glslang ABSOLUTE)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070085
86 if(NOT EXISTS ${GLSLANG_PREFIX})
87 message(FATAL_ERROR "Necessary glslang components do not exist: " ${GLSLANG_PREFIX})
88 endif()
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060089endif()
90
Tony Barbour500194c2015-05-21 11:07:47 -060091if(NOT WIN32)
Adam Jackson3869f412015-07-23 16:29:26 -040092 include(GNUInstallDirs)
James Jonesc28b0a12015-07-23 17:39:37 -070093 add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}")
94 add_definitions(-DDATADIR="${CMAKE_INSTALL_DATADIR}")
95 if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
Jon Ashburn86723b02015-07-31 15:47:59 -060096 elseif (CMAKE_INSTALL_PREFIX STREQUAL "")
James Jonesc28b0a12015-07-23 17:39:37 -070097 else()
98 add_definitions(-DLOCALPREFIX="${CMAKE_INSTALL_PREFIX}")
99 endif()
Tony Barbour500194c2015-05-21 11:07:47 -0600100 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Jon Ashburn1a97d6c2015-03-18 09:29:11 -0600101 set(PYTHON_CMD "python3")
102 endif()
103else()
Tony Barbour500194c2015-05-21 11:07:47 -0600104 set(PYTHON_CMD "py")
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -0600105endif()
106
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -0600107# loader: Generic VULKAN ICD loader
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -0600108# tests: VULKAN tests
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -0700109if(BUILD_LOADER)
110 add_subdirectory(loader)
111endif()
112
Tony Barboura05dbaa2015-07-09 17:31:46 -0600113if(BUILD_TESTS)
114 add_subdirectory(tests)
115endif()
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -0700116
117if(BUILD_LAYERS)
118 add_subdirectory(layers)
119endif()
120
121if(BUILD_DEMOS)
122 add_subdirectory(demos)
123endif()
124
Antoine Labourd66cc922015-10-27 12:21:09 -0700125if(BUILD_VKJSON)
126 add_subdirectory(libs/vkjson)
127endif()