2018-06-26 20:36:20 +00:00
# ~~~
2019-07-19 00:17:34 +00:00
# Copyright (c) 2014-2019 Valve Corporation
# Copyright (c) 2014-2019 LunarG, Inc.
2018-06-26 20:36:20 +00:00
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~
2019-07-16 21:11:25 +00:00
cmake_minimum_required ( VERSION 3.10.2 )
2018-04-18 17:46:21 +00:00
2018-09-20 18:12:14 +00:00
# Apple: Must be set before enable_language() or project() as it may influence configuration of the toolchain and flags.
2018-04-18 17:46:21 +00:00
set ( CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version" )
2021-09-21 17:37:14 +00:00
# If we are building in Visual Studio 2015 and with a CMake version 3.19 or greater, we need to set this variable
# so that CMake will choose a Windows SDK version higher than 10.0.14393.0, as dxgi1_6.h is only found in Windows SDK
# 10.0.17763 and higher.
set ( CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM OFF )
2018-05-13 16:59:16 +00:00
project ( Vulkan-Loader )
2018-09-20 18:12:14 +00:00
2019-09-18 21:39:34 +00:00
set_property ( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS API_NAME= "Vulkan" )
2014-07-24 14:36:15 +00:00
2020-03-17 18:11:59 +00:00
# Enable beta Vulkan extensions
add_definitions ( -DVK_ENABLE_BETA_EXTENSIONS )
2021-09-23 16:09:26 +00:00
if ( UPDATE_DEPS )
find_package ( PythonInterp 3 REQUIRED )
if ( CMAKE_GENERATOR_PLATFORM )
set ( _target_arch ${ CMAKE_GENERATOR_PLATFORM } )
else ( )
message ( WARNING "CMAKE_GENERATOR_PLATFORM not set. Using x64 as target architecture." )
set ( _target_arch x64 )
endif ( )
if ( NOT CMAKE_BUILD_TYPE )
message ( WARNING "CMAKE_BUILD_TYPE not set. Using Debug for dependency build type" )
set ( _build_type Debug )
else ( )
set ( _build_type ${ CMAKE_BUILD_TYPE } )
endif ( )
2021-09-23 21:15:08 +00:00
set ( _build_tests_arg "" )
if ( NOT BUILD_TESTS )
set ( _build_tests_arg "--optional=tests" )
endif ( )
2021-09-23 16:09:26 +00:00
message ( "********************************************************************************" )
message ( "* NOTE: Adding target vl_update_deps to run as needed for updating *" )
message ( "* dependencies. *" )
message ( "********************************************************************************" )
# Add a target so that update_deps.py will run when necessary
# NOTE: This is triggered off of the timestamps of known_good.json and helper.cmake
add_custom_command ( OUTPUT ${ CMAKE_CURRENT_LIST_DIR } /external/helper.cmake
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s c r i p t s / u p d a t e _ d e p s . p y - - d i r $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / e x t e r n a l - - a r c h $ { _ t a r g e t _ a r c h } - - c o n f i g $ { _ b u i l d _ t y p e } - - g e n e r a t o r " $ { C M A K E _ G E N E R A T O R } " $ { _ b u i l d _ t e s t s _ a r g }
D E P E N D S $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s c r i p t s / k n o w n _ g o o d . j s o n )
add_custom_target ( vl_update_deps DEPENDS ${ CMAKE_CURRENT_LIST_DIR } /external/helper.cmake )
# Check if update_deps.py needs to be run on first cmake run
if ( ${ CMAKE_CURRENT_LIST_DIR } /scripts/known_good.json IS_NEWER_THAN ${ CMAKE_CURRENT_LIST_DIR } /external/helper.cmake )
execute_process (
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s c r i p t s / u p d a t e _ d e p s . p y - - d i r $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / e x t e r n a l - - a r c h $ { _ t a r g e t _ a r c h } - - c o n f i g $ { _ b u i l d _ t y p e } - - g e n e r a t o r " $ { C M A K E _ G E N E R A T O R } " $ { _ b u i l d _ t e s t s _ a r g }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ L I S T _ D I R }
R E S U L T _ V A R I A B L E _ u p d a t e _ d e p s _ r e s u l t
)
if ( NOT ( ${ _update_deps_result } EQUAL 0 ) )
message ( FATAL_ERROR "Could not run update_deps.py which is necessary to download dependencies." )
endif ( )
endif ( )
include ( ${ CMAKE_CURRENT_LIST_DIR } /external/helper.cmake )
else ( )
message ( "********************************************************************************" )
message ( "* NOTE: Not adding target to run update_deps.py automatically. *" )
message ( "********************************************************************************" )
find_package ( PythonInterp 3 QUIET )
endif ( )
2016-12-07 23:13:35 +00:00
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
2019-07-19 00:17:34 +00:00
find_package ( PythonInterp 3 QUIET )
2015-12-15 16:25:29 +00:00
2021-09-23 21:15:08 +00:00
option ( BUILD_TESTS "Build Tests" OFF )
2020-04-01 19:26:02 +00:00
2021-04-23 18:34:05 +00:00
if ( BUILD_TESTS )
enable_testing ( )
endif ( )
2020-04-01 19:26:02 +00:00
if ( APPLE )
option ( BUILD_STATIC_LOADER "Build a loader that can be statically linked" OFF )
endif ( )
2021-09-18 00:00:18 +00:00
if ( WIN32 )
# Optional: Allow specify the exact version used in the loader dll
# Format is major.minor.patch.build
set ( BUILD_DLL_VERSIONINFO "" CACHE STRING "Set the version to be used in the loader.rc file. Default value is the currently generated header version" )
2021-09-27 23:37:47 +00:00
option ( RELEASE_BUILD "Configures the loader.rc file for a \" Release\ " build. Used for SDK builds primarily. Does not change CMAKE_BUILD_TYPE. Default is off." OFF )
2021-09-18 00:00:18 +00:00
endif ( )
2020-04-01 19:26:02 +00:00
if ( BUILD_STATIC_LOADER )
2020-10-05 22:58:04 +00:00
message ( WARNING "The BUILD_STATIC_LOADER option has been set. Note that this will only work on MacOS and is not supported "
2020-04-01 19:26:02 +00:00
" o r t e s t e d a s p a r t o f t h e l o a d e r . U s e i t a t y o u r o w n r i s k . " )
2020-02-19 02:40:29 +00:00
endif ( )
2019-02-08 04:53:48 +00:00
if ( TARGET Vulkan::Headers )
message ( STATUS "Using Vulkan headers from Vulkan::Headers target" )
2019-07-27 17:13:37 +00:00
get_target_property ( VulkanHeaders_INCLUDE_DIRS Vulkan::Headers INTERFACE_INCLUDE_DIRECTORIES )
2019-02-08 04:53:48 +00:00
get_target_property ( VulkanRegistry_DIR Vulkan::Registry INTERFACE_INCLUDE_DIRECTORIES )
else ( )
find_package ( VulkanHeaders )
if ( NOT ${ VulkanHeaders_FOUND } )
message ( FATAL_ERROR "Could not find Vulkan headers path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
" i n s t a l l a t i o n o f t h e V u l k a n - H e a d e r s r e p o s i t o r y . " )
endif ( )
if ( NOT ${ VulkanRegistry_FOUND } )
message ( FATAL_ERROR "Could not find Vulkan registry path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
" i n s t a l l a t i o n o f t h e V u l k a n - H e a d e r s r e p o s i t o r y . " )
endif ( )
# set up the Vulkan::Headers target for consistency
add_library ( vulkan-headers INTERFACE )
2020-06-19 10:19:08 +00:00
target_include_directories ( vulkan-headers SYSTEM INTERFACE "${VulkanHeaders_INCLUDE_DIRS}" )
2019-02-08 04:53:48 +00:00
add_library ( Vulkan::Headers ALIAS vulkan-headers )
2018-09-20 18:12:14 +00:00
endif ( )
2018-05-31 20:18:40 +00:00
2017-10-31 23:05:03 +00:00
option ( USE_CCACHE "Use ccache" OFF )
2018-06-30 18:07:29 +00:00
if ( USE_CCACHE )
2017-10-31 23:05:03 +00:00
find_program ( CCACHE_FOUND ccache )
if ( CCACHE_FOUND )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
2018-09-20 18:12:14 +00:00
endif ( )
2017-10-31 23:05:03 +00:00
endif ( )
2018-05-25 17:37:20 +00:00
include ( GNUInstallDirs )
2018-09-20 18:12:14 +00:00
if ( UNIX AND NOT APPLE ) # i.e.: Linux
include ( FindPkgConfig )
2018-05-25 17:37:20 +00:00
endif ( )
2017-12-12 15:33:01 +00:00
if ( APPLE )
2018-06-30 18:07:29 +00:00
# CMake versions 3 or later need CMAKE_MACOSX_RPATH defined. This avoids the CMP0042 policy message.
2017-12-12 15:33:01 +00:00
set ( CMAKE_MACOSX_RPATH 1 )
endif ( )
2021-08-17 02:01:25 +00:00
find_package ( Git )
2021-10-06 11:46:58 +00:00
if ( GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git/HEAD" )
2021-08-17 02:01:25 +00:00
execute_process (
C O M M A N D $ { G I T _ E X E C U T A B L E } d e s c r i b e - - t a g s - - a l w a y s
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R }
O U T P U T _ V A R I A B L E G I T _ T A G _ I N F O )
string ( REGEX REPLACE "\n$" "" GIT_TAG_INFO "${GIT_TAG_INFO}" )
file ( READ ".git/HEAD" GIT_HEAD_REF_INFO )
if ( GIT_HEAD_REF_INFO )
string ( REGEX MATCH "ref: refs/heads/(.*)" _ ${ GIT_HEAD_REF_INFO } )
if ( CMAKE_MATCH_1 )
set ( GIT_BRANCH_NAME ${ CMAKE_MATCH_1 } )
else ( )
set ( GIT_BRANCH_NAME ${ GIT_HEAD_REF_INFO } )
endif ( )
string ( REGEX REPLACE "\n$" "" GIT_BRANCH_NAME "${GIT_BRANCH_NAME}" )
else ( )
set ( GIT_BRANCH_NAME "--unknown--" )
endif ( )
else ( )
set ( GIT_BRANCH_NAME "--unknown--" )
set ( GIT_TAG_INFO "--unknown--" )
endif ( )
2018-09-20 18:12:14 +00:00
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 ( )
# Enable IDE GUI folders. "Helper targets" that don't have interesting source code should set their FOLDER property to this
2018-02-01 16:27:03 +00:00
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
2018-06-14 22:53:01 +00:00
set ( LOADER_HELPER_FOLDER "Helper Targets" )
2018-02-01 16:27:03 +00:00
2018-09-20 18:12:14 +00:00
if ( UNIX )
2018-06-30 18:07:29 +00:00
set (
F A L L B A C K _ C O N F I G _ D I R S " / e t c / x d g "
C A C H E
S T R I N G
" S e a r c h p a t h t o u s e w h e n X D G _ C O N F I G _ D I R S i s u n s e t o r e m p t y o r t h e c u r r e n t p r o c e s s i s S U I D / S G I D . D e f a u l t i s f r e e d e s k t o p c o m p l i a n t . "
)
set (
F A L L B A C K _ D A T A _ D I R S " / u s r / l o c a l / s h a r e : / u s r / s h a r e "
C A C H E
S T R I N G
" S e a r c h p a t h t o u s e w h e n X D G _ D A T A _ D I R S i s u n s e t o r e m p t y o r t h e c u r r e n t p r o c e s s i s S U I D / S G I D . D e f a u l t i s f r e e d e s k t o p c o m p l i a n t . "
)
2019-06-25 08:53:21 +00:00
set (
S Y S C O N F D I R " "
C A C H E
S T R I N G
" S y s t e m - w i d e s e a r c h d i r e c t o r y . I f n o t s e t o r e m p t y , C M A K E _ I N S T A L L _ F U L L _ S Y S C O N F D I R a n d / e t c a r e u s e d . "
)
2017-12-12 15:33:01 +00:00
endif ( )
2017-02-19 19:14:24 +00:00
2018-09-20 18:12:14 +00:00
if ( UNIX AND NOT APPLE ) # i.e.: Linux
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 )
2020-07-04 20:53:59 +00:00
option ( BUILD_WSI_DIRECTFB_SUPPORT "Build DirectFB WSI support" OFF )
2021-03-13 00:17:03 +00:00
option ( BUILD_WSI_SCREEN_QNX_SUPPORT "Build QNX Screen WSI support" OFF )
2015-11-25 20:26:15 +00:00
2018-06-30 18:07:29 +00:00
if ( BUILD_WSI_XCB_SUPPORT )
2016-12-07 23:13:35 +00:00
find_package ( XCB REQUIRED )
endif ( )
2018-06-30 18:07:29 +00:00
if ( BUILD_WSI_XLIB_SUPPORT )
2016-12-07 23:13:35 +00:00
find_package ( X11 REQUIRED )
endif ( )
2018-06-30 18:07:29 +00:00
if ( BUILD_WSI_WAYLAND_SUPPORT )
2016-12-07 23:13:35 +00:00
find_package ( Wayland REQUIRED )
2020-06-19 10:19:08 +00:00
include_directories ( SYSTEM ${ WAYLAND_CLIENT_INCLUDE_DIR } )
2016-12-07 23:13:35 +00:00
endif ( )
2020-07-04 20:53:59 +00:00
if ( BUILD_WSI_DIRECTFB_SUPPORT )
find_package ( DirectFB REQUIRED )
include_directories ( SYSTEM ${ DIRECTFB_INCLUDE_DIR } )
endif ( )
2021-03-11 03:17:20 +00:00
2021-03-13 00:17:03 +00:00
if ( BUILD_WSI_SCREEN_QNX_SUPPORT )
2021-03-11 03:17:20 +00:00
# Part of OS, no additional include directories are 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
2018-09-20 18:12:14 +00:00
option ( BUILD_LOADER "Build loader" ON )
2018-06-30 18:07:29 +00:00
if ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" )
2019-09-18 21:39:34 +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
2018-06-30 18:07:29 +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
2019-09-18 21:39:34 +00:00
if ( CMAKE_COMPILER_IS_GNUCC )
set ( COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Wno-stringop-truncation -Wno-stringop-overflow" )
if ( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 7.1 )
set ( COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Wimplicit-fallthrough=0" )
endif ( )
2017-07-12 16:06:19 +00:00
endif ( )
2018-06-30 18:07:29 +00:00
if ( APPLE )
2017-12-12 15:33:01 +00:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILE_FLAGS}" )
2021-10-01 22:46:33 +00:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11 -fno-rtti" )
2019-09-18 21:39:34 +00:00
#clang-cl on Windows
elseif ( ( CMAKE_C_COMPILER_ID MATCHES "Clang" ) AND ( CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" ) )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xclang -std=c99 ${COMMON_COMPILE_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -std=c++11 -fno-rtti" )
# clang (not clang-cl) or gcc
2017-12-12 15:33:01 +00:00
else ( )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}" )
2019-09-18 21:39:34 +00:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti" )
2017-12-12 15:33:01 +00:00
endif ( )
2019-09-18 21:39:34 +00:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS}" )
2018-06-30 18:07:29 +00:00
if ( UNIX )
2014-08-04 00:03:57 +00:00
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
2018-09-20 18:12:14 +00:00
if ( MSVC )
2018-10-29 21:57:54 +00:00
# /WX: Treat warnings as errors
# /GR-: Disable RTTI
# /w34456: Warn about nested declarations
# /w34701, /w34703: Warn about potentially uninitialized variables
# /w34057: Warn about different indirection types.
# /w34245: Warn about signed/unsigned mismatch.
set ( MSVC_LOADER_COMPILE_OPTIONS /WX /GR- /w34456 /w34701 /w34703 /w34057 /w34245 )
2021-08-16 17:50:43 +00:00
# Replace /GR with an empty string, prevents warnings of /GR being overriden by /GR-
# Newer CMake versions (3.20) have better solutions for this through policy - using the old
# way while waiting for when updating can occur
string ( REPLACE "/GR" "" CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS } )
2016-05-12 16:28:57 +00:00
endif ( )
2019-07-19 00:17:34 +00:00
# Optional codegen target
if ( PYTHONINTERP_FOUND )
add_custom_target ( VulkanLoader_generated_source
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { P R O J E C T _ S O U R C E _ D I R } / s c r i p t s / g e n e r a t e _ s o u r c e . p y
$ { V u l k a n R e g i s t r y _ D I R } - - i n c r e m e n t a l
)
else ( )
message ( "WARNING: VulkanLoader_generated_source target requires python 3" )
endif ( )
2017-01-23 16:08:20 +00:00
2018-09-20 18:12:14 +00:00
if ( UNIX )
2019-09-18 21:39:34 +00:00
set_property ( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS FALLBACK_CONFIG_DIRS= "${FALLBACK_CONFIG_DIRS}" FALLBACK_DATA_DIRS= "${FALLBACK_DATA_DIRS}" )
2017-02-19 19:14:24 +00:00
2019-06-25 08:53:21 +00:00
if ( NOT ( SYSCONFDIR STREQUAL "" ) )
# SYSCONFDIR is specified, use it and do not force /etc.
2019-09-18 21:39:34 +00:00
set_property ( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS SYSCONFDIR= "${SYSCONFDIR}" )
2019-06-25 08:53:21 +00:00
else ( )
2019-09-18 21:39:34 +00:00
set_property ( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS SYSCONFDIR= "${CMAKE_INSTALL_FULL_SYSCONFDIR}" )
2019-06-25 08:53:21 +00:00
# Make sure /etc is searched by the loader
if ( NOT ( CMAKE_INSTALL_FULL_SYSCONFDIR STREQUAL "/etc" ) )
2019-09-18 21:39:34 +00:00
set_property ( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS EXTRASYSCONFDIR= "/etc" )
2019-06-25 08:53:21 +00:00
endif ( )
2016-10-22 19:20:29 +00:00
endif ( )
2014-10-03 21:34:53 +00:00
endif ( )
2017-03-14 23:11:24 +00:00
# uninstall target
2018-06-12 21:10:23 +00:00
if ( NOT TARGET uninstall )
2018-09-20 18:12:14 +00:00
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
2018-06-30 18:07:29 +00:00
I M M E D I A T E
@ O N L Y )
add_custom_target ( uninstall COMMAND ${ CMAKE_COMMAND } -P ${ CMAKE_CURRENT_BINARY_DIR } /cmake_uninstall.cmake )
2018-06-14 22:53:01 +00:00
set_target_properties ( uninstall PROPERTIES FOLDER ${ LOADER_HELPER_FOLDER } )
2018-06-12 21:10:23 +00:00
endif ( )
2016-10-12 23:36:35 +00:00
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 )
2021-09-23 21:15:08 +00:00
# Set gtest build configuration
# Attempt to enable if it is available.
if ( TARGET gtest )
# Already enabled as a target (perhaps by a project enclosing this one)
message ( STATUS "Vulkan-Loader/external: " "googletest already configured - using it" )
elseif ( IS_DIRECTORY "${GOOGLETEST_INSTALL_DIR}/googletest" )
set ( BUILD_GTEST ON CACHE BOOL "Builds the googletest subproject" )
set ( BUILD_GMOCK OFF CACHE BOOL "Builds the googlemock subproject" )
2021-11-04 20:36:02 +00:00
set ( gtest_force_shared_crt ON CACHE BOOL "Link gtest runtimes dynamically" FORCE )
2021-09-23 21:15:08 +00:00
set ( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries" )
# The googletest directory exists, so enable it as a target.
message ( STATUS "Vulkan-Loader/external: " "googletest found - configuring it for tests" )
add_subdirectory ( "${GOOGLETEST_INSTALL_DIR}/googletest" )
else ( )
message ( SEND_ERROR "Could not find googletest directory. Be sure to run update_deps.py with the --tests option to download the appropriate version of googletest" )
set ( BUILD_TESTS OFF )
endif ( )
if ( WIN32 )
if ( TARGET detours )
# Already enabled as a target (perhaps by a project enclosing this one)
message ( STATUS "Vulkan-Loader/external: " "detours already configured - using it" )
else ( )
if ( IS_DIRECTORY ${ DETOURS_INSTALL_DIR } )
# The detours directory exists, so enable it as a target.
message ( STATUS "Vulkan-Loader/external: " "detours found - configuring it for tests" )
else ( )
message ( SEND_ERROR "Could not find detours directory. Be sure to run update_deps.py with the --tests option to download the appropriate version of detours" )
set ( BUILD_TESTS OFF )
endif ( )
add_library ( detours STATIC
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / c r e a t w t h . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d e t o u r s . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d e t o u r s . h
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d e t v e r . h
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d i s a s m . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d i s o l a r m . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d i s o l a r m 6 4 . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d i s o l i a 6 4 . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d i s o l x 6 4 . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / d i s o l x 8 6 . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / i m a g e . c p p
$ { D E T O U R S _ I N S T A L L _ D I R } / s r c / m o d u l e s . c p p
)
target_include_directories ( detours PUBLIC ${ DETOURS_INSTALL_DIR } /src )
macro ( GET_WIN32_WINNT version )
if ( WIN32 AND CMAKE_SYSTEM_VERSION )
set ( ver ${ CMAKE_SYSTEM_VERSION } )
string ( REGEX MATCH "^([0-9]+).([0-9])" ver ${ ver } )
string ( REGEX MATCH "^([0-9]+)" verMajor ${ ver } )
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
if ( "${verMajor}" MATCHES "10" )
set ( verMajor "A" )
string ( REGEX REPLACE "^([0-9]+)" ${ verMajor } ver ${ ver } )
endif ( "${verMajor}" MATCHES "10" )
# Remove all remaining '.' characters.
string ( REPLACE "." "" ver ${ ver } )
# Prepend each digit with a zero.
string ( REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ ver } )
set ( ${ version } "0x${ver}" )
endif ( )
endmacro ( )
set ( DETOURS_MAJOR_VERSION "4" )
set ( DETOURS_MINOR_VERSION "0" )
set ( DETOURS_PATCH_VERSION "1" )
set ( DETOURS_VERSION "${DETOURS_MAJOR_VERSION}.${DETOURS_MINOR_VERSION}.${DETOURS_PATCH_VERSION}" )
target_include_directories ( detours PUBLIC ${ DETOURS_INSTALL_DIR } /src )
if ( MSVC_VERSION GREATER_EQUAL 1700 )
target_compile_definitions ( detours PUBLIC DETOURS_CL_17_OR_NEWER )
endif ( MSVC_VERSION GREATER_EQUAL 1700 )
GET_WIN32_WINNT ( ver )
if ( ver EQUAL 0x0700 )
target_compile_definitions ( detours PUBLIC _USING_V110_SDK71_ DETOURS_WIN_7 )
endif ( ver EQUAL 0x0700 )
target_compile_definitions ( detours PUBLIC "_WIN32_WINNT=${ver}" )
if ( "${CMAKE_SIZEOF_VOID_P}" EQUAL "8" )
target_compile_definitions ( detours PUBLIC "DETOURS_TARGET_PROCESSOR=X64" DETOURS_X64 DETOURS_64BIT _AMD64_ )
else ( "${CMAKE_SIZEOF_VOID_P}" EQUAL "8" )
target_compile_definitions ( detours PUBLIC "DETOURS_TARGET_PROCESSOR=X86" DETOURS_X86 _X86_ )
endif ( "${CMAKE_SIZEOF_VOID_P}" EQUAL "8" )
target_compile_definitions ( detours PUBLIC "DETOURS_VERSION=0x4c0c1" WIN32_LEAN_AND_MEAN )
if ( MSVC )
target_compile_definitions ( detours PUBLIC "_CRT_SECURE_NO_WARNINGS=1" )
set_target_properties ( detours PROPERTIES COMPILE_FLAGS /EHsc )
endif ( )
endif ( )
endif ( )
if ( BUILD_TESTS )
add_subdirectory ( tests ${ CMAKE_BINARY_DIR } /tests )
endif ( )
2017-10-13 15:26:20 +00:00
endif ( )