blob: 9510e31dad19047eb9bf03518454054fe448badf [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 Pinedo1d98da32015-11-16 17:01:29 -070012set(MAJOR "0")
David Pinedo0c083652015-07-09 12:44:38 -060013
Mark Lobodzinskifaa90812015-11-25 13:26:15 -070014if(WIN32)
Mark Lobodzinskib49b6e52015-11-26 10:59:58 -070015 add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
Mark Lobodzinskifaa90812015-11-25 13:26:15 -070016else()
17 add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
18endif()
19
Chia-I Wuc3624592015-01-10 23:15:51 +080020set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
21
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060022# Header file for CMake settings
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060023include_directories("${PROJECT_SOURCE_DIR}/include")
24
Chia-I Wu155be032014-08-02 09:14:28 +080025include(FindPkgConfig)
Chia-I Wu155be032014-08-02 09:14:28 +080026
Jon Ashburna0dffd62015-07-31 15:15:00 -060027set (CMAKE_INSTALL_PREFIX "")
28
Chia-I Wu084c8862015-02-17 09:55:34 -070029if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
Ian Elliott661dc372015-02-13 14:04:01 -070030 set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
Tony Barbourf4351602015-02-05 14:14:33 -070031 set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
Chia-I Wubba8fc02014-12-19 11:34:46 +080032 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
Adam Jackson77d5fd32015-06-23 15:33:48 -040033 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11")
Chia-I Wu19300602014-08-04 08:03:57 +080034 if (UNIX)
35 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
Chia-I Wu33ada632015-01-18 11:09:29 +080036 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
Chia-I Wu19300602014-08-04 08:03:57 +080037 endif()
38endif()
Chia-I Wu155be032014-08-02 09:14:28 +080039
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070040option(BUILD_LOADER "Build loader" ON)
Courtney Goeltzenleuchtere250a322015-10-14 17:00:19 -060041if(WIN32)
42 option(BUILD_ICD "Build LunarG intel icd" OFF)
43else()
44 option(BUILD_ICD "Build LunarG intel icd" ON)
45endif()
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070046option(BUILD_TESTS "Build tests" ON)
47option(BUILD_LAYERS "Build layers" ON)
48option(BUILD_DEMOS "Build demos" ON)
Mark Lobodzinskib8ba3002015-11-25 16:13:36 -070049option(BUILD_VKTRACE "Build VkTrace" ON)
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060050
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060051if (BUILD_ICD OR BUILD_TESTS)
52 # Hard code our glslang path for now
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070053 get_filename_component(GLSLANG_PREFIX ../glslang ABSOLUTE)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070054
55 if(NOT EXISTS ${GLSLANG_PREFIX})
56 message(FATAL_ERROR "Necessary glslang components do not exist: " ${GLSLANG_PREFIX})
57 endif()
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060058endif()
59
60if (BUILD_ICD)
61 # Hard code our LunarGLASS path for now
62 get_filename_component(LUNARGLASS_PREFIX ../LunarGLASS ABSOLUTE)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070063
64 if(NOT EXISTS ${LUNARGLASS_PREFIX})
65 message(FATAL_ERROR "Necessary LunarGLASS components do not exist: " ${LUNARGLASS_PREFIX})
66 endif()
Tony Barbour500194c2015-05-21 11:07:47 -060067endif()
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060068
Tony Barbour500194c2015-05-21 11:07:47 -060069if(NOT WIN32)
Adam Jackson3869f412015-07-23 16:29:26 -040070 include(GNUInstallDirs)
James Jonesc28b0a12015-07-23 17:39:37 -070071 add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}")
72 add_definitions(-DDATADIR="${CMAKE_INSTALL_DATADIR}")
73 if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
Jon Ashburn86723b02015-07-31 15:47:59 -060074 elseif (CMAKE_INSTALL_PREFIX STREQUAL "")
James Jonesc28b0a12015-07-23 17:39:37 -070075 else()
76 add_definitions(-DLOCALPREFIX="${CMAKE_INSTALL_PREFIX}")
77 endif()
Tony Barbour500194c2015-05-21 11:07:47 -060078 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Jon Ashburn1a97d6c2015-03-18 09:29:11 -060079 set(PYTHON_CMD "python3")
80 endif()
81else()
Tony Barbour500194c2015-05-21 11:07:47 -060082 set(PYTHON_CMD "py")
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060083endif()
84
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060085# loader: Generic VULKAN ICD loader
86# icd: Device dependent (DD) VULKAN components
87# tests: VULKAN tests
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070088if(BUILD_LOADER)
89 add_subdirectory(loader)
90endif()
91
92if(BUILD_ICD)
93 add_subdirectory(icd)
94endif()
95
Tony Barboura05dbaa2015-07-09 17:31:46 -060096if(BUILD_TESTS)
97 add_subdirectory(tests)
98endif()
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070099
100if(BUILD_LAYERS)
101 add_subdirectory(layers)
102endif()
103
104if(BUILD_DEMOS)
105 add_subdirectory(demos)
106endif()
107
108if(BUILD_VKTRACE)
109 add_subdirectory(vktrace)
110endif()