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