blob: 32d75333fb79ed3135b33928fe045a573f547e1f [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
David Pinedo0c083652015-07-09 12:44:38 -06008# The MAJOR number of the version we're building, used in naming
David Pinedo4bb0d302015-09-08 11:07:46 -06009# vulkan-<major>.dll (and other files).
David Pinedo0c083652015-07-09 12:44:38 -060010set(MAJOR "0")
11
Chia-I Wuc3624592015-01-10 23:15:51 +080012set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
13
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060014# Header file for CMake settings
Courtney Goeltzenleuchter2220a3b2014-07-24 08:36:15 -060015include_directories("${PROJECT_SOURCE_DIR}/include")
16
Chia-I Wu155be032014-08-02 09:14:28 +080017include(FindPkgConfig)
Chia-I Wu155be032014-08-02 09:14:28 +080018
Jon Ashburna0dffd62015-07-31 15:15:00 -060019set (CMAKE_INSTALL_PREFIX "")
20
Chia-I Wu084c8862015-02-17 09:55:34 -070021if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
Ian Elliott661dc372015-02-13 14:04:01 -070022 set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
Tony Barbourf4351602015-02-05 14:14:33 -070023 set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
Chia-I Wubba8fc02014-12-19 11:34:46 +080024 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
Adam Jackson77d5fd32015-06-23 15:33:48 -040025 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11")
Chia-I Wu19300602014-08-04 08:03:57 +080026 if (UNIX)
27 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
Chia-I Wu33ada632015-01-18 11:09:29 +080028 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
Chia-I Wu19300602014-08-04 08:03:57 +080029 endif()
30endif()
Chia-I Wu155be032014-08-02 09:14:28 +080031
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070032option(BUILD_LOADER "Build loader" ON)
Courtney Goeltzenleuchtere250a322015-10-14 17:00:19 -060033if(WIN32)
34 option(BUILD_ICD "Build LunarG intel icd" OFF)
35else()
36 option(BUILD_ICD "Build LunarG intel icd" ON)
37endif()
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070038option(BUILD_TESTS "Build tests" ON)
39option(BUILD_LAYERS "Build layers" ON)
40option(BUILD_DEMOS "Build demos" ON)
41option(BUILD_VKTRACE "Build VkTrace" ON)
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060042
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060043if (BUILD_ICD OR BUILD_TESTS)
44 # Hard code our glslang path for now
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070045 get_filename_component(GLSLANG_PREFIX ../glslang ABSOLUTE)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070046
47 if(NOT EXISTS ${GLSLANG_PREFIX})
48 message(FATAL_ERROR "Necessary glslang components do not exist: " ${GLSLANG_PREFIX})
49 endif()
Courtney Goeltzenleuchter5df372f2015-10-14 17:00:44 -060050endif()
51
52if (BUILD_ICD)
53 # Hard code our LunarGLASS path for now
54 get_filename_component(LUNARGLASS_PREFIX ../LunarGLASS ABSOLUTE)
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070055
56 if(NOT EXISTS ${LUNARGLASS_PREFIX})
57 message(FATAL_ERROR "Necessary LunarGLASS components do not exist: " ${LUNARGLASS_PREFIX})
58 endif()
Tony Barbour500194c2015-05-21 11:07:47 -060059endif()
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060060
Tony Barbour500194c2015-05-21 11:07:47 -060061if(NOT WIN32)
Adam Jackson3869f412015-07-23 16:29:26 -040062 include(GNUInstallDirs)
James Jonesc28b0a12015-07-23 17:39:37 -070063 add_definitions(-DLIBDIR="${CMAKE_INSTALL_LIBDIR}")
64 add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}")
65 add_definitions(-DDATADIR="${CMAKE_INSTALL_DATADIR}")
66 if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
Jon Ashburn86723b02015-07-31 15:47:59 -060067 elseif (CMAKE_INSTALL_PREFIX STREQUAL "")
James Jonesc28b0a12015-07-23 17:39:37 -070068 else()
69 add_definitions(-DLOCALPREFIX="${CMAKE_INSTALL_PREFIX}")
70 endif()
Tony Barbour500194c2015-05-21 11:07:47 -060071 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Jon Ashburn1a97d6c2015-03-18 09:29:11 -060072 set(PYTHON_CMD "python3")
73 endif()
74else()
Tony Barbour500194c2015-05-21 11:07:47 -060075 set(PYTHON_CMD "py")
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060076endif()
77
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060078# loader: Generic VULKAN ICD loader
79# icd: Device dependent (DD) VULKAN components
80# tests: VULKAN tests
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070081if(BUILD_LOADER)
82 add_subdirectory(loader)
83endif()
84
85if(BUILD_ICD)
86 add_subdirectory(icd)
87endif()
88
Tony Barboura05dbaa2015-07-09 17:31:46 -060089if(BUILD_TESTS)
90 add_subdirectory(tests)
91endif()
Jason Ekstrand5dfc4a92015-10-10 08:43:07 -070092
93if(BUILD_LAYERS)
94 add_subdirectory(layers)
95endif()
96
97if(BUILD_DEMOS)
98 add_subdirectory(demos)
99endif()
100
101if(BUILD_VKTRACE)
102 add_subdirectory(vktrace)
103endif()