2015-01-10 15:15:51 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.11)
|
2018-04-18 17:46:21 +00:00
|
|
|
|
|
|
|
# This must come before the project command.
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
|
|
|
|
|
2018-05-09 20:07:11 +00:00
|
|
|
project(VULKAN_LOADER)
|
|
|
|
set (CMAKE_VERBOSE_MAKEFILE 0)
|
2014-07-24 14:36:15 +00:00
|
|
|
|
2016-11-07 17:44:23 +00:00
|
|
|
# The API_NAME allows renaming builds to avoid conflicts with installed SDKs
|
2015-07-09 18:44:38 +00:00
|
|
|
# The MAJOR number of the version we're building, used in naming
|
2016-11-07 17:44:23 +00:00
|
|
|
# <api-name>-<major>.dll (and other files).
|
|
|
|
set(API_NAME "Vulkan" CACHE STRING "API name to use when building")
|
2016-01-06 23:34:27 +00:00
|
|
|
set(MAJOR "1")
|
2016-11-07 17:44:23 +00:00
|
|
|
string(TOLOWER ${API_NAME} API_LOWERCASE)
|
2015-07-09 18:44:38 +00:00
|
|
|
|
2016-12-07 23:13:35 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2016-02-25 22:44:10 +00:00
|
|
|
find_package(PythonInterp 3 REQUIRED)
|
2015-12-15 16:25:29 +00:00
|
|
|
|
2017-10-31 23:05:03 +00:00
|
|
|
option(USE_CCACHE "Use ccache" OFF)
|
|
|
|
if (USE_CCACHE)
|
|
|
|
find_program(CCACHE_FOUND ccache)
|
|
|
|
if(CCACHE_FOUND)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
|
|
|
endif(CCACHE_FOUND)
|
|
|
|
endif()
|
|
|
|
|
2017-12-12 15:33:01 +00:00
|
|
|
if(APPLE)
|
|
|
|
# CMake versions 3 or later need CMAKE_MACOSX_RPATH defined.
|
|
|
|
# This avoids the CMP0042 policy message.
|
|
|
|
set(CMAKE_MACOSX_RPATH 1)
|
|
|
|
# The "install" target for MacOS fixes up bundles in place.
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
|
|
|
|
endif()
|
|
|
|
|
2018-02-01 16:27:03 +00:00
|
|
|
# Enable cmake folders
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
set(LVL_TARGET_FOLDER lvl_cmake_targets)
|
|
|
|
|
2017-12-12 15:33:01 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
2017-02-19 19:14:24 +00:00
|
|
|
set(FALLBACK_CONFIG_DIRS "/etc/xdg" CACHE STRING
|
|
|
|
"Search path to use when XDG_CONFIG_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
|
|
|
|
set(FALLBACK_DATA_DIRS "/usr/local/share:/usr/share" CACHE STRING
|
|
|
|
"Search path to use when XDG_DATA_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
|
2017-12-12 15:33:01 +00:00
|
|
|
endif()
|
2017-02-19 19:14:24 +00:00
|
|
|
|
2017-12-12 15:33:01 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2016-12-07 23:13:35 +00:00
|
|
|
include(FindPkgConfig)
|
2016-02-20 16:13:28 +00:00
|
|
|
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
|
2016-04-12 19:35:51 +00:00
|
|
|
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
|
2016-12-07 17:19:21 +00:00
|
|
|
option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON)
|
2017-04-21 20:27:08 +00:00
|
|
|
option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" OFF)
|
2017-01-31 17:26:07 +00:00
|
|
|
set(DEMOS_WSI_SELECTION "XCB" CACHE STRING "Select WSI target for demos (XCB, XLIB, WAYLAND, MIR, DISPLAY)")
|
2015-11-25 20:26:15 +00:00
|
|
|
|
2016-12-07 23:13:35 +00:00
|
|
|
if (BUILD_WSI_XCB_SUPPORT)
|
|
|
|
find_package(XCB REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (BUILD_WSI_XLIB_SUPPORT)
|
|
|
|
find_package(X11 REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (BUILD_WSI_WAYLAND_SUPPORT)
|
|
|
|
find_package(Wayland REQUIRED)
|
2017-08-21 22:36:45 +00:00
|
|
|
include_directories(${WAYLAND_CLIENT_INCLUDE_DIR})
|
2016-12-07 23:13:35 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (BUILD_WSI_MIR_SUPPORT)
|
|
|
|
find_package(Mir REQUIRED)
|
|
|
|
endif()
|
2018-05-09 20:07:11 +00:00
|
|
|
endif()
|
2017-06-12 17:23:57 +00:00
|
|
|
|
2018-05-09 20:07:11 +00:00
|
|
|
if(WIN32)
|
|
|
|
option(ENABLE_WIN10_ONECORE "Link the loader with OneCore umbrella libraries" OFF)
|
2016-12-07 23:13:35 +00:00
|
|
|
endif()
|
2015-01-10 15:15:51 +00:00
|
|
|
|
2017-01-31 14:35:19 +00:00
|
|
|
set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
|
2016-11-18 21:44:37 +00:00
|
|
|
|
2018-05-09 20:07:11 +00:00
|
|
|
# Add location of Vulkan header files to include search path
|
|
|
|
set(vulkan_include_dir "${PROJECT_SOURCE_DIR}/Vulkan-Headers/include")
|
|
|
|
include_directories(${vulkan_include_dir})
|
2014-07-24 14:36:15 +00:00
|
|
|
|
2015-02-17 16:55:34 +00:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2015-02-13 21:04:01 +00:00
|
|
|
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
|
2015-02-05 21:14:33 +00:00
|
|
|
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
|
2017-07-12 16:06:19 +00:00
|
|
|
|
|
|
|
# For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since
|
|
|
|
# there's no consistent way to satisfy all compilers until they all accept the C++17 standard
|
|
|
|
if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.1))
|
|
|
|
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Wimplicit-fallthrough=0")
|
|
|
|
endif()
|
|
|
|
|
2017-12-12 15:33:01 +00:00
|
|
|
if (APPLE)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILE_FLAGS}")
|
|
|
|
else()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
|
|
|
|
endif()
|
2016-05-12 16:28:57 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11 -fno-rtti")
|
2014-08-04 00:03:57 +00:00
|
|
|
if (UNIX)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
|
2015-01-18 03:09:29 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
2014-08-04 00:03:57 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2014-08-02 01:14:28 +00:00
|
|
|
|
2016-05-12 16:28:57 +00:00
|
|
|
if(WIN32)
|
2017-01-20 20:19:20 +00:00
|
|
|
# Treat warnings as errors
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/WX>")
|
|
|
|
# Disable RTTI
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/GR->")
|
|
|
|
# Warn about nested declarations
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34456>")
|
2017-03-15 20:17:46 +00:00
|
|
|
# Warn about potentially uninitialized variables
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34701>")
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34703>")
|
2017-11-08 19:48:32 +00:00
|
|
|
# Warn about different indirection types.
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34057>")
|
2017-11-08 21:25:22 +00:00
|
|
|
# Warn about signed/unsigned mismatch.
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34245>")
|
2016-05-12 16:28:57 +00:00
|
|
|
endif()
|
|
|
|
|
2015-10-10 15:43:07 +00:00
|
|
|
option(BUILD_LOADER "Build loader" ON)
|
|
|
|
option(BUILD_TESTS "Build tests" ON)
|
2015-10-14 23:00:44 +00:00
|
|
|
|
2016-03-01 23:40:39 +00:00
|
|
|
set (PYTHON_CMD ${PYTHON_EXECUTABLE})
|
|
|
|
|
2017-01-23 16:08:20 +00:00
|
|
|
# Define macro used for building vkxml generated files
|
2017-01-23 15:51:08 +00:00
|
|
|
macro(run_vk_xml_generate dependency output)
|
|
|
|
add_custom_command(OUTPUT ${output}
|
|
|
|
COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/lvl_genvk.py -registry ${SCRIPTS_DIR}/vk.xml ${output}
|
|
|
|
DEPENDS ${SCRIPTS_DIR}/vk.xml ${SCRIPTS_DIR}/generator.py ${SCRIPTS_DIR}/${dependency} ${SCRIPTS_DIR}/lvl_genvk.py ${SCRIPTS_DIR}/reg.py
|
|
|
|
)
|
|
|
|
endmacro()
|
|
|
|
|
2017-01-23 16:08:20 +00:00
|
|
|
# Custom target for generated vulkan helper file dependencies
|
|
|
|
add_custom_target(generate_helper_files DEPENDS
|
|
|
|
vk_enum_string_helper.h
|
|
|
|
vk_safe_struct.h
|
|
|
|
vk_safe_struct.cpp
|
2017-04-04 13:38:17 +00:00
|
|
|
vk_object_types.h
|
2017-02-28 16:58:04 +00:00
|
|
|
vk_layer_dispatch_table.h
|
|
|
|
vk_dispatch_table_helper.h
|
2017-06-01 13:46:20 +00:00
|
|
|
vk_extension_helper.h
|
2017-10-26 18:07:05 +00:00
|
|
|
vk_typemap_helper.h
|
2017-01-23 16:08:20 +00:00
|
|
|
)
|
2018-02-01 16:27:03 +00:00
|
|
|
set_target_properties(generate_helper_files PROPERTIES FOLDER ${LVL_TARGET_FOLDER})
|
2017-01-23 16:08:20 +00:00
|
|
|
|
|
|
|
# Rules to build generated helper files
|
2017-02-28 16:58:04 +00:00
|
|
|
run_vk_xml_generate(loader_extension_generator.py vk_layer_dispatch_table.h)
|
|
|
|
run_vk_xml_generate(dispatch_table_helper_generator.py vk_dispatch_table_helper.h)
|
2017-01-23 16:08:20 +00:00
|
|
|
run_vk_xml_generate(helper_file_generator.py vk_safe_struct.h)
|
|
|
|
run_vk_xml_generate(helper_file_generator.py vk_safe_struct.cpp)
|
|
|
|
run_vk_xml_generate(helper_file_generator.py vk_enum_string_helper.h)
|
2017-04-04 13:38:17 +00:00
|
|
|
run_vk_xml_generate(helper_file_generator.py vk_object_types.h)
|
2017-06-01 13:46:20 +00:00
|
|
|
run_vk_xml_generate(helper_file_generator.py vk_extension_helper.h)
|
2017-10-26 18:07:05 +00:00
|
|
|
run_vk_xml_generate(helper_file_generator.py vk_typemap_helper.h)
|
2018-02-02 20:58:41 +00:00
|
|
|
|
2015-05-21 17:07:47 +00:00
|
|
|
if(NOT WIN32)
|
2015-07-23 20:29:26 +00:00
|
|
|
include(GNUInstallDirs)
|
2016-10-22 19:20:29 +00:00
|
|
|
|
2017-02-19 19:14:24 +00:00
|
|
|
add_definitions(-DFALLBACK_CONFIG_DIRS="${FALLBACK_CONFIG_DIRS}")
|
|
|
|
add_definitions(-DFALLBACK_DATA_DIRS="${FALLBACK_DATA_DIRS}")
|
2016-10-22 17:42:44 +00:00
|
|
|
add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
|
2017-02-19 19:14:24 +00:00
|
|
|
|
2016-10-22 19:20:29 +00:00
|
|
|
# Make sure /etc is searched by the loader
|
2017-01-29 22:49:54 +00:00
|
|
|
if(NOT (CMAKE_INSTALL_FULL_SYSCONFDIR STREQUAL "/etc"))
|
2016-10-22 19:20:29 +00:00
|
|
|
add_definitions(-DEXTRASYSCONFDIR="/etc")
|
|
|
|
endif()
|
2014-10-03 21:34:53 +00:00
|
|
|
endif()
|
|
|
|
|
2016-10-12 23:36:35 +00:00
|
|
|
if(UNIX)
|
2018-05-11 21:48:06 +00:00
|
|
|
install(DIRECTORY "${PROJECT_SOURCE_DIR}/Vulkan-Headers/include/vulkan" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/vk_layer_dispatch_table.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/vulkan")
|
2017-03-14 23:11:24 +00:00
|
|
|
|
|
|
|
# uninstall target
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
2016-10-12 23:36:35 +00:00
|
|
|
endif()
|
|
|
|
|
2017-08-31 16:44:17 +00:00
|
|
|
add_definitions(-DAPI_NAME="${API_NAME}")
|
|
|
|
|
2015-10-10 15:43:07 +00:00
|
|
|
if(BUILD_LOADER)
|
|
|
|
add_subdirectory(loader)
|
|
|
|
endif()
|
|
|
|
|
2015-07-09 23:31:46 +00:00
|
|
|
if(BUILD_TESTS)
|
2018-05-09 23:40:36 +00:00
|
|
|
add_subdirectory(tests)
|
2017-10-13 15:26:20 +00:00
|
|
|
endif()
|