Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 1 | # 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 Wu | c362459 | 2015-01-10 23:15:51 +0800 | [diff] [blame] | 4 | cmake_minimum_required(VERSION 2.8.11) |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 5 | project (VULKAN) |
Courtney Goeltzenleuchter | 1d22ed8 | 2014-08-01 13:01:47 -0600 | [diff] [blame] | 6 | # set (CMAKE_VERBOSE_MAKEFILE 1) |
Courtney Goeltzenleuchter | 2220a3b | 2014-07-24 08:36:15 -0600 | [diff] [blame] | 7 | |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 8 | |
| 9 | |
David Pinedo | 0c08365 | 2015-07-09 12:44:38 -0600 | [diff] [blame] | 10 | # The MAJOR number of the version we're building, used in naming |
David Pinedo | 4bb0d30 | 2015-09-08 11:07:46 -0600 | [diff] [blame] | 11 | # vulkan-<major>.dll (and other files). |
David Pinedo | f2defe3 | 2016-01-06 16:34:27 -0700 | [diff] [blame] | 12 | set(MAJOR "1") |
David Pinedo | 0c08365 | 2015-07-09 12:44:38 -0600 | [diff] [blame] | 13 | |
Mark Lobodzinski | e020405 | 2015-12-15 09:25:29 -0700 | [diff] [blame] | 14 | |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 15 | if(CMAKE_SYSTEM_NAME STREQUAL "Windows") |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 16 | add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN) |
Mark Lobodzinski | e020405 | 2015-12-15 09:25:29 -0700 | [diff] [blame] | 17 | set(DisplayServer Win32) |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 18 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 19 | add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) |
Mark Lobodzinski | e020405 | 2015-12-15 09:25:29 -0700 | [diff] [blame] | 20 | set(DisplayServer Android) |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 21 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
Mark Lobodzinski | e020405 | 2015-12-15 09:25:29 -0700 | [diff] [blame] | 22 | add_definitions(-DVK_USE_PLATFORM_XCB_KHR) |
| 23 | set(DisplayServer Xcb) |
| 24 | |
| 25 | # TODO: Basic support is present for Xlib but is untested. |
| 26 | # Wayland/Mir support is stubbed in but unimplemented and untested. |
| 27 | |
| 28 | # add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) |
| 29 | # set(DisplayServer Xlib) |
| 30 | |
| 31 | # add_definitions(-DVK_USE_PLATFORM_MIR_KHR) |
| 32 | # set(DisplayServer Mir) |
| 33 | |
| 34 | # add_definitions(-DVK_USEPLATFORM_WAYLAND_KHR) |
| 35 | # set(DisplayServer Wayland) |
| 36 | |
Mark Lobodzinski | faa9081 | 2015-11-25 13:26:15 -0700 | [diff] [blame] | 37 | else() |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 38 | message(FATAL_ERROR "Unsupported Platform!") |
Mark Lobodzinski | faa9081 | 2015-11-25 13:26:15 -0700 | [diff] [blame] | 39 | endif() |
| 40 | |
Mark Lobodzinski | e020405 | 2015-12-15 09:25:29 -0700 | [diff] [blame] | 41 | |
| 42 | |
| 43 | |
| 44 | |
Chia-I Wu | c362459 | 2015-01-10 23:15:51 +0800 | [diff] [blame] | 45 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") |
| 46 | |
Courtney Goeltzenleuchter | 2220a3b | 2014-07-24 08:36:15 -0600 | [diff] [blame] | 47 | # Header file for CMake settings |
Courtney Goeltzenleuchter | 2220a3b | 2014-07-24 08:36:15 -0600 | [diff] [blame] | 48 | include_directories("${PROJECT_SOURCE_DIR}/include") |
| 49 | |
Tony Barbour | 89dc91c | 2015-12-16 14:57:33 -0700 | [diff] [blame] | 50 | if(NOT WIN32) |
| 51 | include(FindPkgConfig) |
| 52 | endif() |
Chia-I Wu | 155be03 | 2014-08-02 09:14:28 +0800 | [diff] [blame] | 53 | |
Jon Ashburn | a0dffd6 | 2015-07-31 15:15:00 -0600 | [diff] [blame] | 54 | set (CMAKE_INSTALL_PREFIX "") |
| 55 | |
Chia-I Wu | 084c886 | 2015-02-17 09:55:34 -0700 | [diff] [blame] | 56 | if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") |
Ian Elliott | 661dc37 | 2015-02-13 14:04:01 -0700 | [diff] [blame] | 57 | set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers") |
Tony Barbour | f435160 | 2015-02-05 14:14:33 -0700 | [diff] [blame] | 58 | set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp") |
Chia-I Wu | bba8fc0 | 2014-12-19 11:34:46 +0800 | [diff] [blame] | 59 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}") |
Adam Jackson | 77d5fd3 | 2015-06-23 15:33:48 -0400 | [diff] [blame] | 60 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11") |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 61 | if (UNIX) |
| 62 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") |
Chia-I Wu | 33ada63 | 2015-01-18 11:09:29 +0800 | [diff] [blame] | 63 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 64 | endif() |
| 65 | endif() |
Chia-I Wu | 155be03 | 2014-08-02 09:14:28 +0800 | [diff] [blame] | 66 | |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 67 | option(BUILD_LOADER "Build loader" ON) |
Courtney Goeltzenleuchter | e250a32 | 2015-10-14 17:00:19 -0600 | [diff] [blame] | 68 | if(WIN32) |
| 69 | option(BUILD_ICD "Build LunarG intel icd" OFF) |
| 70 | else() |
| 71 | option(BUILD_ICD "Build LunarG intel icd" ON) |
| 72 | endif() |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 73 | option(BUILD_TESTS "Build tests" ON) |
| 74 | option(BUILD_LAYERS "Build layers" ON) |
| 75 | option(BUILD_DEMOS "Build demos" ON) |
Mark Lobodzinski | b8ba300 | 2015-11-25 16:13:36 -0700 | [diff] [blame] | 76 | option(BUILD_VKTRACE "Build VkTrace" ON) |
Courtney Goeltzenleuchter | a43bbd8 | 2014-10-03 15:34:53 -0600 | [diff] [blame] | 77 | |
Courtney Goeltzenleuchter | 5df372f | 2015-10-14 17:00:44 -0600 | [diff] [blame] | 78 | if (BUILD_ICD OR BUILD_TESTS) |
| 79 | # Hard code our glslang path for now |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 80 | get_filename_component(GLSLANG_PREFIX ../glslang ABSOLUTE) |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 81 | |
| 82 | if(NOT EXISTS ${GLSLANG_PREFIX}) |
| 83 | message(FATAL_ERROR "Necessary glslang components do not exist: " ${GLSLANG_PREFIX}) |
| 84 | endif() |
Courtney Goeltzenleuchter | 5df372f | 2015-10-14 17:00:44 -0600 | [diff] [blame] | 85 | endif() |
| 86 | |
| 87 | if (BUILD_ICD) |
| 88 | # Hard code our LunarGLASS path for now |
| 89 | get_filename_component(LUNARGLASS_PREFIX ../LunarGLASS ABSOLUTE) |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 90 | |
| 91 | if(NOT EXISTS ${LUNARGLASS_PREFIX}) |
| 92 | message(FATAL_ERROR "Necessary LunarGLASS components do not exist: " ${LUNARGLASS_PREFIX}) |
| 93 | endif() |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 94 | endif() |
Courtney Goeltzenleuchter | a43bbd8 | 2014-10-03 15:34:53 -0600 | [diff] [blame] | 95 | |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 96 | if(NOT WIN32) |
Adam Jackson | 3869f41 | 2015-07-23 16:29:26 -0400 | [diff] [blame] | 97 | include(GNUInstallDirs) |
James Jones | c28b0a1 | 2015-07-23 17:39:37 -0700 | [diff] [blame] | 98 | add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}") |
| 99 | add_definitions(-DDATADIR="${CMAKE_INSTALL_DATADIR}") |
| 100 | if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") |
Jon Ashburn | 86723b0 | 2015-07-31 15:47:59 -0600 | [diff] [blame] | 101 | elseif (CMAKE_INSTALL_PREFIX STREQUAL "") |
James Jones | c28b0a1 | 2015-07-23 17:39:37 -0700 | [diff] [blame] | 102 | else() |
| 103 | add_definitions(-DLOCALPREFIX="${CMAKE_INSTALL_PREFIX}") |
| 104 | endif() |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 105 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
Jon Ashburn | 1a97d6c | 2015-03-18 09:29:11 -0600 | [diff] [blame] | 106 | set(PYTHON_CMD "python3") |
| 107 | endif() |
| 108 | else() |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 109 | set(PYTHON_CMD "py") |
Courtney Goeltzenleuchter | a43bbd8 | 2014-10-03 15:34:53 -0600 | [diff] [blame] | 110 | endif() |
| 111 | |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 112 | # loader: Generic VULKAN ICD loader |
| 113 | # icd: Device dependent (DD) VULKAN components |
| 114 | # tests: VULKAN tests |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 115 | if(BUILD_LOADER) |
| 116 | add_subdirectory(loader) |
| 117 | endif() |
| 118 | |
| 119 | if(BUILD_ICD) |
| 120 | add_subdirectory(icd) |
| 121 | endif() |
| 122 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 123 | if(BUILD_TESTS) |
| 124 | add_subdirectory(tests) |
| 125 | endif() |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 126 | |
| 127 | if(BUILD_LAYERS) |
| 128 | add_subdirectory(layers) |
| 129 | endif() |
| 130 | |
| 131 | if(BUILD_DEMOS) |
| 132 | add_subdirectory(demos) |
| 133 | endif() |
| 134 | |
| 135 | if(BUILD_VKTRACE) |
| 136 | add_subdirectory(vktrace) |
| 137 | endif() |