blob: fa9a3d3b54d8cbb2cf3b898af4e5fe9d09fec13e [file] [log] [blame]
# The name of our project is "VULKAN". CMakeLists files in this project can
# refer to the root source directory of the project as ${VULKAN_SOURCE_DIR} and
# to the root binary directory of the project as ${VULKAN_BINARY_DIR}.
cmake_minimum_required(VERSION 2.8.11)
# This must come before the project command.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
project (Vulkan-Tools)
# set (CMAKE_VERBOSE_MAKEFILE 1)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# If CMAKE 3.7+, use FindVulkan
if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
message(STATUS "Using find_package to locate Vulkan")
find_package(Vulkan)
endif()
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()
# Enable cmake folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(TOOLS_TARGET_FOLDER lvl_cmake_targets)
# Output warning if vulkan headers submodule contents are not present
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/Vulkan-Headers/include/vulkan/vulkan_core.h")
message(FATAL_ERROR "Please run 'git submodule update --init' before running cmake")
endif()
# Header file for CMake settings
include_directories("${PROJECT_SOURCE_DIR}/Vulkan-Headers/include")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
# 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()
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()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11 -fno-rtti")
if (UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
endif()
if(NOT WIN32)
set (BUILDTGT_DIR build)
set (BINDATA_DIR Bin)
set (LIBSOURCE_DIR Lib)
else()
# For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory.
# 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the
# appropriate data at build time.
if (DISABLE_BUILDTGT_DIR_DECORATION)
set (BUILDTGT_DIR "")
set (BINDATA_DIR "")
set (LIBSOURCE_DIR "")
elseif (CMAKE_CL_64)
set (BUILDTGT_DIR build)
set (BINDATA_DIR Bin)
set (LIBSOURCE_DIR Lib)
else()
set (BUILDTGT_DIR build32)
set (BINDATA_DIR Bin32)
set (LIBSOURCE_DIR Lib32)
endif()
if(DISABLE_BUILD_PATH_DECORATION)
set (DEBUG_DECORATION "")
set (RELEASE_DECORATION "")
else()
set (DEBUG_DECORATION "Debug")
set (RELEASE_DECORATION "Release")
endif()
endif()
option(BUILD_CUBE "Build cube" ON)
option(BUILD_VULKANINFO "Build vulkaninfo" ON)
option(BUILD_ICD "Build icd" ON)
if(UNIX)
include(GNUInstallDirs)
# 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-Vulkan-Tools
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
if(APPLE)
include(mac_common.cmake)
endif()
if(BUILD_CUBE)
add_subdirectory(cube)
endif()
if(BUILD_VULKANINFO)
add_subdirectory(vulkaninfo)
endif()
if(BUILD_ICD)
add_subdirectory(icd)
endif()