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 | 1d98da3 | 2015-11-16 17:01:29 -0700 | [diff] [blame] | 12 | set(MAJOR "0") |
David Pinedo | 0c08365 | 2015-07-09 12:44:38 -0600 | [diff] [blame] | 13 | |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame^] | 14 | if(CMAKE_SYSTEM_NAME STREQUAL "Windows") |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 15 | add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN) |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame^] | 16 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 17 | add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) |
| 18 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 19 | add_definitions(-DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XLIB_KHR) |
| 20 | # TODO: Add support to SDK for Wayland and Mir |
| 21 | # add_definitions(-DVK_USE_PLATFORM_MIR_KHR -DVK_USEPLATFORM_WAYLAND_KHR) |
Mark Lobodzinski | faa9081 | 2015-11-25 13:26:15 -0700 | [diff] [blame] | 22 | else() |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame^] | 23 | message(FATAL_ERROR "Unsupported Platform!") |
Mark Lobodzinski | faa9081 | 2015-11-25 13:26:15 -0700 | [diff] [blame] | 24 | endif() |
| 25 | |
Chia-I Wu | c362459 | 2015-01-10 23:15:51 +0800 | [diff] [blame] | 26 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") |
| 27 | |
Courtney Goeltzenleuchter | 2220a3b | 2014-07-24 08:36:15 -0600 | [diff] [blame] | 28 | # Header file for CMake settings |
Courtney Goeltzenleuchter | 2220a3b | 2014-07-24 08:36:15 -0600 | [diff] [blame] | 29 | include_directories("${PROJECT_SOURCE_DIR}/include") |
| 30 | |
Chia-I Wu | 155be03 | 2014-08-02 09:14:28 +0800 | [diff] [blame] | 31 | include(FindPkgConfig) |
Chia-I Wu | 155be03 | 2014-08-02 09:14:28 +0800 | [diff] [blame] | 32 | |
Jon Ashburn | a0dffd6 | 2015-07-31 15:15:00 -0600 | [diff] [blame] | 33 | set (CMAKE_INSTALL_PREFIX "") |
| 34 | |
Chia-I Wu | 084c886 | 2015-02-17 09:55:34 -0700 | [diff] [blame] | 35 | if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") |
Ian Elliott | 661dc37 | 2015-02-13 14:04:01 -0700 | [diff] [blame] | 36 | 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] | 37 | 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] | 38 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}") |
Adam Jackson | 77d5fd3 | 2015-06-23 15:33:48 -0400 | [diff] [blame] | 39 | 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] | 40 | if (UNIX) |
| 41 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") |
Chia-I Wu | 33ada63 | 2015-01-18 11:09:29 +0800 | [diff] [blame] | 42 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 43 | endif() |
| 44 | endif() |
Chia-I Wu | 155be03 | 2014-08-02 09:14:28 +0800 | [diff] [blame] | 45 | |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 46 | option(BUILD_LOADER "Build loader" ON) |
Courtney Goeltzenleuchter | e250a32 | 2015-10-14 17:00:19 -0600 | [diff] [blame] | 47 | if(WIN32) |
| 48 | option(BUILD_ICD "Build LunarG intel icd" OFF) |
| 49 | else() |
| 50 | option(BUILD_ICD "Build LunarG intel icd" ON) |
| 51 | endif() |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 52 | option(BUILD_TESTS "Build tests" ON) |
| 53 | option(BUILD_LAYERS "Build layers" ON) |
| 54 | option(BUILD_DEMOS "Build demos" ON) |
Mark Lobodzinski | b8ba300 | 2015-11-25 16:13:36 -0700 | [diff] [blame] | 55 | option(BUILD_VKTRACE "Build VkTrace" ON) |
Courtney Goeltzenleuchter | a43bbd8 | 2014-10-03 15:34:53 -0600 | [diff] [blame] | 56 | |
Courtney Goeltzenleuchter | 5df372f | 2015-10-14 17:00:44 -0600 | [diff] [blame] | 57 | if (BUILD_ICD OR BUILD_TESTS) |
| 58 | # Hard code our glslang path for now |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 59 | get_filename_component(GLSLANG_PREFIX ../glslang ABSOLUTE) |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 60 | |
| 61 | if(NOT EXISTS ${GLSLANG_PREFIX}) |
| 62 | message(FATAL_ERROR "Necessary glslang components do not exist: " ${GLSLANG_PREFIX}) |
| 63 | endif() |
Courtney Goeltzenleuchter | 5df372f | 2015-10-14 17:00:44 -0600 | [diff] [blame] | 64 | endif() |
| 65 | |
| 66 | if (BUILD_ICD) |
| 67 | # Hard code our LunarGLASS path for now |
| 68 | get_filename_component(LUNARGLASS_PREFIX ../LunarGLASS ABSOLUTE) |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 69 | |
| 70 | if(NOT EXISTS ${LUNARGLASS_PREFIX}) |
| 71 | message(FATAL_ERROR "Necessary LunarGLASS components do not exist: " ${LUNARGLASS_PREFIX}) |
| 72 | endif() |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 73 | endif() |
Courtney Goeltzenleuchter | a43bbd8 | 2014-10-03 15:34:53 -0600 | [diff] [blame] | 74 | |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 75 | if(NOT WIN32) |
Adam Jackson | 3869f41 | 2015-07-23 16:29:26 -0400 | [diff] [blame] | 76 | include(GNUInstallDirs) |
James Jones | c28b0a1 | 2015-07-23 17:39:37 -0700 | [diff] [blame] | 77 | add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}") |
| 78 | add_definitions(-DDATADIR="${CMAKE_INSTALL_DATADIR}") |
| 79 | if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") |
Jon Ashburn | 86723b0 | 2015-07-31 15:47:59 -0600 | [diff] [blame] | 80 | elseif (CMAKE_INSTALL_PREFIX STREQUAL "") |
James Jones | c28b0a1 | 2015-07-23 17:39:37 -0700 | [diff] [blame] | 81 | else() |
| 82 | add_definitions(-DLOCALPREFIX="${CMAKE_INSTALL_PREFIX}") |
| 83 | endif() |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 84 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
Jon Ashburn | 1a97d6c | 2015-03-18 09:29:11 -0600 | [diff] [blame] | 85 | set(PYTHON_CMD "python3") |
| 86 | endif() |
| 87 | else() |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 88 | set(PYTHON_CMD "py") |
Courtney Goeltzenleuchter | a43bbd8 | 2014-10-03 15:34:53 -0600 | [diff] [blame] | 89 | endif() |
| 90 | |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 91 | # loader: Generic VULKAN ICD loader |
| 92 | # icd: Device dependent (DD) VULKAN components |
| 93 | # tests: VULKAN tests |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 94 | if(BUILD_LOADER) |
| 95 | add_subdirectory(loader) |
| 96 | endif() |
| 97 | |
| 98 | if(BUILD_ICD) |
| 99 | add_subdirectory(icd) |
| 100 | endif() |
| 101 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 102 | if(BUILD_TESTS) |
| 103 | add_subdirectory(tests) |
| 104 | endif() |
Jason Ekstrand | 5dfc4a9 | 2015-10-10 08:43:07 -0700 | [diff] [blame] | 105 | |
| 106 | if(BUILD_LAYERS) |
| 107 | add_subdirectory(layers) |
| 108 | endif() |
| 109 | |
| 110 | if(BUILD_DEMOS) |
| 111 | add_subdirectory(demos) |
| 112 | endif() |
| 113 | |
| 114 | if(BUILD_VKTRACE) |
| 115 | add_subdirectory(vktrace) |
| 116 | endif() |