summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Weiblen <mikew@lunarg.com>2018-08-16 14:09:08 -0600
committerMike Weiblen <mikew@lunarg.com>2018-09-12 12:26:37 -0600
commite31a32283aa35f482f80067ded5e15a305f2a9ed (patch)
tree1322f4079a61adc7bc3387d5d64830fa577963cc
parente88bc84edea639d028cfd8f37abd6875016fa70c (diff)
downloadVulkan-Tools-e31a32283aa35f482f80067ded5e15a305f2a9ed.tar.gz
Vulkan-Tools-e31a32283aa35f482f80067ded5e15a305f2a9ed.tar.bz2
Vulkan-Tools-e31a32283aa35f482f80067ded5e15a305f2a9ed.zip
build: CMakeLists.txt cleanup, part 1
This is a first pass reorganization of CMake files in this repo. It consists primarily of dead code/variable removal, simplification, and reformatting by latest cmake-format. bump to cmake_minimum_required(3.4), for ccache support. add USE_CCACHE change 'ln -sf' to '-E create_symlink' clarify why CMAKE_OSX_DEPLOYMENT_TARGET is pre-project(). sync FindVulkan.cmake from upstream CMake v3.8.0 Ensure our repos use identical copy of upstream FindVulkan.cmake Copied from Modules/FindVulkan.cmake https://gitlab.kitware.com/cmake/cmake.git tag: v3.8.0 (commit da7833c5bb1f331162d46a2c664a443c1c641089) change $<CONFIGURATION> to $<CONFIG> The $<CONFIGURATION> genexp is officially deprecated. change CMAKE_SYSTEM_NAME to UNIX/APPLE/WIN32 Note that UNIX evaluates true for OSX, so whenever the code intends "Linux only", we use (UNIX AND NOT APPLE). change TOOLS_TARGET_FOLDER to TOOLS_HELPER_FOLDER for consistency with VVL and VL repos. set Windows install prefix if needed remove unused DisplayServer variable remove deprecated GLSLANG_REPO_ROOT The *_REPO_ROOT mechanism for finding packages is deprecated. remove extra cmake_minimum_required change LIBVK to Vulkan::Vulkan change PYTHON_CMD to PYTHON_EXECUTABLE section rulers, other cosmetics .cmake-format.py 0.4.1 reformat using cmake-format 0.4.1 Change-Id: Id8e5b26fdcf5dc0b383de94cbec75a567704a55e
-rw-r--r--.cmake-format.py2
-rw-r--r--BUILD.md1
-rw-r--r--CMakeLists.txt41
-rw-r--r--cmake/FindVulkan.cmake1
-rw-r--r--cube/CMakeLists.txt100
-rw-r--r--cube/macOS/cube/cube.cmake7
-rw-r--r--cube/macOS/cubepp/cubepp.cmake12
-rw-r--r--icd/CMakeLists.txt56
-rw-r--r--vulkaninfo/CMakeLists.txt11
-rw-r--r--vulkaninfo/macOS/vulkaninfo.cmake22
10 files changed, 143 insertions, 110 deletions
diff --git a/.cmake-format.py b/.cmake-format.py
index 9c173ac1..07d2f99d 100644
--- a/.cmake-format.py
+++ b/.cmake-format.py
@@ -1,4 +1,4 @@
-# Configuration for cmake-format (v0.3.6, circa Apr 2018)
+# Configuration for cmake-format (v0.4.1, circa Jul 2018)
# https://github.com/cheshirekow/cmake_format
# How wide to allow formatted cmake files
diff --git a/BUILD.md b/BUILD.md
index e18f36ed..5e3817a5 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -174,6 +174,7 @@ on/off options currently supported by this repository:
| BUILD_WSI_XLIB_SUPPORT | Linux | `ON` | Build the components with Xlib support. |
| BUILD_WSI_WAYLAND_SUPPORT | Linux | `ON` | Build the components with Wayland support. |
| BUILD_WSI_MIR_SUPPORT | Linux | `OFF` | Build the components with Mir support. |
+| USE_CCACHE | Linux | `OFF` | Enable caching with the CCache program. |
The following is a table of all string options currently supported by this repository:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2239747..ecd5af1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,13 +15,24 @@
# limitations under the License.
# ~~~
-cmake_minimum_required(VERSION 2.8.11)
+# CMake project initialization ---------------------------------------------------------------------------------------------------
+# This section contains pre-project() initialization, and ends with the project() command.
-# This must come before the project command.
+cmake_minimum_required(VERSION 3.4)
+
+# Apple: Must be set before enable_language() or project() as it may influence configuration of the toolchain and flags.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
project(Vulkan-Tools)
+# find_package(), include() and global project settings --------------------------------------------------------------------------
+
+find_package(PythonInterp 3 REQUIRED)
+
+# User-interface declarations ----------------------------------------------------------------------------------------------------
+# This section contains variables that affect development GUIs (e.g. CMake GUI and IDEs), such as option(), folders, and variables
+# with the CACHE property.
+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(BUILD_CUBE "Build cube" ON)
@@ -34,7 +45,15 @@ option(INSTALL_ICD "Install icd" OFF)
# Enable IDE GUI folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# "Helper" targets that don't have interesting source code should set their FOLDER property to this
-set(TOOLS_TARGET_FOLDER "Helper Targets")
+set(TOOLS_HELPER_FOLDER "Helper Targets")
+
+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)
+ endif()
+endif()
# ~~~
# Find Vulkan Headers and Loader
@@ -66,28 +85,27 @@ endif()
message(STATUS "Using find_package to locate Vulkan")
find_package(Vulkan)
find_package(VulkanHeaders)
-# "Vulkan::Vulkan" on macOS causes the framework to be linked to the app instead of an individual library
-set(LIBVK "Vulkan::Vulkan")
message(STATUS "Vulkan FOUND = ${Vulkan_FOUND}")
message(STATUS "Vulkan Lib = ${Vulkan_LIBRARY}")
message(STATUS "Vulkan Headers Include = ${VulkanHeaders_INCLUDE_DIR}")
message(STATUS "Vulkan Headers Registry = ${VulkanRegistry_DIR}")
-# Install-related settings
include(GNUInstallDirs)
-# Set a better default install location for Windows only if the user did not provide one.
-if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
+
+if(WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ # Windows: if install locations not set by user, set install prefix to "<build_dir>\install".
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
endif()
# uninstall target
if(NOT TARGET uninstall)
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ 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)
- set_target_properties(uninstall PROPERTIES FOLDER ${TOOLS_TARGET_FOLDER})
+ set_target_properties(uninstall PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
endif()
if(APPLE)
@@ -120,12 +138,15 @@ 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()
diff --git a/cmake/FindVulkan.cmake b/cmake/FindVulkan.cmake
index 41496a63..1f4c8ade 100644
--- a/cmake/FindVulkan.cmake
+++ b/cmake/FindVulkan.cmake
@@ -65,7 +65,6 @@ endif()
set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
-#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vulkan
DEFAULT_MSG
diff --git a/cube/CMakeLists.txt b/cube/CMakeLists.txt
index 3204214f..59105462 100644
--- a/cube/CMakeLists.txt
+++ b/cube/CMakeLists.txt
@@ -17,38 +17,27 @@
set(CUBE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ${VulkanHeaders_INCLUDE_DIR})
-find_package(PythonInterp 3 REQUIRED)
-set(PYTHON_CMD ${PYTHON_EXECUTABLE})
-
set(SCRIPTS_DIR "${PROJECT_SOURCE_DIR}/scripts")
if(GLSLANG_INSTALL_DIR)
message(STATUS "Using GLSLANG_INSTALL_DIR to look for glslangValidator")
find_program(GLSLANG_VALIDATOR names glslangValidator HINTS "${GLSLANG_INSTALL_DIR}/bin")
-elseif(GLSLANG_REPO_ROOT)
- message(STATUS "Using glslang_repo_root to look for glslangValidator")
- find_program(GLSLANG_VALIDATOR names glslangValidator
- HINTS "${GLSLANG_REPO_ROOT}/build/standalone/release"
- HINTS "${GLSLANG_REPO_ROOT}/build/standalone/debug"
- HINTS "${GLSLANG_REPO_ROOT}/build/StandAlone"
- HINTS "${GLSLANG_REPO_ROOT}/dbuild/StandAlone"
- HINTS "${GLSLANG_REPO_ROOT}/build32/standalone/release"
- HINTS "${GLSLANG_REPO_ROOT}/build32/standalone/debug")
else()
set(GLSLANG_VALIDATOR_NAME "glslangValidator")
message(STATUS "Using cmake find_program to look for glslangValidator")
- if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- execute_process(COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-windows-x64-Release.zip)
+ if(WIN32)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-windows-x64-Release.zip)
set(GLSLANG_VALIDATOR_NAME "glslangValidator.exe")
- elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- execute_process(COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-linux-Release.zip)
- elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- execute_process(COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-osx-Release.zip)
+ elseif(APPLE)
+ execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-osx-Release.zip)
+ elseif(UNIX AND NOT APPLE) # i.e. Linux
+ execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-linux-Release.zip)
endif()
find_program(GLSLANG_VALIDATOR NAMES ${GLSLANG_VALIDATOR_NAME} HINTS "${PROJECT_SOURCE_DIR}/glslang/bin")
endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if(UNIX AND NOT APPLE) # i.e. Linux
include(FindPkgConfig)
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
@@ -75,9 +64,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+if(WIN32)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
- set(DisplayServer Win32)
if(NOT MSVC_VERSION LESS 1900)
# Enable control flow guard
message(STATUS "Building cube with control flow guard")
@@ -85,9 +73,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf")
endif()
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
+elseif(ANDROID)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+elseif(APPLE)
+ add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
+elseif(UNIX AND NOT APPLE) # i.e. Linux
if(NOT CUBE_WSI_SELECTION)
set(CUBE_WSI_SELECTION "XCB")
endif()
@@ -126,8 +116,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
link_libraries(${API_LOWERCASE} m)
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
else()
message(FATAL_ERROR "Unsupported Platform!")
endif()
@@ -148,7 +136,11 @@ if(WIN32)
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${configuration} MATCHES "/MD")
- string(REGEX REPLACE "/MD" "/MT" ${configuration} "${${configuration}}")
+ string(REGEX
+ REPLACE "/MD"
+ "/MT"
+ ${configuration}
+ "${${configuration}}")
endif()
endforeach()
@@ -183,9 +175,13 @@ if(APPLE)
include(macOS/cube/cube.cmake)
elseif(NOT WIN32)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
- add_executable(
- cube cube.c ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc)
- target_link_libraries(cube ${LIBVK})
+ add_executable(cube
+ cube.c
+ ${PROJECT_SOURCE_DIR}/cube/cube.vert
+ ${PROJECT_SOURCE_DIR}/cube/cube.frag
+ cube.vert.inc
+ cube.frag.inc)
+ target_link_libraries(cube Vulkan::Vulkan)
endif()
else()
if(CMAKE_CL_64)
@@ -194,9 +190,14 @@ else()
set(LIB_DIR "Win32")
endif()
- add_executable(
- cube WIN32 cube.c ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc)
- target_link_libraries(cube ${LIBVK})
+ add_executable(cube
+ WIN32
+ cube.c
+ ${PROJECT_SOURCE_DIR}/cube/cube.vert
+ ${PROJECT_SOURCE_DIR}/cube/cube.frag
+ cube.vert.inc
+ cube.frag.inc)
+ target_link_libraries(cube Vulkan::Vulkan)
endif()
if(APPLE)
@@ -204,13 +205,10 @@ if(APPLE)
set_target_properties(cube PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
install(TARGETS cube BUNDLE DESTINATION "cube")
# Fix up the library references to be self-contained within the bundle.
- install(
- CODE
- "
+ install(CODE "
include(BundleUtilities)
fixup_bundle(\${CMAKE_INSTALL_PREFIX}/cube/cube.app \"\" \"\")
- "
- )
+ ")
else()
install(TARGETS cube RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
@@ -222,9 +220,13 @@ if(APPLE)
include(macOS/cubepp/cubepp.cmake)
elseif(NOT WIN32)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
- add_executable(
- cubepp cube.cpp ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc)
- target_link_libraries(cubepp ${LIBVK})
+ add_executable(cubepp
+ cube.cpp
+ ${PROJECT_SOURCE_DIR}/cube/cube.vert
+ ${PROJECT_SOURCE_DIR}/cube/cube.frag
+ cube.vert.inc
+ cube.frag.inc)
+ target_link_libraries(cubepp Vulkan::Vulkan)
endif()
else()
if(CMAKE_CL_64)
@@ -233,9 +235,14 @@ else()
set(LIB_DIR "Win32")
endif()
- add_executable(
- cubepp WIN32 cube.cpp ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc)
- target_link_libraries(cubepp ${LIBVK})
+ add_executable(cubepp
+ WIN32
+ cube.cpp
+ ${PROJECT_SOURCE_DIR}/cube/cube.vert
+ ${PROJECT_SOURCE_DIR}/cube/cube.frag
+ cube.vert.inc
+ cube.frag.inc)
+ target_link_libraries(cubepp Vulkan::Vulkan)
endif()
if(APPLE)
@@ -243,13 +250,10 @@ if(APPLE)
set_target_properties(cubepp PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
install(TARGETS cubepp BUNDLE DESTINATION "cube")
# Fix up the library references to be self-contained within the bundle.
- install(
- CODE
- "
+ install(CODE "
include(BundleUtilities)
fixup_bundle(\${CMAKE_INSTALL_PREFIX}/cube/cubepp.app \"\" \"\")
- "
- )
+ ")
else()
install(TARGETS cubepp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
diff --git a/cube/macOS/cube/cube.cmake b/cube/macOS/cube/cube.cmake
index 69952eeb..b2b6ba53 100644
--- a/cube/macOS/cube/cube.cmake
+++ b/cube/macOS/cube/cube.cmake
@@ -38,10 +38,13 @@ add_executable(cube MACOSX_BUNDLE ${cube_SRCS} ${cube_HDRS} ${cube_RESOURCES} cu
if(NOT ${CMAKE_GENERATOR} MATCHES "^Xcode.*")
# Compile the storyboard file with the ibtool.
add_custom_command(TARGET cube POST_BUILD
- COMMAND ${IBTOOL} --errors --warnings --notices
+ COMMAND ${IBTOOL}
+ --errors
+ --warnings
+ --notices
--output-format human-readable-text
--compile ${CMAKE_CURRENT_BINARY_DIR}/cube.app/Contents/Resources/Main.storyboardc
- ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Resources/Main.storyboard
+ ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Resources/Main.storyboard
COMMENT "Compiling storyboard")
endif()
diff --git a/cube/macOS/cubepp/cubepp.cmake b/cube/macOS/cubepp/cubepp.cmake
index 7e27e9c6..2b523a98 100644
--- a/cube/macOS/cubepp/cubepp.cmake
+++ b/cube/macOS/cubepp/cubepp.cmake
@@ -22,8 +22,9 @@ set(cubepp_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/AppDelegate.mm
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/DemoViewController.mm)
-set(cubepp_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/AppDelegate.h
- ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/DemoViewController.h)
+set(
+ cubepp_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/AppDelegate.h ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/DemoViewController.h
+ )
set(cubepp_RESOURCES ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Resources/LunarGIcon.icns)
@@ -39,10 +40,13 @@ add_executable(cubepp MACOSX_BUNDLE ${cubepp_SRCS} ${cubepp_HDRS} ${cubepp_RESOU
if(NOT ${CMAKE_GENERATOR} MATCHES "^Xcode.*")
# Compile the storyboard file with the ibtool.
add_custom_command(TARGET cubepp POST_BUILD
- COMMAND ${IBTOOL} --errors --warnings --notices
+ COMMAND ${IBTOOL}
+ --errors
+ --warnings
+ --notices
--output-format human-readable-text
--compile ${CMAKE_CURRENT_BINARY_DIR}/cubepp.app/Contents/Resources/Main.storyboardc
- ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Resources/Main.storyboard
+ ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Resources/Main.storyboard
COMMENT "Compiling storyboard")
endif()
diff --git a/icd/CMakeLists.txt b/icd/CMakeLists.txt
index c2c8b73e..8c3aa6b2 100644
--- a/icd/CMakeLists.txt
+++ b/icd/CMakeLists.txt
@@ -15,18 +15,12 @@
# limitations under the License.
# ~~~
-cmake_minimum_required(VERSION 2.8.11)
-
-find_package(PythonInterp 3 REQUIRED)
-
set(SCRIPTS_DIR "${PROJECT_SOURCE_DIR}/scripts")
-set(PYTHON_CMD ${PYTHON_EXECUTABLE})
-
# Define macro used for building vk.xml generated files
macro(run_vk_xml_generate dependency output)
add_custom_command(OUTPUT ${output}
- COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/kvt_genvk.py -registry ${VulkanRegistry_DIR}/vk.xml -scripts
+ COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/kvt_genvk.py -registry ${VulkanRegistry_DIR}/vk.xml -scripts
${VulkanRegistry_DIR} ${output}
DEPENDS ${VulkanRegistry_DIR}/vk.xml
${VulkanRegistry_DIR}/generator.py
@@ -35,12 +29,13 @@ macro(run_vk_xml_generate dependency output)
${VulkanRegistry_DIR}/reg.py)
endmacro()
-if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+if(WIN32)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DVK_USE_PLATFORM_WIN32_KHX -DWIN32_LEAN_AND_MEAN)
- set(DisplayServer Win32)
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
+elseif(ANDROID)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR -DVK_USE_PLATFORM_ANDROID_KHX)
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+elseif(APPLE)
+ add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
+elseif(UNIX AND NOT APPLE) # i.e. Linux
if(BUILD_WSI_XCB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XCB_KHX)
endif()
@@ -57,8 +52,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-DVK_USE_PLATFORM_MIR_KHR -DVK_USE_PLATFORM_MIR_KHX)
include_directories(${MIR_INCLUDE_DIR})
endif()
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
else()
message(FATAL_ERROR "Unsupported Platform!")
endif()
@@ -71,9 +64,9 @@ if(WIN32)
if(CMAKE_GENERATOR MATCHES "^Visual Studio.*")
foreach(config_file ${ICD_JSON_FILES})
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json)
- file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json)
+ file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${config_file}.json dst_json)
add_custom_target(${config_file}-json ALL COMMAND copy ${src_json} ${dst_json} VERBATIM)
- set_target_properties(${config_file}-json PROPERTIES FOLDER ${TOOLS_TARGET_FOLDER})
+ set_target_properties(${config_file}-json PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
endforeach(config_file)
else()
foreach(config_file ${ICD_JSON_FILES})
@@ -92,13 +85,15 @@ elseif(APPLE)
foreach(config_file ${ICD_JSON_FILES})
add_custom_target(${config_file}-json ALL
DEPENDS mk_icd_config_dir
- COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json $<CONFIG>
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json
+ $<CONFIG> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${config_file}.json
VERBATIM)
endforeach(config_file)
else()
foreach(config_file ${ICD_JSON_FILES})
add_custom_target(${config_file}-json ALL
- COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json
+ ${config_file}.json
VERBATIM)
endforeach(config_file)
endif()
@@ -107,7 +102,10 @@ else()
# extra setup for out-of-tree builds
if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
foreach(config_file ${ICD_JSON_FILES})
- add_custom_target(${config_file}-json ALL COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json VERBATIM)
+ add_custom_target(${config_file}-json ALL
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json
+ ${config_file}.json
+ VERBATIM)
endforeach(config_file)
endif()
endif()
@@ -115,7 +113,7 @@ endif()
# Custom target for generated vulkan helper file dependencies
set(icd_generate_helper_files_DEPENDS)
add_custom_target(icd_generate_helper_files DEPENDS vk_typemap_helper.h)
-set_target_properties(icd_generate_helper_files PROPERTIES FOLDER ${TOOLS_TARGET_FOLDER})
+set_target_properties(icd_generate_helper_files PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
run_vk_xml_generate(vulkan_tools_helper_file_generator.py vk_typemap_helper.h)
# For ICD with a direct dependency on a project with the same name, use it.
@@ -125,7 +123,7 @@ if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
endforeach(config_file)
endif()
add_custom_target(generate_icd_files DEPENDS mock_icd.h mock_icd.cpp)
-set_target_properties(generate_icd_files PROPERTIES FOLDER ${TOOLS_TARGET_FOLDER})
+set_target_properties(generate_icd_files PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
if(WIN32)
macro(add_vk_icd target)
@@ -133,7 +131,7 @@ if(WIN32)
add_custom_target(copy-${target}-def-file ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} VkICD_${target}.def
VERBATIM)
- set_target_properties(copy-${target}-def-file PROPERTIES FOLDER ${TOOLS_TARGET_FOLDER})
+ set_target_properties(copy-${target}-def-file PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
add_library(VkICD_${target} SHARED ${ARGN} VkICD_${target}.def)
add_dependencies(VkICD_${target} icd_generate_helper_files generate_icd_files)
# target_link_Libraries(VkICD_${target} VkICD_utils)
@@ -157,14 +155,17 @@ else()
# target_link_Libraries(VkICD_${target} VkICD_utils)
add_dependencies(VkICD_${target} icd_generate_helper_files generate_icd_files)
set_target_properties(VkICD_${target} PROPERTIES LINK_FLAGS "-Wl,-export-dynamic,-Bsymbolic,--exclude-libs,ALL")
- if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND INSTALL_ICD)
+ if((UNIX AND NOT APPLE) AND INSTALL_ICD) # i.e. Linux
install(TARGETS VkICD_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endmacro()
endif()
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR} ${VulkanHeaders_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR} ${CMAKE_BINARY_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${VulkanHeaders_INCLUDE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${PROJECT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR})
if(WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
@@ -187,7 +188,7 @@ run_vk_xml_generate(mock_icd_generator.py mock_icd.cpp)
add_vk_icd(mock_icd mock_icd.cpp mock_icd.h)
# JSON file(s) install targets. For Linux, need to remove the "./" from the library path before installing to system directories.
-if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND INSTALL_ICD)
+if((UNIX AND NOT APPLE) AND INSTALL_ICD) # i.e. Linux
foreach(config_file ${ICD_JSON_FILES})
add_custom_target(${config_file}-staging-json ALL
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/staging-json
@@ -196,8 +197,8 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND INSTALL_ICD)
${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json
VERBATIM
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json DESTINATION
- ${CMAKE_INSTALL_DATAROOTDIR}/vulkan/icd.d)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/vulkan/icd.d)
endforeach(config_file)
endif()
@@ -207,4 +208,3 @@ if(WIN32 AND INSTALL_ICD)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json DESTINATION ${CMAKE_INSTALL_LIBDIR})
endforeach(config_file)
endif()
-
diff --git a/vulkaninfo/CMakeLists.txt b/vulkaninfo/CMakeLists.txt
index 6bbfd9d1..9d604cb5 100644
--- a/vulkaninfo/CMakeLists.txt
+++ b/vulkaninfo/CMakeLists.txt
@@ -28,7 +28,7 @@ else()
add_executable(vulkaninfo vulkaninfo.c)
endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if(UNIX AND NOT APPLE) # i.e. Linux
include(FindPkgConfig)
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
@@ -64,7 +64,7 @@ if(APPLE)
target_link_libraries(vulkaninfo ${Vulkan_LIBRARY} "-framework AppKit -framework QuartzCore")
target_include_directories(vulkaninfo PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/macOS/vulkaninfo ${VulkanHeaders_INCLUDE_DIR})
else()
- target_link_libraries(vulkaninfo ${LIBVK})
+ target_link_libraries(vulkaninfo Vulkan::Vulkan)
endif()
# Create vulkaninfo application bundle for MacOS
@@ -87,7 +87,11 @@ if(WIN32)
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${configuration} MATCHES "/MD")
- string(REGEX REPLACE "/MD" "/MT" ${configuration} "${${configuration}}")
+ string(REGEX
+ REPLACE "/MD"
+ "/MT"
+ ${configuration}
+ "${${configuration}}")
endif()
endforeach()
@@ -101,4 +105,3 @@ if(APPLE)
else()
install(TARGETS vulkaninfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
-
diff --git a/vulkaninfo/macOS/vulkaninfo.cmake b/vulkaninfo/macOS/vulkaninfo.cmake
index d69610d8..1927a38e 100644
--- a/vulkaninfo/macOS/vulkaninfo.cmake
+++ b/vulkaninfo/macOS/vulkaninfo.cmake
@@ -28,8 +28,11 @@ add_executable(vulkaninfo-bundle
${CMAKE_CURRENT_SOURCE_DIR}/macOS/Resources/LunarGIcon.icns
${CMAKE_CURRENT_SOURCE_DIR}/macOS/vulkaninfo/metal_view.m
${CMAKE_CURRENT_SOURCE_DIR}/macOS/vulkaninfo/metal_view.h)
-set_target_properties(
- vulkaninfo-bundle PROPERTIES OUTPUT_NAME vulkaninfo MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/macOS/Info.plist)
+set_target_properties(vulkaninfo-bundle
+ PROPERTIES OUTPUT_NAME
+ vulkaninfo
+ MACOSX_BUNDLE_INFO_PLIST
+ ${CMAKE_CURRENT_SOURCE_DIR}/macOS/Info.plist)
# We do this so vulkaninfo is linked to an individual library and NOT a framework.
target_link_libraries(vulkaninfo-bundle ${Vulkan_LIBRARY} "-framework AppKit -framework QuartzCore")
target_include_directories(vulkaninfo-bundle PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/macOS/vulkaninfo ${VulkanHeaders_INCLUDE_DIR})
@@ -60,15 +63,10 @@ endif()
# Keep RPATH so fixup_bundle can use it to find libraries
set_target_properties(vulkaninfo-bundle PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
install(TARGETS vulkaninfo-bundle BUNDLE DESTINATION "vulkaninfo")
-# Fix up the library search path in the executable to find (loader) libraries
-# in the bundle. When fixup_bundle() is passed a bundle in the first argument,
-# it looks at the Info.plist file to determine the BundleExecutable. In this
-# case, the executable is a script, which can't be fixed up. Instead pass it
-# the explicit name of the executable.
-install(
- CODE
- "
+# Fix up the library search path in the executable to find (loader) libraries in the bundle. When fixup_bundle() is passed a bundle
+# in the first argument, it looks at the Info.plist file to determine the BundleExecutable. In this case, the executable is a
+# script, which can't be fixed up. Instead pass it the explicit name of the executable.
+install(CODE "
include(BundleUtilities)
fixup_bundle(\${CMAKE_INSTALL_PREFIX}/vulkaninfo/vulkaninfo.app/Contents/MacOS/vulkaninfo \"\" \"\")
- "
-)
+ ")