Add ktx
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# Copyright 2015-2020 The Khronos Group Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# include(CMakeFindDependencyMacro)
|
||||
# find_dependency()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/KtxTargets.cmake")
|
||||
@@ -0,0 +1,19 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf2822
|
||||
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;}
|
||||
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
|
||||
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww10020\viewh19580\viewkind0
|
||||
\deftab720
|
||||
\pard\pardeftab720\partightenfactor0
|
||||
|
||||
\f0\fs26 \cf2 \expnd0\expndtw0\kerning0
|
||||
Copyright 2010-2020 The Khronos Group Inc.\
|
||||
SPDX-License-Identifier: Apache-2.0\
|
||||
\
|
||||
This is open source software. The majority of the source is licensed under {\field{\*\fldinst{HYPERLINK "http://www.apache.org/licenses/LICENSE-2.0"}}{\fldrslt Apache 2.0.}} Follow the link for the full license text. Exceptions and full details of contributors are listed in {\field{\*\fldinst{HYPERLINK "https://github.com/KhronosGroup/KTX-Software/blob/master/LICENSE.md"}}{\fldrslt LICENSE.md}} in the KTX-Software repository.\
|
||||
\
|
||||
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 {\field{\*\fldinst{HYPERLINK "http://www.apache.org/licenses/LICENSE-2.0"}}{\fldrslt License}} for the specific language governing permissions and limitations under the License.\
|
||||
\pard\pardeftab720\sa140\partightenfactor0
|
||||
\cf2 \
|
||||
\pard\pardeftab720\sa280\partightenfactor0
|
||||
\cf2 libktx is the work of Mark Callow based on work by Georg Kolling and Jacob Str\'f6m with contributions borrowed from Troy Hanson, Johannes van Waveren, Lode Vandevenne and Rich Geldreich. The KTX tool suite is the work of RasterGrid Kft. The legacy tools are the work of Mark Callow. The CMake-based build setup used to produce this installer is the work of Andreas Atteneder.}
|
||||
@@ -0,0 +1,2 @@
|
||||
SPDX-FileCopyrightText: 2010-2020 The Khronos Group Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
@@ -0,0 +1,43 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf2822
|
||||
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;\f1\fnil\fcharset0 LucidaGrande;\f2\fnil\fcharset0 HelveticaNeue-Italic;
|
||||
\f3\fnil\fcharset0 HelveticaNeue-Bold;}
|
||||
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
|
||||
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0\cname textColor;}
|
||||
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid2\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li1440\lin1440 }{\listname ;}\listid1}
|
||||
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{square\}}{\leveltext\leveltemplateid101\'01\uc0\u9642 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid102\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li1440\lin1440 }{\listname ;}\listid2}}
|
||||
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww19120\viewh13180\viewkind0
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
|
||||
|
||||
\f0\fs26 \cf2 This will install the following:\
|
||||
\
|
||||
\pard\tx220\tx720\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li720\fi-720\pardirnatural\partightenfactor0
|
||||
|
||||
\f1 \cf2 \uc0\u9642
|
||||
\f0 ktx - Unified front end for the KTX tool suite:\
|
||||
\pard\tx940\tx1440\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li1440\fi-1440\pardirnatural\partightenfactor0
|
||||
\ls1\ilvl1\cf2 {\listtext \uc0\u8259 }create - Create KTX v2 files.\
|
||||
{\listtext \uc0\u8259 }compare - Compare KTX v2 files.\
|
||||
{\listtext \uc0\u8259 }deflate - Apply Zstd or ZLIB compression to a KTX v2 file.\
|
||||
{\listtext \uc0\u8259 }encode - Encode a KTX v2 file to Basis Universal or ASTC.\
|
||||
{\listtext \uc0\u8259 }extract - Extract an image from a KTX v2 file.\
|
||||
{\listtext \uc0\u8259 }info - Display info about a KTX file.\
|
||||
{\listtext \uc0\u8259 }transcode - Transcode a KTX v2 file.\
|
||||
{\listtext \uc0\u8259 }validate - Validate a KTX v2 file.\
|
||||
\pard\tx220\tx720\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li720\fi-720\pardirnatural\partightenfactor0
|
||||
|
||||
\f1 \cf2 \uc0\u9642
|
||||
\f0 Legacy tools which will be removed in the next release:\
|
||||
\pard\tx940\tx1440\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li1440\fi-1440\pardirnatural\partightenfactor0
|
||||
\ls2\ilvl1\cf2 {\listtext \uc0\u8259 }ktx2check - Check KTX v2 files for validity.\
|
||||
{\listtext \uc0\u8259 }ktxinfo - Print info about a KTX file in human-readable form.\
|
||||
{\listtext \uc0\u8259 }ktx2ktx2 - Convert a KTX v1 file to a KTX v2 file.\
|
||||
{\listtext \uc0\u8259 }ktxsc - Supercompress a KTX v2 file.\
|
||||
{\listtext \uc0\u8259 }toktx - Create a KTX v1 or v2 file from .jpg, .png or Netpbm images.\
|
||||
\pard\tx566\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
|
||||
\cf2 \
|
||||
By clicking the
|
||||
\f2\i Customize
|
||||
\f0\i0 button at the bottom of the
|
||||
\f3\b Installation Type
|
||||
\f0\b0 screen you can add installation of the resources needed for developing applications using the KTX library.}
|
||||
@@ -0,0 +1,12 @@
|
||||
Copyright 2015-2020 The Khronos Group Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
This will install the following KTX tools along with libktx:
|
||||
|
||||
- ktx2check - Check KTX v2 files for validity.
|
||||
- ktxinfo - Print info about a KTX file in human-readable form.
|
||||
- ktx2ktx2 - Convert a KTX v1 file to a KTX v2 file.
|
||||
- ktxsc - Supercompress a KTX v2 file.
|
||||
- toktx - Create a KTX v1 or v2 file from .jpg, .png or Netpbm images.
|
||||
|
||||
It also installs the header files for development.
|
||||
@@ -0,0 +1,8 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf2513
|
||||
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
{\*\expandedcolortbl;;}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
|
||||
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
|
||||
|
||||
\f0\fs26 \cf0 This program will guide you through installation of the KTX tools and the optional KTX development resources on your system.}
|
||||
@@ -0,0 +1,160 @@
|
||||
# Copyright 2020 Andreas Atteneder
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Macro for setting up code signing on targets
|
||||
macro (set_code_sign target)
|
||||
if(APPLE)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${XCODE_CODE_SIGN_IDENTITY}"
|
||||
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${XCODE_DEVELOPMENT_TEAM}"
|
||||
XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--timestamp"
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS $<IF:$<CONFIG:Debug>,YES,NO>
|
||||
)
|
||||
if(IOS)
|
||||
set(set_pps FALSE)
|
||||
if(${ARGC} EQUAL 1)
|
||||
set(set_pps TRUE)
|
||||
elseif (NOT ${ARGV1} STREQUAL "NOPPS")
|
||||
set(set_pps TRUE)
|
||||
endif()
|
||||
if (${set_pps})
|
||||
set_property(TARGET ${target}
|
||||
PROPERTY XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER ${XCODE_PROVISIONING_PROFILE_SPECIFIER}
|
||||
)
|
||||
endif()
|
||||
unset(set_pps)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32 AND CODE_SIGN_KEY_VAULT)
|
||||
configure_windows_sign_params()
|
||||
if(SIGN_PARAMS)
|
||||
add_custom_command( TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND ${signtool_EXECUTABLE} sign ${SIGN_PARAMS} $<TARGET_FILE:${target}>
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endmacro (set_code_sign)
|
||||
|
||||
function(configure_windows_sign_params)
|
||||
if(NOT SIGN_PARAMS)
|
||||
if(CODE_SIGN_KEY_VAULT STREQUAL "Azure")
|
||||
# Use EV certificate in Azure key vault
|
||||
find_program(signtool_EXECUTABLE azuresigntool REQUIRED)
|
||||
if(signtool_EXECUTABLE)
|
||||
configure_azuresigntool_params()
|
||||
endif()
|
||||
else()
|
||||
# Use standard OV certificate in local certificate store.
|
||||
find_package(signtool REQUIRED)
|
||||
if(signtool_EXECUTABLE)
|
||||
configure_signtool_params()
|
||||
endif()
|
||||
endif()
|
||||
set(SIGN_PARAMS ${SIGN_PARAMS} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(configure_azuresigntool_params)
|
||||
if(NOT SIGN_PARAMS)
|
||||
foreach(param AZURE_KEY_VAULT_CERTIFICATE AZURE_KEY_VAULT_URL AZURE_KEY_VAULT_CLIENT_ID AZURE_KEY_VAULT_CLIENT_SECRET AZURE_KEY_VAULT_TENANT_ID)
|
||||
if(NOT ${param})
|
||||
message(SEND_ERROR "CODE_SIGN_KEY_VAULT set to \"Azure\" but necessary parameter ${param} is not set.")
|
||||
endif()
|
||||
endforeach()
|
||||
configure_common_params()
|
||||
set(SIGN_PARAMS ${SIGN_PARAMS}
|
||||
--azure-key-vault-url ${AZURE_KEY_VAULT_URL}
|
||||
--azure-key-vault-client-id ${AZURE_KEY_VAULT_CLIENT_ID}
|
||||
--azure-key-vault-client-secret ${AZURE_KEY_VAULT_CLIENT_SECRET}
|
||||
--azure-key-vault-tenant-id ${AZURE_KEY_VAULT_TENANT_ID}
|
||||
--azure-key-vault-certificate ${AZURE_KEY_VAULT_CERTIFICATE}
|
||||
#--verbose # Include additional output.
|
||||
#--quiet # Do not print any output to the console.
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(configure_signtool_params)
|
||||
if(NOT SIGN_PARAMS)
|
||||
# User store is preferred because importing the cert. does not need
|
||||
# admin elevation. However problems were encountered on Appveyor,
|
||||
# see comment at begin_build phase in .appveyor.yml, so use of local
|
||||
# machine store is also supported.
|
||||
if(CODE_SIGN_KEY_VAULT STREQUAL Machine)
|
||||
# Search in local machine certificate store
|
||||
set(store "/sm")
|
||||
elseif(CODE_SIGN_KEY_VAULT STREQUAL User)
|
||||
# Search in user's certificate store.
|
||||
unset(store)
|
||||
else()
|
||||
message(FATAL_ERROR "Unrecognized CODE_SIGN_KEY_VAULT value \"${CODE_SIGN_KEY_VAULT}\"")
|
||||
endif()
|
||||
if(LOCAL_KEY_VAULT_CERTIFICATE_THUMBPRINT)
|
||||
set(certopt /sha1)
|
||||
set(certid ${LOCAL_KEY_VAULT_CERTIFICATE_THUMBPRINT})
|
||||
elseif(LOCAL_KEY_VAULT_SIGNING_IDENTITY)
|
||||
set(certopt /n)
|
||||
set(certid ${LOCAL_KEY_VAULT_SIGNING_IDENTITY})
|
||||
else()
|
||||
message(FATAL_ERROR "CODE_SIGN_KEY_VAULT set to ${CODE_SIGN_KEY_VAULT} but neither LOCAL_KEY_VAULT_CERTIFICATE_THUMBPRINT nor LOCAL_KEY_VAULT_SIGNING_IDENTITY is set.")
|
||||
endif()
|
||||
configure_common_params()
|
||||
set(SIGN_PARAMS ${SIGN_PARAMS} ${store} ${certopt} ${certid}
|
||||
#/debug
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(configure_common_params)
|
||||
if (CODE_SIGN_TIMESTAMP_URL)
|
||||
set(SIGN_PARAMS ${SIGN_PARAMS}
|
||||
-fd sha256
|
||||
-td sha256 -tr ${CODE_SIGN_TIMESTAMP_URL}
|
||||
-d KTX-Software -du https://github.com/KhronosGroup/KTX-Software
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
message(FATAL_ERROR "CODE_SIGN_KEY_VAULT is set but CODE_SIGN_TIMESTAMP_URL is not set.")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(set_nsis_installer_codesign_cmd)
|
||||
# To make calls to the above macro and this order independent ...
|
||||
if(WIN32 AND CODE_SIGN_KEY_VAULT)
|
||||
if(NOT SIGN_PARAMS)
|
||||
configure_windows_sign_params()
|
||||
endif()
|
||||
if(SIGN_PARAMS)
|
||||
# CPACK_NSIS_FINALIZE_CMD is a variable whose value is to be substituted
|
||||
# into the !finalize and !uninstfinalize commands in
|
||||
# cmake/modules/NSIS.template.in. This variable is ours. It is not a
|
||||
# standard CPACK variable. The name MUST start with CPACK otherwise
|
||||
# it will not be defined when cpack runs its configure_file step.
|
||||
foreach(param IN LISTS SIGN_PARAMS)
|
||||
# Quote the parameters because at least one of them,
|
||||
# WIN_CODE_SIGN_IDENTITY, has spaces. It is easier to quote
|
||||
# all of them than determine which have spaces.
|
||||
#
|
||||
# Insane escaping is needed due to the 2-step process used to
|
||||
# configure the final output. First cpack creates CPackConfig.cmake
|
||||
# in which the value set here appears, inside quotes, as the
|
||||
# argument to a cmake `set` command. That variable's value
|
||||
# is then substituted into the output.
|
||||
string(APPEND NSIS_SIGN_PARAMS "\\\"${param}\\\" ")
|
||||
endforeach()
|
||||
|
||||
# Note 1: cpack/NSIS does not show any output when running signtool,
|
||||
# whether it succeeds or fails.
|
||||
#
|
||||
# Note 2: Do not move the %1 to NSIS.template.in. We need an empty
|
||||
# command there when we aren't signing. %1 is replaced by the name
|
||||
# of the installer or uninstaller during NSIS compilation.
|
||||
set(CPACK_NSIS_FINALIZE_CMD "\\\"${signtool_EXECUTABLE}\\\" sign ${NSIS_SIGN_PARAMS} %1"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
unset(NSIS_SIGN_PARAMS)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -0,0 +1,170 @@
|
||||
# Copyright 2016, Simon Werta (@webmaster128).
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set(cputypetest_code "
|
||||
//
|
||||
// https://gist.github.com/webmaster128/e08067641df1dd784eb195282fd0912f
|
||||
//
|
||||
// The resulting values must not be defined as macros, which
|
||||
// happens e.g. for 'i386', which is a macro in clang.
|
||||
// For safety reasons, we undefine everything we output later
|
||||
//
|
||||
// For CMake literal compatibility, this file must have no double quotes
|
||||
//
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
x86_64
|
||||
#elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
|
||||
x86_32
|
||||
#elif defined(__ARM_ARCH_2__)
|
||||
armv2
|
||||
#elif defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__)
|
||||
armv3
|
||||
#elif defined(__ARM_ARCH_4T__) || defined(__TARGET_ARM_4T)
|
||||
armv4T
|
||||
#elif defined(__ARM_ARCH_5_) || defined(__ARM_ARCH_5E_)
|
||||
ARM5
|
||||
#elif defined(__ARM_ARCH_6T2_) || defined(__ARM_ARCH_6T2_)
|
||||
armv6T2
|
||||
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
|
||||
armv6
|
||||
#elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
|
||||
armv7
|
||||
#elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
|
||||
armv7A
|
||||
#elif defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
|
||||
armv7R
|
||||
#elif defined(__ARM_ARCH_7M__)
|
||||
armv7M
|
||||
#elif defined(__ARM_ARCH_7S__)
|
||||
armv7S
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
arm64
|
||||
#elif defined(mips) || defined(__mips__) || defined(__mips)
|
||||
mips
|
||||
#elif defined(__sh__)
|
||||
superh
|
||||
#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC)
|
||||
powerpc
|
||||
#elif defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
|
||||
powerpc64
|
||||
#elif defined(__sparc__) || defined(__sparc)
|
||||
sparc
|
||||
#elif defined(__m68k__)
|
||||
m68k
|
||||
#elif defined __EMSCRIPTEN__
|
||||
wasm
|
||||
#else
|
||||
#error Unsupported cpu
|
||||
#endif
|
||||
|
||||
")
|
||||
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/cputypetest.c" "${cputypetest_code}")
|
||||
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
function(set_target_processor_type out)
|
||||
if(ANDROID_ABI AND "${ANDROID_ABI}" STREQUAL "armeabi-v7a")
|
||||
set(${out} armv7 PARENT_SCOPE)
|
||||
elseif(ANDROID_ABI AND "${ANDROID_ABI}" STREQUAL "arm64-v8a")
|
||||
set(${out} arm64 PARENT_SCOPE)
|
||||
elseif(ANDROID_ABI AND "${ANDROID_ABI}" STREQUAL "x86")
|
||||
set(${out} x86 PARENT_SCOPE)
|
||||
elseif(ANDROID_ABI AND "${ANDROID_ABI}" STREQUAL "x86_64")
|
||||
set(${out} x86_64 PARENT_SCOPE)
|
||||
|
||||
else()
|
||||
if(MSVC) # MSVC is true for all msvc-style compilers, including clang-cl
|
||||
if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM" OR "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm")
|
||||
set(processor "arm")
|
||||
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64" OR "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm64")
|
||||
set(processor "arm64")
|
||||
else()
|
||||
set(C_PREPROCESS ${CMAKE_C_COMPILER} /EP /nologo)
|
||||
# Versions of MSVC prior to VS2019 have a supporting dll which
|
||||
# must be found along the search path. MSVC in VS 2019 just
|
||||
# works. Whether due to not having this supporting dll or using
|
||||
# a different way to locate it, is unknown. To make earlier
|
||||
# versions work set the WORKING_DIR to the location of the
|
||||
# support dll to ensure it is found.
|
||||
string(REGEX REPLACE "/VC/.*$" "/Common7/IDE"
|
||||
compiler_support_dir
|
||||
${CMAKE_C_COMPILER})
|
||||
execute_process(
|
||||
COMMAND ${C_PREPROCESS} "${CMAKE_BINARY_DIR}/cputypetest.c"
|
||||
WORKING_DIRECTORY ${compiler_support_dir}
|
||||
OUTPUT_VARIABLE processor
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
# Specify this to block MSVC's output of the source file name
|
||||
# so as not to trigger PowerShell's stop-on-error in CI.
|
||||
# Unfortunately it suppresses all compile errors too hence
|
||||
# the special case for MSVC. Which was convenient to have
|
||||
# when we found the issue with earlier versions of VS.
|
||||
ERROR_QUIET
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
# Apple's clang is a single compiler whose target is determined by
|
||||
# its -arch <architecture> or --target=<architecture> options
|
||||
# defaulting to the processor of the Mac it is running on. CMake does
|
||||
# not set this directly when generating for Xcode. (I don't know what
|
||||
# it does when generating makefiles. Therefore, in the Xcode case,
|
||||
# compiling cputypetest.c with CMAKE_{C,CXX}_COMPILER results in
|
||||
# processor being set to x86_86 or arm64 depending on the Mac it is
|
||||
# running on.
|
||||
#
|
||||
# When building for iOS, only CMAKE_SYSTEN_NAME is specified during
|
||||
# configuration. CMake leaves it up to Xcode or to the user passing
|
||||
# a -sdk argument to xcbuild to make sure the correct <architecture>
|
||||
# is set when calling the compiler.
|
||||
#
|
||||
# When building for macOS (and possibly for iOS, not tested) the
|
||||
# user can specify CMAKE_OSX_ARCHITECTURES if they want to compile
|
||||
# for something different than the current processor. This could be
|
||||
# set to $(ARCHS_STANDARD) an Xcode build setting whose value in
|
||||
# recent Xcode versions is "x86_64 arm64" to create universal binaries.
|
||||
# This is passed to Xcode which calls the compiler twice passing the
|
||||
# same set of target_definitions each time so in this case we have
|
||||
# to choose BASISU_SUPPORT_SSE=OFF or the arm64 compile will fail.
|
||||
#
|
||||
# The following code reflects all this.
|
||||
if(APPLE AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
# Building for iOS, iPadOS, etc. Since we don't care what
|
||||
# type of ARM processor, arbitrarily set armv8.
|
||||
# It should be arm64 but there is a check in tests/CMakeLists.txt
|
||||
# that is dropping loadtests for Apple Silicon arm64.
|
||||
set(processor armv8)
|
||||
elseif(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
string(STRIP "${CMAKE_OSX_ARCHITECTURES}" architectures)
|
||||
if("${architectures}" STREQUAL "$(ARCHS_STANDARD)")
|
||||
# Choose arm64 so SSE support is disabled.
|
||||
set(processor arm64)
|
||||
elseif("${architectures}" MATCHES "[^ ]+[ ]+[^ ]+")
|
||||
# Multiple words, choose arm64 so SSE support is disabled.
|
||||
set(processor arm64)
|
||||
elseif(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
|
||||
set(processor x86_64)
|
||||
elseif(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
|
||||
set(processor arm64)
|
||||
else()
|
||||
# Choose arm64 so SSE support is disabled.
|
||||
set(processor arm64)
|
||||
endif()
|
||||
unset(architectures)
|
||||
else()
|
||||
# This will distinguish between M1 and Intel Macs
|
||||
set(C_PREPROCESS ${CMAKE_C_COMPILER} -E -P)
|
||||
execute_process(
|
||||
COMMAND ${C_PREPROCESS} "${CMAKE_BINARY_DIR}/cputypetest.c"
|
||||
OUTPUT_VARIABLE processor
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(STRIP "${processor}" processor)
|
||||
#message(STATUS "*** set_target_processor_type ***: processor is ${processor}")
|
||||
set(${out} ${processor} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction(set_target_processor_type)
|
||||
@@ -0,0 +1,275 @@
|
||||
# Copyright 2015-2020 The Khronos Group Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# dot is optional as missing include dependency graphs and
|
||||
# inheritance graphs is not a big enough deal to justify
|
||||
# forcing people to install Graphviz.
|
||||
find_package(Doxygen REQUIRED OPTIONAL_COMPONENTS dot)
|
||||
if(NOT DOXYGEN_DOT_EXECUTABLE)
|
||||
message(NOTICE "dot executable not found so Doxygen will not generate\n"
|
||||
"include dependency or inheritance graphs in the documentation.\n"
|
||||
"If you want these graphs, install Graphviz.")
|
||||
endif()
|
||||
|
||||
set(docdest "${CMAKE_CURRENT_BINARY_DIR}/docs")
|
||||
|
||||
# The torturous Doxygen output settings are a hack
|
||||
# to workaround a doxygen limitation where it will
|
||||
# only create the trailing directory of the path
|
||||
# given in, e.g DOXYGEN_HTML_OUTPUT while enabling
|
||||
# us to put each sub-document in its own directory of
|
||||
# the html output.
|
||||
|
||||
# Global
|
||||
set( DOXYGEN_PROJECT_LOGO icons/ktx_logo_200.png )
|
||||
set( DOXYGEN_OUTPUT_DIRECTORY ${docdest}/html)
|
||||
set( DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES )
|
||||
set( DOXYGEN_EXTRACT_LOCAL_CLASSES NO )
|
||||
set( DOXYGEN_HIDE_UNDOC_MEMBERS YES )
|
||||
set( DOXYGEN_CASE_SENSE_NAMES YES )
|
||||
set( DOXYGEN_SHOW_USED_FILES NO )
|
||||
set( DOXYGEN_VERBATIM_HEADERS NO )
|
||||
set( DOXYGEN_CLANG_ASSISTED_PARSING NO )
|
||||
set( DOXYGEN_ALPHABETICAL_INDEX NO )
|
||||
set( DOXYGEN_DISABLE_INDEX YES )
|
||||
set( DOXYGEN_DISABLE_INDEX NO )
|
||||
set( DOXYGEN_GENERATE_TREEVIEW YES )
|
||||
set( DOXYGEN_GENERATE_LATEX NO )
|
||||
set( DOXYGEN_GENERATE_HTML YES )
|
||||
set( DOXYGEN_GENERATE_MAN YES )
|
||||
set( DOXYGEN_MAN_OUTPUT ../man )
|
||||
# This is to get timestamps with older versions of doxygen.
|
||||
# older
|
||||
set( DOXYGEN_HTML_TIMESTAMP YES )
|
||||
set( DOXYGEN_TIMESTAMP YES )
|
||||
|
||||
function( add_sources target sources )
|
||||
# Make ${sources} show up in IDE/project
|
||||
get_target_property( doc_sources ${target} SOURCES )
|
||||
if( NOT doc_sources )
|
||||
set( doc_sources "" ) # Clear doc_sources-NOTFOUND value.
|
||||
endif()
|
||||
set_target_properties(
|
||||
${target}
|
||||
PROPERTIES
|
||||
SOURCES "${doc_sources};${sources}"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function( add_docs_cmake target )
|
||||
# Make `docs.cmake` show up in IDE/project
|
||||
add_sources( ${target} "cmake/docs.cmake" )
|
||||
endfunction()
|
||||
|
||||
function( add_docs_cmake_plus target sources )
|
||||
# Make `docs.cmake` plus ${sources} show up in IDE/project
|
||||
add_sources( ${target} "cmake/docs.cmake;${sources}" )
|
||||
endfunction()
|
||||
|
||||
# Note very well
|
||||
#
|
||||
# These projects and accompanying DOXYGEN_LAYOUT_FILES are carefully crafted
|
||||
# to provide the illusion of a consistent GUI across all the projects.
|
||||
# Likely this will be fragile in the face of Doxygen changes.
|
||||
|
||||
# ktx.doc
|
||||
function( CreateDocLibKTX )
|
||||
set( DOXYGEN_PROJECT_NAME "libktx Reference" )
|
||||
set( DOXYGEN_ALIASES error=\"\\par Errors\\n\" )
|
||||
set( DOXYGEN_LAYOUT_FILE pkgdoc/libktxDoxyLayout.xml )
|
||||
set( DOXYGEN_TYPEDEF_HIDES_STRUCT NO )
|
||||
set( DOXYGEN_EXCLUDE lib/uthash.h )
|
||||
set( DOXYGEN_EXCLUDE_PATTERNS ktxint.h )
|
||||
set( DOXYGEN_EXAMPLE_PATH examples lib )
|
||||
# This does not hide the scope (class) names in the Modules list
|
||||
# in the ToC. See https://github.com/doxygen/doxygen/issues/9921.
|
||||
set( DOXYGEN_HIDE_SCOPE_NAMES YES )
|
||||
set( DOXYGEN_HTML_OUTPUT libktx )
|
||||
# Order is important here. '_' suffixed prefices must come first
|
||||
# otherwise the non-suffixed is stripped first leaving just '_'.
|
||||
set( DOXYGEN_IGNORE_PREFIX KTX_;ktx_;KTX;ktx )
|
||||
set( DOXYGEN_MAN_LINKS YES )
|
||||
set( DOXYGEN_MACRO_EXPANSION YES )
|
||||
set( DOXYGEN_EXPAND_ONLY_PREDEF YES )
|
||||
|
||||
set( DOXYGEN_PREDEFINED
|
||||
KTX_DOXYGEN_SKIP
|
||||
KTX_FEATURE_WRITE
|
||||
"KTXTEXTURECLASSDEFN=class_id classId\; \\
|
||||
struct ktxTexture_vtbl* vtbl\; \\
|
||||
struct ktxTexture_vvtbl* vvtbl\; \\
|
||||
struct ktxTexture_protected* _protected\; \\
|
||||
ktx_bool_t isArray\; \\
|
||||
ktx_bool_t isCubemap\; \\
|
||||
ktx_bool_t isCompressed\; \\
|
||||
ktx_bool_t generateMipmaps\; \\
|
||||
ktx_uint32_t baseWidth\; \\
|
||||
ktx_uint32_t baseHeight\; \\
|
||||
ktx_uint32_t baseDepth\; \\
|
||||
ktx_uint32_t numDimensions\; \\
|
||||
ktx_uint32_t numLevels\; \\
|
||||
ktx_uint32_t numLayers\; \\
|
||||
ktx_uint32_t numFaces\; \\
|
||||
struct { \\
|
||||
ktxOrientationX x\; \\
|
||||
ktxOrientationY y\; \\
|
||||
ktxOrientationZ z\; \\
|
||||
} orientation\; \\
|
||||
ktxHashList kvDataHead\; \\
|
||||
ktx_uint32_t kvDataLen\; \\
|
||||
ktx_uint8_t* kvData\; \\
|
||||
ktx_size_t dataSize\; \\
|
||||
ktx_uint8_t* pData\;"
|
||||
)
|
||||
#set( DOXYGEN_GENERATE_TAGFILE ${docdest}/libktx.tag )
|
||||
|
||||
doxygen_add_docs(
|
||||
libktx.doc
|
||||
lib/libktx_mainpage.md
|
||||
include
|
||||
lib/astc_codec.cpp
|
||||
lib/basis_encode.cpp
|
||||
lib/basis_transcode.cpp
|
||||
lib/miniz_wrapper.cpp
|
||||
lib/strings.c
|
||||
lib/gl_funcs.c
|
||||
lib/glloader.c
|
||||
lib/hashlist.c
|
||||
lib/filestream.c
|
||||
lib/memstream.c
|
||||
lib/texture.c
|
||||
lib/texture1.c
|
||||
lib/texture2.c
|
||||
lib/vkloader.c
|
||||
lib/writer1.c
|
||||
lib/writer2.c
|
||||
)
|
||||
add_docs_cmake_plus( libktx.doc pkgdoc/libktxDoxyLayout.xml )
|
||||
endfunction()
|
||||
|
||||
# ktxtools.doc
|
||||
function( CreateDocTools )
|
||||
set( DOXYGEN_PROJECT_NAME "KTX Tools Reference" )
|
||||
set( DOXYGEN_FULL_PATH_NAMES NO )
|
||||
set( DOXYGEN_ALIASES author=\"\\section AUTHOR\\n\" )
|
||||
set( DOXYGEN_LAYOUT_FILE pkgdoc/toolsDoxyLayout.xml )
|
||||
set( DOXYGEN_SHOW_FILES NO )
|
||||
set( DOXYGEN_FILE_PATTERNS *.cpp )
|
||||
set( DOXYGEN_RECURSIVE YES )
|
||||
set( DOXYGEN_EXAMPLE_PATH utils tools )
|
||||
set( DOXYGEN_HTML_OUTPUT ktxtools )
|
||||
set( DOXYGEN_MAN_EXTENSION .1 )
|
||||
#set( DOXYGEN_GENERATE_TAGFILE ${docdest}/ktxtools.tag )
|
||||
set( DOXYGEN_TAGFILES ${docdest}/ktxpkg.tag=.. )
|
||||
|
||||
doxygen_add_docs(
|
||||
tools.doc
|
||||
tools/ktx/ktx_main.cpp
|
||||
tools/ktx/command_compare.cpp
|
||||
tools/ktx/command_create.cpp
|
||||
tools/ktx/command_deflate.cpp
|
||||
tools/ktx/command_encode.cpp
|
||||
tools/ktx/command_extract.cpp
|
||||
tools/ktx/command_help.cpp
|
||||
tools/ktx/command_info.cpp
|
||||
tools/ktx/command_transcode.cpp
|
||||
tools/ktx/command_validate.cpp
|
||||
tools/ktx2check/ktx2check.cpp
|
||||
tools/ktx2ktx2/ktx2ktx2.cpp
|
||||
tools/ktxinfo/ktxinfo.cpp
|
||||
tools/ktxsc/ktxsc.cpp
|
||||
tools/ktxtools_mainpage.md
|
||||
tools/toktx/toktx.cc
|
||||
)
|
||||
add_docs_cmake_plus( tools.doc pkgdoc/toolsDoxyLayout.xml )
|
||||
endfunction()
|
||||
|
||||
# ktxjswrappers.doc
|
||||
function( CreateDocJSWrappers )
|
||||
set( DOXYGEN_PROJECT_NAME "KTX Javascript Wrappers Reference" )
|
||||
set( DOXYGEN_FULL_PATH_NAMES NO )
|
||||
set( DOXYGEN_ALIASES author=\"\\section AUTHOR\\n\" )
|
||||
set( DOXYGEN_LAYOUT_FILE pkgdoc/jswrappersDoxyLayout.xml )
|
||||
set( DOXYGEN_SHOW_FILES NO )
|
||||
set( DOXYGEN_HTML_OUTPUT ktxjswrappers )
|
||||
#set( DOXYGEN_GENERATE_TAGFILE ${docdest}/ktxjswrappers.tag )
|
||||
set( DOXYGEN_TAGFILES ${docdest}/ktxpkg.tag=.. )
|
||||
|
||||
doxygen_add_docs(
|
||||
jswrappers.doc
|
||||
interface/js_binding
|
||||
)
|
||||
add_docs_cmake_plus( jswrappers.doc pkgdoc/jswrappersDoxyLayout.xml )
|
||||
endfunction()
|
||||
|
||||
# pyktxwrappers.doc
|
||||
function( CreateDocPyktxWrappers )
|
||||
add_custom_command(
|
||||
TARGET libktx.doc
|
||||
POST_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy_directory ${KTX_BUILD_DIR}/interface/python_binding/docs/html/pyktx/html ${KTX_BUILD_DIR}/docs/html/pyktx
|
||||
)
|
||||
add_dependencies( libktx.doc pyktx.doc )
|
||||
endfunction()
|
||||
|
||||
# ktxpkg.doc
|
||||
function( CreateDocKTX )
|
||||
set( DOXYGEN_PROJECT_NAME "Khronos Texture Software" )
|
||||
set( DOXYGEN_ALIASES pversion=\"\\par Package Version\\n\" )
|
||||
set( DOXYGEN_LAYOUT_FILE pkgdoc/packageDoxyLayout.xml )
|
||||
set( DOXYGEN_EXCLUDE lib/uthash.h )
|
||||
set( DOXYGEN_EXCLUDE_PATTERNS ktxint.h )
|
||||
set( DOXYGEN_EXAMPLE_PATH lib )
|
||||
set( DOXYGEN_GENERATE_TAGFILE ${docdest}/ktxpkg.tag )
|
||||
set( DOXYGEN_HTML_HEADER pkgdoc/header.html )
|
||||
set( DOXYGEN_HTML_OUTPUT . )
|
||||
set( DOXYGEN_MAN_LINKS YES )
|
||||
#set( DOXYGEN_TAGFILES ${docdest}/libktx.tag=libktx ${docdest}/ktxtools.tag=ktxtools )
|
||||
|
||||
doxygen_add_docs(
|
||||
ktxpkg.doc
|
||||
pkgdoc/pages.md
|
||||
LICENSE.md
|
||||
#RELEASE_NOTES.md
|
||||
)
|
||||
add_docs_cmake_plus( ktxpkg.doc pkgdoc/packageDoxyLayout.xml )
|
||||
endfunction()
|
||||
|
||||
CreateDocLibKTX()
|
||||
CreateDocTools()
|
||||
CreateDocJSWrappers()
|
||||
if (KTX_FEATURE_PY)
|
||||
CreateDocPyktxWrappers()
|
||||
endif()
|
||||
CreateDocKTX()
|
||||
|
||||
add_dependencies( libktx.doc ktxpkg.doc ktx_version )
|
||||
add_dependencies( jswrappers.doc ktxpkg.doc )
|
||||
add_dependencies( tools.doc ktxpkg.doc )
|
||||
|
||||
# I want to add a dependency on the "package" built-in target.
|
||||
# Unfortunately CMake does not support adding dependencies to
|
||||
# built-in targets. See https://gitlab.kitware.com/cmake/cmake/-/issues/8438.
|
||||
#
|
||||
# There also seems to be no way to add a dependency for the install commands
|
||||
# below. Presumably "install(TARGETS ...)" adds a dependency on each target
|
||||
# but the rest of that command is simply not appropriate for this case.
|
||||
add_custom_target( all.doc ALL
|
||||
DEPENDS tools.doc libktx.doc jswrappers.doc
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY ${docdest}/html
|
||||
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
|
||||
COMPONENT tools
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY ${docdest}/man/man1
|
||||
## Omit those, since at the moment they contain a lot of undesired files generated by Doxygen
|
||||
# ${docdest}/man/man3
|
||||
# ${docdest}/man/ktx/man3
|
||||
DESTINATION "${CMAKE_INSTALL_MANDIR}"
|
||||
COMPONENT tools
|
||||
)
|
||||
@@ -0,0 +1,39 @@
|
||||
# Copyright 2023 The Khronos Group Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# CMake Toolchain file for cross-compiling to aarch64 (arm64) on
|
||||
# a non-arm64 device running Linux (Ubuntu).
|
||||
#
|
||||
# This following packages must be installed for compiling to ARM64:
|
||||
# sudo apt-get -qq install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
|
||||
|
||||
######################################################################
|
||||
# Nota Bene
|
||||
#
|
||||
# Untested. Was under development when Travis-CI made arm64 Ubuntu
|
||||
# runners available rendering it unneeded. Kept here to preserve the
|
||||
# learning and in case it becomes useful.
|
||||
######################################################################
|
||||
|
||||
# Target operating system name.
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
# Name of C compiler.
|
||||
set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
|
||||
set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++")
|
||||
|
||||
# Where to look for the target environment. (More paths can be added here)
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
|
||||
#set(CMAKE_SYSROOT /usr/aarch64-linux-gnu)
|
||||
|
||||
# Adjust the default behavior of the FIND_XXX() commands:
|
||||
# search programs in the host environment only.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# Search headers and libraries in the target environment only.
|
||||
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
#set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE arm64)
|
||||
@@ -0,0 +1,48 @@
|
||||
# Copyright 2023 The Khronos Group Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# CMake Toolchain file for cross-compiling to x86_64 (amd64) on
|
||||
# a non-x86_64 device running Linux (Ubuntu).
|
||||
#
|
||||
# The following packages must be installed for compiling to x86_64.
|
||||
# sudo apt-get -qq install gcc-x86-64-linux-gnu g++-x86-64-linux-gnu binutils-x86-64-linux-gnu
|
||||
|
||||
######################################################################
|
||||
# Nota Bene
|
||||
#
|
||||
# Untested. Was under development when Travis-CI made arm64 Ubuntu
|
||||
# runners available rendering it unneeded. Kept here to preserve the
|
||||
# learning and in case it becomes useful.
|
||||
######################################################################
|
||||
|
||||
# A note about the platform/architecture naming.
|
||||
#
|
||||
# The Ubuntu/Deb packages with the compiler and tools use "x64-64" as
|
||||
# you can see above. The compiler and tools are named with "x86_64"
|
||||
# as you will see in the macro settings below. Probably this is done
|
||||
# to maintain consistency with existing naming conventions for
|
||||
# packages (no underscores) and tools (use the offical architecture
|
||||
# name).
|
||||
|
||||
# Target operating system name.
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
# Name of C compiler.
|
||||
set(CMAKE_C_COMPILER "/usr/bin/x86_64-linux-gnu-gcc")
|
||||
set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-linux-gnu-g++")
|
||||
|
||||
# Where to look for the target environment. (More paths can be added here)
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-linux-gnu)
|
||||
#set(CMAKE_SYSROOT /usr/x86_64-linux-gnu)
|
||||
|
||||
# Adjust the default behavior of the FIND_XXX() commands:
|
||||
# search programs in the host environment only.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# Search headers and libraries in the target environment only.
|
||||
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
#set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
|
||||
@@ -0,0 +1,202 @@
|
||||
# Copyright 2015-2020 The Khronos Group Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Code generation scripts that require a Vulkan SDK installation
|
||||
|
||||
# TODO: Rewrite scripts to generate the files from the Vulkan
|
||||
# registry, vk.xml, in the Vulkan-Docs repo.
|
||||
|
||||
# NOTE: Since this must be explicitly included by setting an option,
|
||||
# require sought packages. However, in order to give an informative
|
||||
# error, REQUIRED is not used in the find_* commands.
|
||||
#
|
||||
# CAUTION: Outputs of custom commands are deleted during a clean
|
||||
# operation so these targets result in clean deleting what are normally
|
||||
# considered source files. There appears to be no easy way to avoid
|
||||
# this. Since only project developers need to use these targets, and
|
||||
# only occasionally, this misfeature can be tolerated.
|
||||
|
||||
if (NOT IOS AND NOT ANDROID)
|
||||
# Not needed as local custom vulkan_core.h is used. Keeping
|
||||
# in case we go back to the standard one.
|
||||
# # find_package doesn't find the Vulkan SDK when building for IOS.
|
||||
# # I haven't investigated why.
|
||||
# find_package(Vulkan REQUIRED)
|
||||
|
||||
# This cmake file is included from its parent so has the same scope as
|
||||
# the including file. If we change Vulkan_INCLUDE_DIR, other parts will
|
||||
# be affected.
|
||||
set(mkvk_vulkan_include_dir external/dfdutils)
|
||||
else()
|
||||
# Skip mkvk. There is no need to use iOS or Android to regenerate
|
||||
# the files.
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(vulkan_header "${mkvk_vulkan_include_dir}/vulkan/vulkan_core.h")
|
||||
|
||||
# CAUTION: On Windows use a version of Perl built for Windows, i.e. not
|
||||
# one found in Cygwin or MSYS (Git for Windows). This is needed so the
|
||||
# generated files have the correct the correct CRLF line endings. The ones
|
||||
# mentioned write LF line endings (possibly related to some Cygwin or MSYS
|
||||
# installation setting for handling of text files). The Perl scripts,
|
||||
# unlike the Awk scripts, have not been modified to always write CRLF
|
||||
# on Windows.
|
||||
#
|
||||
# Strawberry Perl via Chocolatey is recommended.
|
||||
# choco install strawberryperl
|
||||
|
||||
#if(CMAKE_HOST_WIN32 AND NOT CYGWIN_INSTALL_PATH)
|
||||
# # Git for Windows comes with Perl
|
||||
# # Trick FindPerl into considering default Git location
|
||||
# set(CYGWIN_INSTALL_PATH "C:\\Program Files\\Git\\usr")
|
||||
#endif()
|
||||
|
||||
string(APPEND not_found_error
|
||||
"not found. "
|
||||
"This is only needed by project maintainers when regenerating source files. "
|
||||
"To silence, set KTX_GENERATE_VK_FILES OFF.")
|
||||
find_package(Perl QUIET)
|
||||
# Painful. Oh for a way to provide custom error messages for failures.
|
||||
if(NOT PERL_EXECUTABLE)
|
||||
message(FATAL_ERROR "Perl executable ${not_found_error}")
|
||||
endif()
|
||||
|
||||
set(Ruby_FIND_VIRTUALENV FIRST)
|
||||
find_package(Ruby 3 QUIET)
|
||||
if(NOT Ruby_EXECUTABLE)
|
||||
message(FATAL_ERROR "Ruby v3 executable ${not_found_error}")
|
||||
endif()
|
||||
|
||||
find_path(KTX_SPECIFICATION
|
||||
NAMES formats.json
|
||||
PATHS ${PROJECT_SOURCE_DIR}/../KTX-Specification
|
||||
NO_DEFAULT_PATH)
|
||||
if(NOT KTX_SPECIFICATION)
|
||||
message(FATAL_ERROR "KTX-Specification repo clone ${not_found_error}")
|
||||
endif()
|
||||
|
||||
list(APPEND mkvkformatfiles_input
|
||||
${vulkan_header}
|
||||
scripts/mkvkformatfiles)
|
||||
list(APPEND mkvkformatfiles_output
|
||||
"${PROJECT_SOURCE_DIR}/interface/java_binding/src/main/java/org/khronos/ktx/VkFormat.java"
|
||||
"${PROJECT_SOURCE_DIR}/interface/js_binding/vk_format.inl"
|
||||
"${PROJECT_SOURCE_DIR}/interface/python_binding/pyktx/vk_format.py"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_enum.h"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_typesize.c"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_check.c"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_str.c"
|
||||
"${PROJECT_SOURCE_DIR}tests/unittests/vkformat_list.inl")
|
||||
|
||||
# CAUTION: When a COMMAND contains VAR="Value" CMake messes up the escaping
|
||||
# for Bash. With or without VERBATIM, if Value has no spaces CMake changes it
|
||||
# to VAR=\"Value\". If it has spaces CMake changes it to "VAR=\"Value\"".
|
||||
# The first causes the quotes to leak into the command that is reading VAR
|
||||
# breaking, e.g. opening a file that has VAR's value as part of its name.
|
||||
# The second causes Bash to look for the command 'VAR="Value"' causing it
|
||||
# to exit with error.
|
||||
#
|
||||
# The only workaround I've found is to put the command in a string and invoke
|
||||
# it with bash -c. This is what we'd have to do on Windows anyway as COMMAND
|
||||
# defaults to cmd or powershell (not sure which). In this case CMake passes
|
||||
# to bash a string of the form '"VAR=\"Value\" command arg ..."' which bash
|
||||
# parses successfully.
|
||||
|
||||
list(APPEND mvffc_as_list
|
||||
scripts/mkvkformatfiles ./ ${vulkan_header})
|
||||
list(JOIN mvffc_as_list " " mvffc_as_string)
|
||||
set(mkvkformatfiles_command "${BASH_EXECUTABLE}" -c "${mvffc_as_string}")
|
||||
|
||||
add_custom_command(OUTPUT ${mkvkformatfiles_output}
|
||||
COMMAND ${mkvkformatfiles_command}
|
||||
DEPENDS ${mkvkformatfiles_input}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generating VkFormat-related source files"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(mkvkformatfiles
|
||||
DEPENDS ${mkvkformatfiles_output}
|
||||
SOURCES ${mkvkformatfiles_input}
|
||||
)
|
||||
|
||||
list(APPEND makevk2dfd_input
|
||||
${vulkan_header}
|
||||
external/dfdutils/makevk2dfd.pl)
|
||||
set(makevk2dfd_output
|
||||
"${PROJECT_SOURCE_DIR}/external/dfdutils/vk2dfd.inl")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${makevk2dfd_output}
|
||||
COMMAND "${PERL_EXECUTABLE}" external/dfdutils/makevk2dfd.pl ${vulkan_header} external/dfdutils/vk2dfd.inl
|
||||
DEPENDS ${makevk2dfd_input}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generating VkFormat/DFD switch body"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(makevk2dfd
|
||||
DEPENDS ${makevk2dfd_output}
|
||||
SOURCES ${makevk2dfd_input}
|
||||
)
|
||||
|
||||
|
||||
list(APPEND makedfd2vk_input
|
||||
${vulkan_header}
|
||||
external/dfdutils/makedfd2vk.pl)
|
||||
list(APPEND makedfd2vk_output
|
||||
"${PROJECT_SOURCE_DIR}/external/dfdutils/dfd2vk.inl")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${makedfd2vk_output}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory external/dfdutils
|
||||
COMMAND "${PERL_EXECUTABLE}" external/dfdutils/makedfd2vk.pl ${vulkan_header} external/dfdutils/dfd2vk.inl
|
||||
DEPENDS ${makedfd2vk_input}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generating DFD/VkFormat switch body"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(makedfd2vk
|
||||
DEPENDS ${makedfd2vk_output}
|
||||
SOURCES ${makedfd2vk_input}
|
||||
)
|
||||
|
||||
list(APPEND makevk2gl_input
|
||||
${KTX_SPECIFICATION}/generate_format_switches.rb
|
||||
${KTX_SPECIFICATION}/formats.json)
|
||||
list(APPEND makevk2gl_output
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2glFormat.inl"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2glInternalFormat.inl"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2glType.inl")
|
||||
# Until we have D3D or Metal loaders these outputs of
|
||||
# generate_format_switches.rb are unneeded.
|
||||
list(APPEND makevk2gl_extraneous_files
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2dxgiFormat.inl"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2mtlFormat.inl"
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${makevk2gl_output}
|
||||
COMMAND "${RUBY_EXECUTABLE}" ${KTX_SPECIFICATION}/generate_format_switches.rb ${PROJECT_SOURCE_DIR}/lib
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -f ${makevk2gl_extraneous_files}
|
||||
DEPENDS ${makevk2gl_input}
|
||||
WORKING_DIRECTORY ${KTX_SPECIFICATION}
|
||||
COMMENT "Generating VkFormat to OpenGL internal format, format and type switches"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(makevk2gl
|
||||
DEPENDS ${makevk2gl_output}
|
||||
SOURCES ${makedvk2gl_input}
|
||||
)
|
||||
|
||||
add_custom_target(mkvk SOURCES ${CMAKE_CURRENT_LIST_FILE})
|
||||
|
||||
add_dependencies(mkvk
|
||||
mkvkformatfiles
|
||||
makevk2dfd
|
||||
makedfd2vk
|
||||
makevk2gl
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2020 Andreas Atteneder
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
<installer-gui-script minSpecVersion="1.0">
|
||||
<title>KTX-Software</title>
|
||||
<welcome file="@CPACK_RESOURCE_FILE_WELCOME_NOPATH@"/>
|
||||
<readme file="@CPACK_RESOURCE_FILE_README_NOPATH@"/>
|
||||
<license file="@CPACK_RESOURCE_FILE_LICENSE_NOPATH@"/>
|
||||
<domains enable_localSystem="true"/>
|
||||
<options allow-external-scripts="no" customize="allow" rootVolumeOnly="true"/>
|
||||
@CPACK_PACKAGEMAKER_CHOICES@
|
||||
<conclusion file="summary.html" mime-type="text/html"/>
|
||||
</installer-gui-script>
|
||||
@@ -0,0 +1,100 @@
|
||||
##############################################################################
|
||||
# @file FindBASH.cmake
|
||||
# @brief Find BASH interpreter.
|
||||
#
|
||||
# Sets the CMake variables @c BASH_FOUND, @c BASH_EXECUTABLE,
|
||||
# @c BASH_VERSION_STRING, @c BASH_VERSION_MAJOR, @c BASH_VERSION_MINOR, and
|
||||
# @c BASH_VERSION_PATCH.
|
||||
#
|
||||
# @ingroup CMakeFindModules
|
||||
##############################################################################
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2011-2012 University of Pennsylvania
|
||||
# Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com>
|
||||
# Copyright 2013-2020 Andreas Atteneder <andreas.atteneder@gmail.com>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# find BASH executable
|
||||
|
||||
# First, look if GIT bash is installed
|
||||
find_program (
|
||||
BASH_EXECUTABLE
|
||||
bash
|
||||
PATHS
|
||||
# Additional paths for Windows
|
||||
"C:\\Program Files\\Git\\bin"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
|
||||
if(NOT BASH_EXECUTABLE)
|
||||
# Fallback search in default locations
|
||||
find_program (
|
||||
BASH_EXECUTABLE
|
||||
bash
|
||||
)
|
||||
endif()
|
||||
|
||||
mark_as_advanced (BASH_EXECUTABLE)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Get version of found BASH executable.
|
||||
if (BASH_EXECUTABLE)
|
||||
# Set LANG to en because match looks for English "version".
|
||||
set(ENV{LANG} "en_US.UTF-8")
|
||||
execute_process (COMMAND "${BASH_EXECUTABLE}" --version OUTPUT_VARIABLE _BASH_STDOUT ERROR_VARIABLE _BASH_STDERR)
|
||||
if (_BASH_STDOUT MATCHES "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
||||
set (BASH_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
set (BASH_VERSION_MINOR "${CMAKE_MATCH_2}")
|
||||
set (BASH_VERSION_PATCH "${CMAKE_MATCH_3}")
|
||||
set (BASH_VERSION_STRING "${BASH_VERSION_MAJOR}.${BASH_VERSION_MINOR}.${BASH_VERSION_PATCH}")
|
||||
else ()
|
||||
message (WARNING "Failed to determine version of Bash interpreter (${BASH_EXECUTABLE})! Error:\n${_BASH_STDERR}")
|
||||
endif ()
|
||||
unset (_BASH_STDOUT)
|
||||
unset (_BASH_STDERR)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Handle the QUIET and REQUIRED arguments and set *_FOUND to TRUE
|
||||
# if all listed variables are found or TRUE
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args (
|
||||
Bash
|
||||
REQUIRED_VARS
|
||||
BASH_EXECUTABLE
|
||||
)
|
||||
@@ -0,0 +1,210 @@
|
||||
# A version of cmake's FindSDL module modified to find SDL2.
|
||||
|
||||
# Copyright 2000-2020 Kitware, Inc. and Contributors
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Modifled for SDL2 by Mark Callow. (khronos at callow.im)
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2
|
||||
--------
|
||||
|
||||
Locate SDL2 library
|
||||
|
||||
This module defines
|
||||
|
||||
::
|
||||
|
||||
SDL2_LIBRARY, the name of the library to link against
|
||||
SDL2_FOUND, if false, do not try to link to SDL
|
||||
SDL2_INCLUDE_DIR, where to find SDL.h
|
||||
SDL2_VERSION_STRING, human-readable string containing the version of SDL
|
||||
|
||||
|
||||
|
||||
This module responds to the flag:
|
||||
|
||||
::
|
||||
|
||||
SDL2_BUILDING_LIBRARY
|
||||
If this is defined, then no SDL2_main will be linked in because
|
||||
only applications need main().
|
||||
Otherwise, it is assumed you are building an application and this
|
||||
module will attempt to locate and set the proper link flags
|
||||
as part of the returned SDL2_LIBRARY variable.
|
||||
|
||||
|
||||
|
||||
Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||
OS X framework based version. (Other versions link to -lSDLmain which
|
||||
this module will try to find on your behalf.) Also for OS X, this
|
||||
module will automatically add the -framework Cocoa on your behalf.
|
||||
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your
|
||||
configuration and no SDL2_LIBRARY, it means CMake did not find your SDL
|
||||
library (SDL.dll, libsdl.so, SDL.framework, etc). Set
|
||||
SDL2_LIBRARY_TEMP to point to your SDL library, and configure again.
|
||||
Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this
|
||||
value as appropriate. These values are used to generate the final
|
||||
SDL2_LIBRARY variable, but when these values are unset, SDL2_LIBRARY
|
||||
does not get created.
|
||||
|
||||
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL. l.e.galup 9-20-02
|
||||
|
||||
Modified by Eric Wing. Added code to assist with automated building
|
||||
by using environmental variables and providing a more
|
||||
controlled/consistent search behavior. Added new modifications to
|
||||
recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
||||
Also corrected the header search path to follow "proper" SDL
|
||||
guidelines. Added a search for SDLmain which is needed by some
|
||||
platforms. Added a search for threads which is needed by some
|
||||
platforms. Added needed compile switches for MinGW.
|
||||
|
||||
On OSX, this will prefer the Framework version (if found) over others.
|
||||
People will have to manually change the cache values of SDL2_LIBRARY to
|
||||
override this selection or set the CMake environment
|
||||
CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
|
||||
Note that the header path has changed from SDL/SDL.h to just SDL.h
|
||||
This needed to change because "proper" SDL convention is #include
|
||||
"SDL.h", not <SDL/SDL.h>. This is done for portability reasons
|
||||
because not all systems place things in SDL/ (see FreeBSD).
|
||||
#]=======================================================================]
|
||||
|
||||
if(NOT SDL2_DIR)
|
||||
set(SDL2_DIR "" CACHE PATH "SDL2 directory")
|
||||
endif()
|
||||
|
||||
find_path(SDL2_INCLUDE_DIR SDL.h
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${SDL2_DIR}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
find_library(SDL2_LIBRARY_TEMP
|
||||
NAMES SDL2
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${SDL2_DIR}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
# Hide this cache variable from the user, it's an internal implementation
|
||||
# detail. The documented library variable for the user is SDL2_LIBRARY
|
||||
# which is derived from SDL2_LIBRARY_TEMP further below.
|
||||
set_property(CACHE SDL2_LIBRARY_TEMP PROPERTY TYPE INTERNAL)
|
||||
|
||||
if(NOT SDL2_BUILDING_LIBRARY)
|
||||
if(NOT SDL2_INCLUDE_DIR MATCHES ".framework")
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDLmain for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
find_library(SDL2MAIN_LIBRARY
|
||||
NAMES SDL2main
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${SDL2_DIR}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SDL may require threads on your system.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
# But for non-OSX systems, I will use the CMake Threads package.
|
||||
if(NOT APPLE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
|
||||
# MinGW needs an additional link flag, -mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -mwindows
|
||||
if(MINGW)
|
||||
set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW")
|
||||
endif()
|
||||
|
||||
if(SDL2_LIBRARY_TEMP)
|
||||
# For SDLmain
|
||||
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
|
||||
list(FIND SDL2_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" _SDL2_MAIN_INDEX)
|
||||
if(_SDL2_MAIN_INDEX EQUAL -1)
|
||||
set(SDL2_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP})
|
||||
endif()
|
||||
unset(_SDL2_MAIN_INDEX)
|
||||
endif()
|
||||
|
||||
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
# though it actually is there if I modify a pre-used variable.
|
||||
# I think it has something to do with the CACHE STRING.
|
||||
# So I use a temporary variable until the end so I can set the
|
||||
# "real" variable in one-shot.
|
||||
if(APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# In fact, there seems to be a problem if I used the Threads package
|
||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||
if(NOT APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
# For MinGW library
|
||||
if(MINGW)
|
||||
set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||
endif()
|
||||
|
||||
# Set the final string here so the GUI reflects the final state.
|
||||
set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
|
||||
endif()
|
||||
|
||||
if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL2_version.h")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}")
|
||||
set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH})
|
||||
unset(SDL2_VERSION_MAJOR_LINE)
|
||||
unset(SDL2_VERSION_MINOR_LINE)
|
||||
unset(SDL2_VERSION_PATCH_LINE)
|
||||
unset(SDL2_VERSION_MAJOR)
|
||||
unset(SDL2_VERSION_MINOR)
|
||||
unset(SDL2_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL2_LIBRARIES ${SDL2_LIBRARY} ${SDL2MAIN_LIBRARY})
|
||||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
|
||||
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
|
||||
VERSION_VAR SDL2_VERSION_STRING)
|
||||
|
||||
# vim:ai:ts=4:sts=4:sw=2:expandtab:textwidth=70
|
||||
@@ -0,0 +1,983 @@
|
||||
# Updates for iOS Copyright (c) 2024, Holochip Inc.
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindVulkan
|
||||
----------
|
||||
|
||||
.. versionadded:: 3.7
|
||||
|
||||
Find Vulkan, which is a low-overhead, cross-platform 3D graphics
|
||||
and computing API.
|
||||
|
||||
Optional COMPONENTS
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 3.24
|
||||
|
||||
This module respects several optional COMPONENTS.
|
||||
There are corresponding imported targets for each of these.
|
||||
|
||||
``glslc``
|
||||
The SPIR-V compiler.
|
||||
|
||||
``glslangValidator``
|
||||
The ``glslangValidator`` tool.
|
||||
|
||||
``glslang``
|
||||
The SPIR-V generator library.
|
||||
|
||||
``shaderc_combined``
|
||||
The static library for Vulkan shader compilation.
|
||||
|
||||
``SPIRV-Tools``
|
||||
Tools to process SPIR-V modules.
|
||||
|
||||
``MoltenVK``
|
||||
On macOS, an additional component ``MoltenVK`` is available.
|
||||
|
||||
``dxc``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
The DirectX Shader Compiler.
|
||||
|
||||
The ``glslc`` and ``glslangValidator`` components are provided even
|
||||
if not explicitly requested (for backward compatibility).
|
||||
|
||||
IMPORTED Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found:
|
||||
|
||||
``Vulkan::Vulkan``
|
||||
The main Vulkan library.
|
||||
|
||||
``Vulkan::glslc``
|
||||
.. versionadded:: 3.19
|
||||
|
||||
The GLSLC SPIR-V compiler, if it has been found.
|
||||
|
||||
``Vulkan::Headers``
|
||||
.. versionadded:: 3.21
|
||||
|
||||
Provides just Vulkan headers include paths, if found. No library is
|
||||
included in this target. This can be useful for applications that
|
||||
load Vulkan library dynamically.
|
||||
|
||||
``Vulkan::glslangValidator``
|
||||
.. versionadded:: 3.21
|
||||
|
||||
The glslangValidator tool, if found. It is used to compile GLSL and
|
||||
HLSL shaders into SPIR-V.
|
||||
|
||||
``Vulkan::glslang``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V
|
||||
generator library (glslang).
|
||||
|
||||
``Vulkan::shaderc_combined``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Defined if SDK has the Google static library for Vulkan shader compilation
|
||||
(shaderc_combined).
|
||||
|
||||
``Vulkan::SPIRV-Tools``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Defined if SDK has the Khronos library to process SPIR-V modules
|
||||
(SPIRV-Tools).
|
||||
|
||||
``Vulkan::MoltenVK``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Defined if SDK has the Khronos library which implement a subset of Vulkan API
|
||||
over Apple Metal graphics framework. (MoltenVK).
|
||||
|
||||
``Vulkan::volk``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
Defined if SDK has the Vulkan meta-loader (volk).
|
||||
|
||||
``Vulkan::dxc_lib``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
Defined if SDK has the DirectX shader compiler library.
|
||||
|
||||
``Vulkan::dxc_exe``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
Defined if SDK has the DirectX shader compiler CLI tool.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following variables:
|
||||
|
||||
``Vulkan_FOUND``
|
||||
set to true if Vulkan was found
|
||||
``Vulkan_INCLUDE_DIRS``
|
||||
include directories for Vulkan
|
||||
``Vulkan_LIBRARIES``
|
||||
link against this library to use Vulkan
|
||||
``Vulkan_VERSION``
|
||||
.. versionadded:: 3.23
|
||||
|
||||
value from ``vulkan/vulkan_core.h``
|
||||
``Vulkan_glslc_FOUND``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
True, if the SDK has the glslc executable.
|
||||
``Vulkan_glslangValidator_FOUND``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
True, if the SDK has the glslangValidator executable.
|
||||
``Vulkan_glslang_FOUND``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
True, if the SDK has the glslang library.
|
||||
``Vulkan_shaderc_combined_FOUND``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
True, if the SDK has the shaderc_combined library.
|
||||
``Vulkan_SPIRV-Tools_FOUND``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
True, if the SDK has the SPIRV-Tools library.
|
||||
``Vulkan_MoltenVK_FOUND``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
True, if the SDK has the MoltenVK library.
|
||||
``Vulkan_volk_FOUND``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
True, if the SDK has the volk library.
|
||||
|
||||
``Vulkan_dxc_lib_FOUND``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
True, if the SDK has the DirectX shader compiler library.
|
||||
|
||||
``Vulkan_dxc_exe_FOUND``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
True, if the SDK has the DirectX shader compiler CLI tool.
|
||||
|
||||
|
||||
The module will also defines these cache variables:
|
||||
|
||||
``Vulkan_INCLUDE_DIR``
|
||||
the Vulkan include directory
|
||||
``Vulkan_LIBRARY``
|
||||
the path to the Vulkan library
|
||||
``Vulkan_GLSLC_EXECUTABLE``
|
||||
the path to the GLSL SPIR-V compiler
|
||||
``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE``
|
||||
the path to the glslangValidator tool
|
||||
``Vulkan_glslang_LIBRARY``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Path to the glslang library.
|
||||
``Vulkan_shaderc_combined_LIBRARY``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Path to the shaderc_combined library.
|
||||
``Vulkan_SPIRV-Tools_LIBRARY``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Path to the SPIRV-Tools library.
|
||||
``Vulkan_MoltenVK_LIBRARY``
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Path to the MoltenVK library.
|
||||
|
||||
``Vulkan_volk_LIBRARY``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
Path to the volk library.
|
||||
|
||||
``Vulkan_dxc_LIBRARY``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
Path to the DirectX shader compiler library.
|
||||
|
||||
``Vulkan_dxc_EXECUTABLE``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
Path to the DirectX shader compiler CLI tool.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
.. versionadded:: 3.18
|
||||
|
||||
The ``VULKAN_SDK`` environment variable optionally specifies the
|
||||
location of the Vulkan SDK root directory for the given
|
||||
architecture. It is typically set by sourcing the toplevel
|
||||
``setup-env.sh`` script of the Vulkan SDK directory into the shell
|
||||
environment.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
|
||||
# Provide compatibility with a common invalid component request that
|
||||
# was silently ignored prior to CMake 3.24.
|
||||
if("FATAL_ERROR" IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
message(AUTHOR_WARNING
|
||||
"Ignoring unknown component 'FATAL_ERROR'.\n"
|
||||
"The find_package() command documents no such argument."
|
||||
)
|
||||
list(REMOVE_ITEM Vulkan_FIND_COMPONENTS "FATAL_ERROR")
|
||||
endif()
|
||||
|
||||
# FindVulkan only works correctly for iOS with CMAKE_FIND_FRAMEWORK set to
|
||||
# FIRST or ALWAYS. If LAST or NEVER it will find the macOS dylibs instead
|
||||
# of the iOS frameworks because the macOS lib directory has to be added to
|
||||
# the search path so libraries for various tools can be found.
|
||||
#
|
||||
# For macOS there is a MoltenVK.xcframework which contains a static library.
|
||||
# To find the MoltenVK.dylib, which is needed when building bundles we need
|
||||
# to LAST or NEVER. LAST appears to be default value.
|
||||
#
|
||||
# If frameworks are ever included in the SDK for macOS, the search mechanism
|
||||
# will need revisiting.
|
||||
if(APPLE)
|
||||
if(IOS)
|
||||
if (NOT ${CMAKE_FIND_FRAMEWORK} STREQUAL "FIRST" AND NOT ${CMAKE_FIND_FRAMEWORK} STREQUAL "ALWAYS")
|
||||
message(NOTICE "Temporarily setting CMAKE_FIND_FRAMEWORK to FIRST to find Vulkan iOS frameworks.")
|
||||
set(_Vulkan_saved_cmake_find_framework ${CMAKE_FIND_FRAMEWORK})
|
||||
set(CMAKE_FIND_FRAMEWORK FIRST)
|
||||
endif()
|
||||
else()
|
||||
if (NOT ${CMAKE_FIND_FRAMEWORK} STREQUAL "LAST" AND NOT ${CMAKE_FIND_FRAMEWORK} STREQUAL "NEVER")
|
||||
message(NOTICE "Temporarily setting CMAKE_FIND_FRAMEWORK to LAST to find Vulkan macOS dylibs.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
# Make robust against different ways VULKAN_SDK may be set.
|
||||
get_filename_component(_Vulkan_SDK_dirname "$ENV{VULKAN_SDK}" NAME)
|
||||
if(${_Vulkan_SDK_dirname} STREQUAL "macOS" OR ${_Vulkan_SDK_dirname} STREQUAL "iOS")
|
||||
get_filename_component(Vulkan_SDK_Base "$ENV{VULKAN_SDK}/.." REALPATH)
|
||||
else()
|
||||
get_filename_component(Vulkan_SDK_Base "$ENV{VULKAN_SDK}" REALPATH)
|
||||
endif()
|
||||
set(_Vulkan_SDK ${Vulkan_SDK_Base}/macOS)
|
||||
if(IOS)
|
||||
list(APPEND CMAKE_FRAMEWORK_PATH "${Vulkan_SDK_Base}/iOS/lib")
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
|
||||
endif()
|
||||
else()
|
||||
set(_Vulkan_SDK "$ENV{VULKAN_SDK}")
|
||||
endif()
|
||||
|
||||
# For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc`
|
||||
# and `glslangValidator` without requesting the corresponding component.
|
||||
if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
list(APPEND Vulkan_FIND_COMPONENTS glslc)
|
||||
endif()
|
||||
if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
list(APPEND Vulkan_FIND_COMPONENTS glslangValidator)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(_Vulkan_library_name vulkan-1)
|
||||
set(_Vulkan_hint_include_search_paths
|
||||
${_Vulkan_SDK}/include
|
||||
)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_Vulkan_hint_executable_search_paths
|
||||
${_Vulkan_SDK}/bin
|
||||
)
|
||||
set(_Vulkan_hint_library_search_paths
|
||||
${_Vulkan_SDK}/lib
|
||||
${_Vulkan_SDK}/bin
|
||||
)
|
||||
else()
|
||||
set(_Vulkan_hint_executable_search_paths
|
||||
${_Vulkan_SDK}/bin32
|
||||
${_Vulkan_SDK}/bin
|
||||
)
|
||||
set(_Vulkan_hint_library_search_paths
|
||||
${_Vulkan_SDK}/lib32
|
||||
${_Vulkan_SDK}/bin32
|
||||
${_Vulkan_SDK}/lib
|
||||
${_Vulkan_SDK}/bin
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
set(_Vulkan_library_name vulkan)
|
||||
set(_Vulkan_hint_include_search_paths
|
||||
${_Vulkan_SDK}/include
|
||||
)
|
||||
set(_Vulkan_hint_executable_search_paths
|
||||
${_Vulkan_SDK}/bin
|
||||
)
|
||||
set(_Vulkan_hint_library_search_paths
|
||||
${_Vulkan_SDK}/lib
|
||||
)
|
||||
endif()
|
||||
if(APPLE AND IOS)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
list(APPEND _Vulkan_hint_library_search_paths
|
||||
${Vulkan_SDK_Base}/iOS/lib
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
|
||||
list(APPEND _Vulkan_hint_library_search_paths
|
||||
${Vulkan_SDK_Base}/tvOS/lib
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(Vulkan_INCLUDE_DIR
|
||||
NAMES vulkan/vulkan.h
|
||||
HINTS
|
||||
${_Vulkan_hint_include_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_INCLUDE_DIR)
|
||||
|
||||
find_library(Vulkan_LIBRARY
|
||||
NAMES ${_Vulkan_library_name}
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
message(STATUS "Vulkan_LIBRARY ${Vulkan_LIBRARY} search paths ${_Vulkan_hint_library_search_paths}")
|
||||
mark_as_advanced(Vulkan_LIBRARY)
|
||||
|
||||
find_library(Vulkan_Layer_API_DUMP
|
||||
NAMES VkLayer_api_dump
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_Layer_API_DUMP)
|
||||
|
||||
find_library(Vulkan_Layer_SHADER_OBJECT
|
||||
NAMES VkLayer_khronos_shader_object
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(VkLayer_khronos_shader_object)
|
||||
|
||||
find_library(Vulkan_Layer_SYNC2
|
||||
NAMES VkLayer_khronos_synchronization2
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_Layer_SYNC2)
|
||||
|
||||
find_library(Vulkan_Layer_VALIDATION
|
||||
NAMES VkLayer_khronos_validation
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_Layer_VALIDATION)
|
||||
|
||||
if(glslc IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
find_program(Vulkan_GLSLC_EXECUTABLE
|
||||
NAMES glslc
|
||||
HINTS
|
||||
${_Vulkan_hint_executable_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_GLSLC_EXECUTABLE)
|
||||
endif()
|
||||
if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE
|
||||
NAMES glslangValidator
|
||||
HINTS
|
||||
${_Vulkan_hint_executable_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
|
||||
endif()
|
||||
if(glslang IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
find_library(Vulkan_glslang-spirv_LIBRARY
|
||||
NAMES SPIRV
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-spirv_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY
|
||||
NAMES SPIRVd
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-oglcompiler_LIBRARY
|
||||
NAMES OGLCompiler
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY
|
||||
NAMES OGLCompilerd
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-osdependent_LIBRARY
|
||||
NAMES OSDependent
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY
|
||||
NAMES OSDependentd
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-machineindependent_LIBRARY
|
||||
NAMES MachineIndependent
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY
|
||||
NAMES MachineIndependentd
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-genericcodegen_LIBRARY
|
||||
NAMES GenericCodeGen
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY
|
||||
NAMES GenericCodeGend
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang_LIBRARY
|
||||
NAMES glslang
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang_LIBRARY)
|
||||
|
||||
find_library(Vulkan_glslang_DEBUG_LIBRARY
|
||||
NAMES glslangd
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY)
|
||||
endif()
|
||||
if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
find_library(Vulkan_shaderc_combined_LIBRARY
|
||||
NAMES shaderc_combined
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths})
|
||||
mark_as_advanced(Vulkan_shaderc_combined_LIBRARY)
|
||||
|
||||
find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY
|
||||
NAMES shaderc_combinedd
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths})
|
||||
mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY)
|
||||
endif()
|
||||
if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
find_library(Vulkan_SPIRV-Tools_LIBRARY
|
||||
NAMES SPIRV-Tools
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths})
|
||||
mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY)
|
||||
|
||||
find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY
|
||||
NAMES SPIRV-Toolsd
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths})
|
||||
mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
|
||||
endif()
|
||||
if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
# CMake has a bug in 3.28 that doesn't handle xcframeworks. Do it by hand for now.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.29)
|
||||
set( _Vulkan_hint_library_search_paths ${Vulkan_SDK_Base}/ios/lib/MoltenVK.xcframework/ios-arm64)
|
||||
else ()
|
||||
set( _Vulkan_hint_library_search_paths ${Vulkan_SDK_Base}/ios/lib/)
|
||||
endif ()
|
||||
endif ()
|
||||
find_library(Vulkan_MoltenVK_LIBRARY
|
||||
NAMES MoltenVK
|
||||
NO_DEFAULT_PATH
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths}
|
||||
)
|
||||
message(STATUS "MoltenVK_LIBRARY ${Vulkan_MoltenVK_LIBRARY} search paths ${_Vulkan_hint_library_search_paths}")
|
||||
mark_as_advanced(Vulkan_MoltenVK_LIBRARY)
|
||||
|
||||
find_path(Vulkan_MoltenVK_INCLUDE_DIR
|
||||
NAMES MoltenVK/mvk_vulkan.h
|
||||
HINTS
|
||||
${_Vulkan_hint_include_search_paths}
|
||||
)
|
||||
mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR)
|
||||
endif()
|
||||
if(volk IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
find_library(Vulkan_volk_LIBRARY
|
||||
NAMES volk
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths})
|
||||
mark_as_advanced(Vulkan_Volk_LIBRARY)
|
||||
endif()
|
||||
|
||||
if (dxc IN_LIST Vulkan_FIND_COMPONENTS)
|
||||
find_library(Vulkan_dxc_LIBRARY
|
||||
NAMES dxcompiler
|
||||
HINTS
|
||||
${_Vulkan_hint_library_search_paths})
|
||||
mark_as_advanced(Vulkan_dxc_LIBRARY)
|
||||
|
||||
find_program(Vulkan_dxc_EXECUTABLE
|
||||
NAMES dxc
|
||||
HINTS
|
||||
${_Vulkan_hint_executable_search_paths})
|
||||
mark_as_advanced(Vulkan_dxc_EXECUTABLE)
|
||||
endif()
|
||||
|
||||
if(DEFINED _Vulkan_saved_cmake_find_framework)
|
||||
set(CMAKE_FIND_FRAMEWORK ${_Vulkan_saved_cmake_find_framework})
|
||||
unset(_Vulkan_saved_cmake_find_framework)
|
||||
endif()
|
||||
|
||||
if(Vulkan_GLSLC_EXECUTABLE)
|
||||
set(Vulkan_glslc_FOUND TRUE)
|
||||
else()
|
||||
set(Vulkan_glslc_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
|
||||
set(Vulkan_glslangValidator_FOUND TRUE)
|
||||
else()
|
||||
set(Vulkan_glslangValidator_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
if (Vulkan_dxc_EXECUTABLE)
|
||||
set(Vulkan_dxc_exe_FOUND TRUE)
|
||||
else()
|
||||
set(Vulkan_dxc_exe_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
function(_Vulkan_set_library_component_found component)
|
||||
cmake_parse_arguments(PARSE_ARGV 1 _ARG
|
||||
"NO_WARNING"
|
||||
""
|
||||
"DEPENDENT_COMPONENTS")
|
||||
|
||||
set(all_dependent_component_found TRUE)
|
||||
foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS)
|
||||
if(NOT Vulkan_${dependent_component}_FOUND)
|
||||
set(all_dependent_component_found FALSE)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY))
|
||||
set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE)
|
||||
|
||||
# For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI:
|
||||
# - Release binaries uses a runtime library
|
||||
# - Debug binaries uses a debug runtime library
|
||||
# This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI.
|
||||
if(WIN32 AND NOT _ARG_NO_WARNING)
|
||||
if(NOT Vulkan_${component}_LIBRARY)
|
||||
message(WARNING
|
||||
"Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.")
|
||||
endif()
|
||||
if(NOT Vulkan_${component}_DEBUG_LIBRARY)
|
||||
message(WARNING
|
||||
"Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
_Vulkan_set_library_component_found(glslang-spirv NO_WARNING)
|
||||
_Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING)
|
||||
_Vulkan_set_library_component_found(glslang-osdependent NO_WARNING)
|
||||
_Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING)
|
||||
_Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING)
|
||||
_Vulkan_set_library_component_found(glslang
|
||||
DEPENDENT_COMPONENTS
|
||||
glslang-spirv
|
||||
glslang-oglcompiler
|
||||
glslang-osdependent
|
||||
glslang-machineindependent
|
||||
glslang-genericcodegen)
|
||||
_Vulkan_set_library_component_found(shaderc_combined)
|
||||
_Vulkan_set_library_component_found(SPIRV-Tools)
|
||||
_Vulkan_set_library_component_found(volk)
|
||||
_Vulkan_set_library_component_found(dxc)
|
||||
|
||||
if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY)
|
||||
set(Vulkan_MoltenVK_FOUND TRUE)
|
||||
else()
|
||||
set(Vulkan_MoltenVK_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
|
||||
set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
|
||||
|
||||
# detect version e.g 1.2.189
|
||||
set(Vulkan_VERSION "")
|
||||
if(Vulkan_INCLUDE_DIR)
|
||||
set(VULKAN_CORE_H ${Vulkan_INCLUDE_DIR}/vulkan/vulkan_core.h)
|
||||
if(EXISTS ${VULKAN_CORE_H})
|
||||
file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ")
|
||||
string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}")
|
||||
file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ")
|
||||
string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}")
|
||||
list(LENGTH VulkanHeaderVersion2 _len)
|
||||
# versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2'
|
||||
if(_len EQUAL 3)
|
||||
list(REMOVE_AT VulkanHeaderVersion2 0)
|
||||
endif()
|
||||
list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion})
|
||||
list(JOIN VulkanHeaderVersion2 "." Vulkan_VERSION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(Vulkan_MoltenVK_FOUND)
|
||||
set(Vulkan_MoltenVK_VERSION "")
|
||||
if(Vulkan_MoltenVK_INCLUDE_DIR)
|
||||
set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h)
|
||||
if(EXISTS ${VK_MVK_MOLTENVK_H})
|
||||
file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ")
|
||||
string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}")
|
||||
file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ")
|
||||
string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}")
|
||||
file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ")
|
||||
string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}")
|
||||
set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}")
|
||||
unset(_Vulkan_MoltenVK_VERSION_MAJOR)
|
||||
unset(_Vulkan_MoltenVK_VERSION_MINOR)
|
||||
unset(_Vulkan_MoltenVK_VERSION_PATCH)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Vulkan
|
||||
REQUIRED_VARS
|
||||
Vulkan_LIBRARY
|
||||
Vulkan_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
Vulkan_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
|
||||
if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan)
|
||||
add_library(Vulkan::Vulkan UNKNOWN IMPORTED)
|
||||
get_filename_component(_Vulkan_lib_extension ${Vulkan_LIBRARIES} LAST_EXT)
|
||||
if(_Vulkan_lib_extension STREQUAL ".framework" AND CMAKE_VERSION VERSION_LESS 3.28)
|
||||
set_target_properties(Vulkan::Vulkan PROPERTIES
|
||||
# Prior to 3.28 must reference library just inside the framework.
|
||||
IMPORTED_LOCATION "${Vulkan_LIBRARIES}/vulkan")
|
||||
else()
|
||||
set_target_properties(Vulkan::Vulkan PROPERTIES
|
||||
IMPORTED_LOCATION "${Vulkan_LIBRARIES}")
|
||||
endif()
|
||||
set_target_properties(Vulkan::Vulkan PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
unset(_Vulkan_lib_extension)
|
||||
endif()
|
||||
|
||||
if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers)
|
||||
add_library(Vulkan::Headers INTERFACE IMPORTED)
|
||||
set_target_properties(Vulkan::Headers PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc)
|
||||
add_executable(Vulkan::glslc IMPORTED)
|
||||
set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::glslangValidator)
|
||||
add_executable(Vulkan::glslangValidator IMPORTED)
|
||||
set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
if(Vulkan_FOUND)
|
||||
if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv)
|
||||
add_library(Vulkan::glslang-spirv STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::glslang-spirv
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_glslang-spirv_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-spirv APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::glslang-spirv
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_glslang-spirv_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-spirv APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::glslang-spirv
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler)
|
||||
add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::glslang-oglcompiler
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_glslang-oglcompiler_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-oglcompiler APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::glslang-oglcompiler
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-oglcompiler APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::glslang-oglcompiler
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent)
|
||||
add_library(Vulkan::glslang-osdependent STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::glslang-osdependent
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_glslang-osdependent_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-osdependent APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::glslang-osdependent
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-osdependent APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::glslang-osdependent
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent)
|
||||
add_library(Vulkan::glslang-machineindependent STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::glslang-machineindependent
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_glslang-machineindependent_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-machineindependent APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::glslang-machineindependent
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-machineindependent APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::glslang-machineindependent
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen)
|
||||
add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::glslang-genericcodegen
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_glslang-genericcodegen_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-genericcodegen APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::glslang-genericcodegen
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang-genericcodegen APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::glslang-genericcodegen
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY)
|
||||
AND TARGET Vulkan::glslang-spirv
|
||||
AND TARGET Vulkan::glslang-oglcompiler
|
||||
AND TARGET Vulkan::glslang-osdependent
|
||||
AND TARGET Vulkan::glslang-machineindependent
|
||||
AND TARGET Vulkan::glslang-genericcodegen
|
||||
AND NOT TARGET Vulkan::glslang)
|
||||
add_library(Vulkan::glslang STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::glslang
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_glslang_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::glslang
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_glslang_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::glslang APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::glslang
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
target_link_libraries(Vulkan::glslang
|
||||
INTERFACE
|
||||
Vulkan::glslang-spirv
|
||||
Vulkan::glslang-oglcompiler
|
||||
Vulkan::glslang-osdependent
|
||||
Vulkan::glslang-machineindependent
|
||||
Vulkan::glslang-genericcodegen
|
||||
)
|
||||
endif()
|
||||
|
||||
if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined)
|
||||
add_library(Vulkan::shaderc_combined STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::shaderc_combined
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_shaderc_combined_LIBRARY)
|
||||
set_property(TARGET Vulkan::shaderc_combined APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::shaderc_combined
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_shaderc_combined_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::shaderc_combined APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::shaderc_combined
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(Vulkan::shaderc_combined
|
||||
INTERFACE
|
||||
Threads::Threads)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools)
|
||||
add_library(Vulkan::SPIRV-Tools STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::SPIRV-Tools
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
if(Vulkan_SPIRV-Tools_LIBRARY)
|
||||
set_property(TARGET Vulkan::SPIRV-Tools APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::SPIRV-Tools
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}")
|
||||
endif()
|
||||
if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
|
||||
set_property(TARGET Vulkan::SPIRV-Tools APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Debug)
|
||||
set_property(TARGET Vulkan::SPIRV-Tools
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk)
|
||||
add_library(Vulkan::volk STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::volk
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
set_property(TARGET Vulkan::volk APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::volk APPEND
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}")
|
||||
|
||||
if (NOT WIN32)
|
||||
set_property(TARGET Vulkan::volk APPEND
|
||||
PROPERTY
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES dl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (Vulkan_dxc_LIBRARY AND NOT TARGET Vulkan::dxc_lib)
|
||||
add_library(Vulkan::dxc_lib STATIC IMPORTED)
|
||||
set_property(TARGET Vulkan::dxc_lib
|
||||
PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
|
||||
set_property(TARGET Vulkan::dxc_lib APPEND
|
||||
PROPERTY
|
||||
IMPORTED_CONFIGURATIONS Release)
|
||||
set_property(TARGET Vulkan::dxc_lib APPEND
|
||||
PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if(Vulkan_dxc_EXECUTABLE AND NOT TARGET Vulkan::dxc_exe)
|
||||
add_executable(Vulkan::dxc_exe IMPORTED)
|
||||
set_property(TARGET Vulkan::dxc_exe PROPERTY IMPORTED_LOCATION "${Vulkan_dxc_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(Vulkan_MoltenVK_FOUND)
|
||||
if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK)
|
||||
add_library(Vulkan::MoltenVK SHARED IMPORTED)
|
||||
set_target_properties(Vulkan::MoltenVK
|
||||
PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
unset(_Vulkan_library_name)
|
||||
unset(_Vulkan_SDK)
|
||||
unset(_Vulkan_SDK_dirname)
|
||||
unset(_Vulkan_hint_include_search_paths)
|
||||
unset(_Vulkan_hint_executable_search_paths)
|
||||
unset(_Vulkan_hint_library_search_paths)
|
||||
|
||||
cmake_policy(POP)
|
||||
@@ -0,0 +1,89 @@
|
||||
# Copyright 2020 Andreas Atteneder
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ASSIMP_ARCHITECTURE "64")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(ASSIMP_ARCHITECTURE "32")
|
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
|
||||
if(WIN32)
|
||||
set(ASSIMP_ROOT_DIR CACHE PATH "ASSIMP root directory")
|
||||
|
||||
# Find path of each library
|
||||
find_path(ASSIMP_INCLUDE_DIR
|
||||
NAMES
|
||||
assimp/anim.h
|
||||
HINTS
|
||||
${ASSIMP_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
if(MSVC12)
|
||||
set(ASSIMP_MSVC_VERSION "vc120")
|
||||
elseif(MSVC14)
|
||||
set(ASSIMP_MSVC_VERSION "vc140")
|
||||
endif(MSVC12)
|
||||
|
||||
if(MSVC12 OR MSVC14)
|
||||
|
||||
find_path(ASSIMP_LIBRARY_DIR
|
||||
NAMES
|
||||
assimp-${ASSIMP_MSVC_VERSION}-mt.lib
|
||||
HINTS
|
||||
${ASSIMP_ROOT_DIR}/lib${ASSIMP_ARCHITECTURE}
|
||||
)
|
||||
|
||||
find_library(ASSIMP_LIBRARY_RELEASE assimp-${ASSIMP_MSVC_VERSION}-mt.lib PATHS ${ASSIMP_LIBRARY_DIR})
|
||||
find_library(ASSIMP_LIBRARY_DEBUG assimp-${ASSIMP_MSVC_VERSION}-mtd.lib PATHS ${ASSIMP_LIBRARY_DIR})
|
||||
|
||||
set(ASSIMP_LIBRARY
|
||||
optimized ${ASSIMP_LIBRARY_RELEASE}
|
||||
debug ${ASSIMP_LIBRARY_DEBUG}
|
||||
)
|
||||
|
||||
set(ASSIMP_LIBRARIES "ASSIMP_LIBRARY_RELEASE" "ASSIMP_LIBRARY_DEBUG")
|
||||
|
||||
FUNCTION(ASSIMP_COPY_BINARIES TargetDirectory)
|
||||
ADD_CUSTOM_TARGET(AssimpCopyBinaries
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${TargetDirectory}/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${TargetDirectory}/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll
|
||||
COMMENT "Copying Assimp binaries to '${TargetDirectory}'"
|
||||
VERBATIM)
|
||||
ENDFUNCTION(ASSIMP_COPY_BINARIES)
|
||||
|
||||
endif()
|
||||
|
||||
else(WIN32)
|
||||
|
||||
find_path(
|
||||
assimp_INCLUDE_DIRS
|
||||
NAMES assimp/postprocess.h assimp/scene.h assimp/version.h assimp/config.h assimp/cimport.h
|
||||
PATHS /usr/local/include
|
||||
PATHS /usr/include/
|
||||
|
||||
)
|
||||
|
||||
find_library(
|
||||
assimp_LIBRARIES
|
||||
NAMES assimp
|
||||
PATHS /usr/local/lib/
|
||||
PATHS /usr/lib64/
|
||||
PATHS /usr/lib/
|
||||
)
|
||||
|
||||
if (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
SET(assimp_FOUND TRUE)
|
||||
ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
|
||||
if (assimp_FOUND)
|
||||
if (NOT assimp_FIND_QUIETLY)
|
||||
message(STATUS "Found asset importer library: ${assimp_LIBRARIES}")
|
||||
endif (NOT assimp_FIND_QUIETLY)
|
||||
else (assimp_FOUND)
|
||||
if (assimp_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find asset importer library")
|
||||
endif (assimp_FIND_REQUIRED)
|
||||
endif (assimp_FOUND)
|
||||
|
||||
endif(WIN32)
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#[============================================================================
|
||||
# Copyright 2022, Khronos Group, Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#============================================================================]
|
||||
|
||||
# Functions to convert unix-style paths into paths useable by cmake on windows.
|
||||
#[=======================================================================[.rst:
|
||||
Findsigntool
|
||||
-------
|
||||
|
||||
Finds the signtool executable used for codesigning on Windows.
|
||||
|
||||
Note that signtool does not offer a way to make it print its version
|
||||
so version selection and reporting is not possible.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``signtool_FOUND``
|
||||
True if the system has the signtool executable.
|
||||
``signtool_EXECUTABLE``
|
||||
The signtool command executable.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
if (WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES "CYGWIN.*")
|
||||
find_program(CYGPATH
|
||||
NAMES cygpath
|
||||
HINTS [HKEY_LOCAL_MACHINE\\Software\\Cygwin\\setup;rootdir]/bin
|
||||
PATHS C:/cygwin64/bin
|
||||
C:/cygwin/bin
|
||||
)
|
||||
endif ()
|
||||
|
||||
function(convert_cygwin_path _pathvar)
|
||||
if (WIN32 AND CYGPATH)
|
||||
execute_process(
|
||||
COMMAND "${CYGPATH}" -m "${${_pathvar}}"
|
||||
OUTPUT_VARIABLE ${_pathvar}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(${_pathvar} "${${_pathvar}}" PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
function(convert_windows_path _pathvar)
|
||||
if (CYGPATH)
|
||||
execute_process(
|
||||
COMMAND "${CYGPATH}" "${${_pathvar}}"
|
||||
OUTPUT_VARIABLE ${_pathvar}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(${_pathvar} "${${_pathvar}}" PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
# Make a list of Windows Kit versions with newer versions first.
|
||||
#
|
||||
# _root string KitsRoot for the Windows version whose kits to find.
|
||||
# _versions variable name Variable in which to return the list of versions.
|
||||
#
|
||||
function(find_kits _winver _kit_versions)
|
||||
set(${_kit_versions})
|
||||
set(_kit_root "KitsRoot${_winver}")
|
||||
set(regkey "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots")
|
||||
set(regval ${_kit_root})
|
||||
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
|
||||
# Note: must be a cache operation in order to read from the registry.
|
||||
get_filename_component(_kits_path "[${regkey};${regval}]"
|
||||
ABSOLUTE CACHE
|
||||
)
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "CYGWIN.*")
|
||||
# On Cygwin, CMake's built-in registry query won't work.
|
||||
# Use Cygwin utility "regtool" instead.
|
||||
execute_process(COMMAND regtool get "\\${regkey}\\${regval}"
|
||||
OUTPUT_VARIABLE _kits_path}
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (_kits_path)
|
||||
convert_windows_path(_kits_path)
|
||||
endif ()
|
||||
endif()
|
||||
if (_kits_path)
|
||||
file(GLOB ${_kit_versions} "${_kits_path}/bin/${_winver}.*")
|
||||
# Reverse list, so newer versions (higher-numbered) appear first.
|
||||
list(REVERSE ${_kit_versions})
|
||||
endif ()
|
||||
unset(_kits_path CACHE)
|
||||
set(${_kit_versions} ${${_kit_versions}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if (WIN32 AND NOT signtool_EXECUTABLE)
|
||||
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "AMD64")
|
||||
set(arch "x64")
|
||||
else()
|
||||
set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||
endif()
|
||||
|
||||
# Look for latest signtool
|
||||
foreach(winver 11 10)
|
||||
find_kits(${winver} kit_versions)
|
||||
if (kit_versions)
|
||||
find_program(signtool_EXECUTABLE
|
||||
NAMES signtool
|
||||
PATHS ${kit_versions}
|
||||
PATH_SUFFIXES ${arch}
|
||||
bin/${arch}
|
||||
bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (signtool_EXECUTABLE)
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (signtool_EXECUTABLE)
|
||||
mark_as_advanced (signtool_EXECUTABLE)
|
||||
endif ()
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE
|
||||
# if all listed variables are found or TRUE
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args (
|
||||
signtool
|
||||
REQUIRED_VARS
|
||||
signtool_EXECUTABLE
|
||||
FAIL_MESSAGE
|
||||
"Could NOT find signtool. Will be unable to sign Windows binaries."
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,33 @@
|
||||
# Copyright 2020 Andreas Atteneder
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# - Find zstd
|
||||
# Find the zstd compression library and includes
|
||||
#
|
||||
# zstd_INCLUDE_DIRS - where to find zstd.h, etc.
|
||||
# zstd_LIBRARIES - List of libraries when using zstd.
|
||||
# zstd_FOUND - True if zstd found.
|
||||
|
||||
find_path(zstd_INCLUDE_DIRS
|
||||
NAMES zstd.h
|
||||
HINTS ${zstd_ROOT_DIR}/include)
|
||||
|
||||
find_library(zstd_LIBRARIES
|
||||
NAMES zstd
|
||||
HINTS ${zstd_ROOT_DIR}/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(zstd DEFAULT_MSG zstd_LIBRARIES zstd_INCLUDE_DIRS)
|
||||
|
||||
mark_as_advanced(
|
||||
zstd_LIBRARIES
|
||||
zstd_INCLUDE_DIRS)
|
||||
|
||||
if(zstd_FOUND AND NOT (TARGET zstd::zstd))
|
||||
add_library (zstd::zstd UNKNOWN IMPORTED)
|
||||
set_target_properties(zstd::zstd
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION ${zstd_LIBRARIES}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${zstd_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
# Copyright 2009-2010 Iowa State University
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
# - Returns a version string from Git
|
||||
#
|
||||
# These functions force a re-configure on each git commit so that you can
|
||||
# trust the values of the variables in your build system.
|
||||
#
|
||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting
|
||||
# the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree,
|
||||
# and adjusting the output so that it tests false if there was no exact
|
||||
# matching tag.
|
||||
#
|
||||
# git_local_changes(<var>)
|
||||
#
|
||||
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
|
||||
# Uses the return code of "git diff-index --quiet HEAD --".
|
||||
# Does not regard untracked files.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__get_git_revision_description)
|
||||
return()
|
||||
endif()
|
||||
set(__get_git_revision_description YES)
|
||||
|
||||
# We must run the following at "include" time, not at function call time,
|
||||
# to find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(get_git_head_revision _refspecvar _hashvar)
|
||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
endwhile()
|
||||
# check if this is a submodule
|
||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||
file(READ ${GIT_DIR} submodule)
|
||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
||||
endif()
|
||||
if(NOT IS_DIRECTORY "${GIT_DIR}")
|
||||
file(READ ${GIT_DIR} worktree)
|
||||
string(REGEX REPLACE "gitdir: (.*)worktrees(.*)\n$" "\\1" GIT_DIR ${worktree})
|
||||
endif()
|
||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||
if(NOT EXISTS "${GIT_DATA}")
|
||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||
return()
|
||||
endif()
|
||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||
|
||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||
"${GIT_DATA}/grabRef.cmake"
|
||||
@ONLY)
|
||||
include("${GIT_DATA}/grabRef.cmake")
|
||||
|
||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize
|
||||
#if((${ARGN}" MATCHES "&&") OR
|
||||
# (ARGN MATCHES "||") OR
|
||||
# (ARGN MATCHES "\\;"))
|
||||
# message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||
#endif()
|
||||
|
||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
describe
|
||||
${hash}
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_local_changes _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
diff-index --quiet HEAD --
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(res EQUAL 0)
|
||||
set(${_var} "CLEAN" PARENT_SCOPE)
|
||||
else()
|
||||
set(${_var} "DIRTY" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -0,0 +1,44 @@
|
||||
# Copyright 2009-2010 Iowa State University
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#
|
||||
# Internal file for GetGitRevisionDescription.cmake
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set(HEAD_HASH)
|
||||
|
||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||
|
||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||
if(HEAD_CONTENTS MATCHES "ref")
|
||||
# named branch
|
||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
else()
|
||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# detached HEAD
|
||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HEAD_HASH)
|
||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||
endif()
|
||||
@@ -0,0 +1,79 @@
|
||||
#[============================================================================
|
||||
# Copyright 2022, Khronos Group, Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#============================================================================]
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
KtxDependentVariable
|
||||
--------------------
|
||||
|
||||
Macro to provide a cache variable dependent on other options.
|
||||
|
||||
This macro presents the variable to the user only if a set of other
|
||||
conditions are true.
|
||||
|
||||
.. command:: dependent_variable
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
KTX_DEPENDENT_VARIABLE(<var> type "<help_text>" <value> <depends> <force>)
|
||||
|
||||
Makes ``<var>`` available to the user if the
|
||||
:ref:`semicolon-separated list <CMake Language Lists>` of conditions in
|
||||
``<depends>`` are all true. Otherwise, a local variable named ``<var>``
|
||||
is set to ``<force>``.
|
||||
|
||||
When ``<var>`` is available, the given ``<help_text>`` and initial
|
||||
``<value>`` are used. Otherwise, any value set by the user is preserved for
|
||||
when ``<depends>`` is satisfied in the future.
|
||||
|
||||
Note that the ``<var>`` variable only has a value which satisfies the
|
||||
``<depends>`` condition within the scope of the caller because it is a local
|
||||
variable.
|
||||
|
||||
Example invocation:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
KTX_DEPENDENT_VARIABLE(USE_FOO STRING "Use Foo" "Default" "USE_BAR;NOT USE_ZOT" "")
|
||||
|
||||
If ``USE_BAR`` is true and ``USE_ZOT`` is false, this provides an var called
|
||||
``USE_FOO`` that defaults to Default. Otherwise, it sets ``USE_FOO`` to OFF and
|
||||
hides the var from the user. If the status of ``USE_BAR`` or ``USE_ZOT``
|
||||
ever changes, any value for the ``USE_FOO`` var is saved so that when the
|
||||
var is re-enabled it retains its old value.
|
||||
|
||||
An important difference to CMakeDependentOption is that this does an early
|
||||
out on false when processing the list of dependencies. This is so expressions
|
||||
of dependencies based on a potentially unset variable do not fail when it
|
||||
is unset.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
macro(KTX_DEPENDENT_VARIABLE var type doc default depends force)
|
||||
if(${var}_ISSET MATCHES "^${var}_ISSET$")
|
||||
set(${var}_AVAILABLE 1)
|
||||
foreach(d ${depends})
|
||||
cmake_language(EVAL CODE "
|
||||
if (${d})
|
||||
else()
|
||||
set(${var}_AVAILABLE 0)
|
||||
endif()"
|
||||
)
|
||||
if(NOT ${${var}_AVAILABLE})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(${var}_AVAILABLE)
|
||||
set(${var} "${${var}}" CACHE ${type} "${doc}" FORCE)
|
||||
else()
|
||||
if(${var} MATCHES "^${var}$")
|
||||
else()
|
||||
set(${var} "${${var}}" CACHE INTERNAL "${doc}")
|
||||
endif()
|
||||
set(${var} ${force})
|
||||
endif()
|
||||
else()
|
||||
set(${var} "${${var}_ISSET}")
|
||||
endif()
|
||||
endmacro()
|
||||
@@ -0,0 +1,37 @@
|
||||
[Settings]
|
||||
NumFields=4
|
||||
|
||||
[Field 1]
|
||||
Type=label
|
||||
Text=By default @CPACK_PACKAGE_INSTALL_DIRECTORY@ does not add its directory to the system PATH.
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=0
|
||||
Bottom=20
|
||||
|
||||
[Field 2]
|
||||
Type=radiobutton
|
||||
Text=Do not add @CPACK_PACKAGE_NAME@ to the system PATH
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=30
|
||||
Bottom=40
|
||||
State=1
|
||||
|
||||
[Field 3]
|
||||
Type=radiobutton
|
||||
Text=Add @CPACK_PACKAGE_NAME@ to the system PATH for all users
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=40
|
||||
Bottom=50
|
||||
State=0
|
||||
|
||||
[Field 4]
|
||||
Type=radiobutton
|
||||
Text=Add @CPACK_PACKAGE_NAME@ to the system PATH for current user
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=50
|
||||
Bottom=60
|
||||
State=0
|
||||
@@ -0,0 +1,987 @@
|
||||
; Copyright 2020 Andreas Atteneder
|
||||
; SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
; CPack install script designed for a nmake build
|
||||
|
||||
;--------------------------------
|
||||
; You must define these values
|
||||
|
||||
!define VERSION "@CPACK_PACKAGE_VERSION@"
|
||||
!define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
|
||||
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
|
||||
|
||||
;--------------------------------
|
||||
;Variables
|
||||
|
||||
Var MUI_TEMP
|
||||
;Var STARTMENU_FOLDER
|
||||
Var SV_ALLUSERS
|
||||
;Var START_MENU
|
||||
Var DO_NOT_ADD_TO_PATH
|
||||
Var ADD_TO_PATH_ALL_USERS
|
||||
Var ADD_TO_PATH_CURRENT_USER
|
||||
Var INSTALL_DESKTOP
|
||||
Var IS_DEFAULT_INSTALLDIR
|
||||
;--------------------------------
|
||||
;Include Modern UI
|
||||
|
||||
!include "MUI.nsh"
|
||||
|
||||
;Default installation folder
|
||||
InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||
|
||||
;--------------------------------
|
||||
;Signing
|
||||
|
||||
!finalize '@CPACK_NSIS_FINALIZE_CMD@'
|
||||
!uninstfinalize '@CPACK_NSIS_FINALIZE_CMD@'
|
||||
|
||||
;--------------------------------
|
||||
;General
|
||||
|
||||
;Name and file
|
||||
Name "@CPACK_NSIS_PACKAGE_NAME@"
|
||||
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
|
||||
|
||||
;Set compression
|
||||
SetCompressor @CPACK_NSIS_COMPRESSOR@
|
||||
|
||||
;Require administrator access
|
||||
RequestExecutionLevel admin
|
||||
|
||||
@CPACK_NSIS_DEFINES@
|
||||
|
||||
!include Sections.nsh
|
||||
|
||||
;--- Component support macros: ---
|
||||
; The code for the add/remove functionality is from:
|
||||
; http://nsis.sourceforge.net/Add/Remove_Functionality
|
||||
; It has been modified slightly and extended to provide
|
||||
; inter-component dependencies.
|
||||
Var AR_SecFlags
|
||||
Var AR_RegFlags
|
||||
@CPACK_NSIS_SECTION_SELECTED_VARS@
|
||||
|
||||
; Loads the "selected" flag for the section named SecName into the
|
||||
; variable VarName.
|
||||
!macro LoadSectionSelectedIntoVar SecName VarName
|
||||
SectionGetFlags ${${SecName}} $${VarName}
|
||||
IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
|
||||
!macroend
|
||||
|
||||
; Loads the value of a variable... can we get around this?
|
||||
!macro LoadVar VarName
|
||||
IntOp $R0 0 + $${VarName}
|
||||
!macroend
|
||||
|
||||
; Sets the value of a variable
|
||||
!macro StoreVar VarName IntValue
|
||||
IntOp $${VarName} 0 + ${IntValue}
|
||||
!macroend
|
||||
|
||||
!macro InitSection SecName
|
||||
; This macro reads component installed flag from the registry and
|
||||
;changes checked state of the section on the components page.
|
||||
;Input: section index constant name specified in Section command.
|
||||
|
||||
ClearErrors
|
||||
;Reading component status from registry
|
||||
ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed"
|
||||
IfErrors "default_${SecName}"
|
||||
;Status will stay default if registry value not found
|
||||
;(component was never installed)
|
||||
IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
|
||||
SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags
|
||||
IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off
|
||||
IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit
|
||||
|
||||
; Note whether this component was installed before
|
||||
!insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
|
||||
IntOp $R0 $AR_RegFlags & $AR_RegFlags
|
||||
|
||||
;Writing modified flags
|
||||
SectionSetFlags ${${SecName}} $AR_SecFlags
|
||||
|
||||
"default_${SecName}:"
|
||||
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
|
||||
!macroend
|
||||
|
||||
!macro FinishSection SecName
|
||||
; This macro reads section flag set by user and removes the section
|
||||
;if it is not selected.
|
||||
;Then it writes component installed flag to registry
|
||||
;Input: section index constant name specified in Section command.
|
||||
|
||||
SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
|
||||
;Checking lowest bit:
|
||||
IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
|
||||
IntCmp $AR_SecFlags 1 "leave_${SecName}"
|
||||
;Section is not selected:
|
||||
;Calling Section uninstall macro and writing zero installed flag
|
||||
!insertmacro "Remove_${${SecName}}"
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
|
||||
"Installed" 0
|
||||
Goto "exit_${SecName}"
|
||||
|
||||
"leave_${SecName}:"
|
||||
;Section is selected:
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
|
||||
"Installed" 1
|
||||
|
||||
"exit_${SecName}:"
|
||||
!macroend
|
||||
|
||||
!macro RemoveSection_CPack SecName
|
||||
; This macro is used to call section's Remove_... macro
|
||||
;from the uninstaller.
|
||||
;Input: section index constant name specified in Section command.
|
||||
|
||||
!insertmacro "Remove_${${SecName}}"
|
||||
!macroend
|
||||
|
||||
; Determine whether the selection of SecName changed
|
||||
!macro MaybeSelectionChanged SecName
|
||||
!insertmacro LoadVar ${SecName}_selected
|
||||
SectionGetFlags ${${SecName}} $R1
|
||||
IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
|
||||
|
||||
; See if the status has changed:
|
||||
IntCmp $R0 $R1 "${SecName}_unchanged"
|
||||
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
|
||||
|
||||
IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
|
||||
!insertmacro "Deselect_required_by_${SecName}"
|
||||
goto "${SecName}_unchanged"
|
||||
|
||||
"${SecName}_was_selected:"
|
||||
!insertmacro "Select_${SecName}_depends"
|
||||
|
||||
"${SecName}_unchanged:"
|
||||
!macroend
|
||||
;--- End of Add/Remove macros ---
|
||||
|
||||
;--------------------------------
|
||||
;Interface Settings
|
||||
|
||||
!define MUI_HEADERIMAGE
|
||||
!define MUI_ABORTWARNING
|
||||
|
||||
;----------------------------------------
|
||||
; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
|
||||
;----------------------------------------
|
||||
!verbose 3
|
||||
!include "WinMessages.NSH"
|
||||
!verbose 4
|
||||
;====================================================
|
||||
; get_NT_environment
|
||||
; Returns: the selected environment
|
||||
; Output : head of the stack
|
||||
;====================================================
|
||||
!macro select_NT_profile UN
|
||||
Function ${UN}select_NT_profile
|
||||
StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
|
||||
DetailPrint "Selected environment for all users"
|
||||
Push "all"
|
||||
Return
|
||||
environment_single:
|
||||
DetailPrint "Selected environment for current user only."
|
||||
Push "current"
|
||||
Return
|
||||
FunctionEnd
|
||||
!macroend
|
||||
!insertmacro select_NT_profile ""
|
||||
!insertmacro select_NT_profile "un."
|
||||
;----------------------------------------------------
|
||||
!define NT_current_env 'HKCU "Environment"'
|
||||
!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||
|
||||
!ifndef WriteEnvStr_RegKey
|
||||
!ifdef ALL_USERS
|
||||
!define WriteEnvStr_RegKey \
|
||||
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||
!else
|
||||
!define WriteEnvStr_RegKey 'HKCU "Environment"'
|
||||
!endif
|
||||
!endif
|
||||
|
||||
; AddToPath - Adds the given dir to the search path.
|
||||
; Input - head of the stack
|
||||
; Note - Win9x systems requires reboot
|
||||
|
||||
Function AddToPath
|
||||
Exch $0
|
||||
Push $1
|
||||
Push $2
|
||||
Push $3
|
||||
|
||||
# don't add if the path doesn't exist
|
||||
IfFileExists "$0\*.*" "" AddToPath_done
|
||||
|
||||
ReadEnvStr $1 PATH
|
||||
; if the path is too long for a NSIS variable NSIS will return a 0
|
||||
; length string. If we find that, then warn and skip any path
|
||||
; modification as it will trash the existing path.
|
||||
StrLen $2 $1
|
||||
IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
|
||||
CheckPathLength_ShowPathWarning:
|
||||
Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!"
|
||||
Goto AddToPath_done
|
||||
CheckPathLength_Done:
|
||||
Push "$1;"
|
||||
Push "$0;"
|
||||
Call StrStr
|
||||
Pop $2
|
||||
StrCmp $2 "" "" AddToPath_done
|
||||
Push "$1;"
|
||||
Push "$0\;"
|
||||
Call StrStr
|
||||
Pop $2
|
||||
StrCmp $2 "" "" AddToPath_done
|
||||
GetFullPathName /SHORT $3 $0
|
||||
Push "$1;"
|
||||
Push "$3;"
|
||||
Call StrStr
|
||||
Pop $2
|
||||
StrCmp $2 "" "" AddToPath_done
|
||||
Push "$1;"
|
||||
Push "$3\;"
|
||||
Call StrStr
|
||||
Pop $2
|
||||
StrCmp $2 "" "" AddToPath_done
|
||||
|
||||
Call IsNT
|
||||
Pop $1
|
||||
StrCmp $1 1 AddToPath_NT
|
||||
; Not on NT
|
||||
StrCpy $1 $WINDIR 2
|
||||
FileOpen $1 "$1\autoexec.bat" a
|
||||
FileSeek $1 -1 END
|
||||
FileReadByte $1 $2
|
||||
IntCmp $2 26 0 +2 +2 # DOS EOF
|
||||
FileSeek $1 -1 END # write over EOF
|
||||
FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
|
||||
FileClose $1
|
||||
SetRebootFlag true
|
||||
Goto AddToPath_done
|
||||
|
||||
AddToPath_NT:
|
||||
StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
|
||||
ReadRegStr $1 ${NT_current_env} "PATH"
|
||||
Goto DoTrim
|
||||
ReadAllKey:
|
||||
ReadRegStr $1 ${NT_all_env} "PATH"
|
||||
DoTrim:
|
||||
StrCmp $1 "" AddToPath_NTdoIt
|
||||
Push $1
|
||||
Call Trim
|
||||
Pop $1
|
||||
StrCpy $0 "$1;$0"
|
||||
AddToPath_NTdoIt:
|
||||
StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
|
||||
WriteRegExpandStr ${NT_current_env} "PATH" $0
|
||||
Goto DoSend
|
||||
WriteAllKey:
|
||||
WriteRegExpandStr ${NT_all_env} "PATH" $0
|
||||
DoSend:
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
AddToPath_done:
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
|
||||
|
||||
; RemoveFromPath - Remove a given dir from the path
|
||||
; Input: head of the stack
|
||||
|
||||
Function un.RemoveFromPath
|
||||
Exch $0
|
||||
Push $1
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
Push $5
|
||||
Push $6
|
||||
|
||||
IntFmt $6 "%c" 26 # DOS EOF
|
||||
|
||||
Call un.IsNT
|
||||
Pop $1
|
||||
StrCmp $1 1 unRemoveFromPath_NT
|
||||
; Not on NT
|
||||
StrCpy $1 $WINDIR 2
|
||||
FileOpen $1 "$1\autoexec.bat" r
|
||||
GetTempFileName $4
|
||||
FileOpen $2 $4 w
|
||||
GetFullPathName /SHORT $0 $0
|
||||
StrCpy $0 "SET PATH=%PATH%;$0"
|
||||
Goto unRemoveFromPath_dosLoop
|
||||
|
||||
unRemoveFromPath_dosLoop:
|
||||
FileRead $1 $3
|
||||
StrCpy $5 $3 1 -1 # read last char
|
||||
StrCmp $5 $6 0 +2 # if DOS EOF
|
||||
StrCpy $3 $3 -1 # remove DOS EOF so we can compare
|
||||
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
|
||||
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
|
||||
StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
|
||||
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
|
||||
FileWrite $2 $3
|
||||
Goto unRemoveFromPath_dosLoop
|
||||
unRemoveFromPath_dosLoopRemoveLine:
|
||||
SetRebootFlag true
|
||||
Goto unRemoveFromPath_dosLoop
|
||||
|
||||
unRemoveFromPath_dosLoopEnd:
|
||||
FileClose $2
|
||||
FileClose $1
|
||||
StrCpy $1 $WINDIR 2
|
||||
Delete "$1\autoexec.bat"
|
||||
CopyFiles /SILENT $4 "$1\autoexec.bat"
|
||||
Delete $4
|
||||
Goto unRemoveFromPath_done
|
||||
|
||||
unRemoveFromPath_NT:
|
||||
StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
|
||||
ReadRegStr $1 ${NT_current_env} "PATH"
|
||||
Goto unDoTrim
|
||||
unReadAllKey:
|
||||
ReadRegStr $1 ${NT_all_env} "PATH"
|
||||
unDoTrim:
|
||||
StrCpy $5 $1 1 -1 # copy last char
|
||||
StrCmp $5 ";" +2 # if last char != ;
|
||||
StrCpy $1 "$1;" # append ;
|
||||
Push $1
|
||||
Push "$0;"
|
||||
Call un.StrStr ; Find `$0;` in $1
|
||||
Pop $2 ; pos of our dir
|
||||
StrCmp $2 "" unRemoveFromPath_done
|
||||
; else, it is in path
|
||||
# $0 - path to add
|
||||
# $1 - path var
|
||||
StrLen $3 "$0;"
|
||||
StrLen $4 $2
|
||||
StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
|
||||
StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
|
||||
StrCpy $3 $5$6
|
||||
|
||||
StrCpy $5 $3 1 -1 # copy last char
|
||||
StrCmp $5 ";" 0 +2 # if last char == ;
|
||||
StrCpy $3 $3 -1 # remove last char
|
||||
|
||||
StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
|
||||
WriteRegExpandStr ${NT_current_env} "PATH" $3
|
||||
Goto unDoSend
|
||||
unWriteAllKey:
|
||||
WriteRegExpandStr ${NT_all_env} "PATH" $3
|
||||
unDoSend:
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
unRemoveFromPath_done:
|
||||
Pop $6
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Uninstall sutff
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
###########################################
|
||||
# Utility Functions #
|
||||
###########################################
|
||||
|
||||
;====================================================
|
||||
; IsNT - Returns 1 if the current system is NT, 0
|
||||
; otherwise.
|
||||
; Output: head of the stack
|
||||
;====================================================
|
||||
; IsNT
|
||||
; no input
|
||||
; output, top of the stack = 1 if NT or 0 if not
|
||||
;
|
||||
; Usage:
|
||||
; Call IsNT
|
||||
; Pop $R0
|
||||
; ($R0 at this point is 1 or 0)
|
||||
|
||||
!macro IsNT un
|
||||
Function ${un}IsNT
|
||||
Push $0
|
||||
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
|
||||
StrCmp $0 "" 0 IsNT_yes
|
||||
; we are not NT.
|
||||
Pop $0
|
||||
Push 0
|
||||
Return
|
||||
|
||||
IsNT_yes:
|
||||
; NT!!!
|
||||
Pop $0
|
||||
Push 1
|
||||
FunctionEnd
|
||||
!macroend
|
||||
!insertmacro IsNT ""
|
||||
!insertmacro IsNT "un."
|
||||
|
||||
; StrStr
|
||||
; input, top of stack = string to search for
|
||||
; top of stack-1 = string to search in
|
||||
; output, top of stack (replaces with the portion of the string remaining)
|
||||
; modifies no other variables.
|
||||
;
|
||||
; Usage:
|
||||
; Push "this is a long ass string"
|
||||
; Push "ass"
|
||||
; Call StrStr
|
||||
; Pop $R0
|
||||
; ($R0 at this point is "ass string")
|
||||
|
||||
!macro StrStr un
|
||||
Function ${un}StrStr
|
||||
Exch $R1 ; st=haystack,old$R1, $R1=needle
|
||||
Exch ; st=old$R1,haystack
|
||||
Exch $R2 ; st=old$R1,old$R2, $R2=haystack
|
||||
Push $R3
|
||||
Push $R4
|
||||
Push $R5
|
||||
StrLen $R3 $R1
|
||||
StrCpy $R4 0
|
||||
; $R1=needle
|
||||
; $R2=haystack
|
||||
; $R3=len(needle)
|
||||
; $R4=cnt
|
||||
; $R5=tmp
|
||||
loop:
|
||||
StrCpy $R5 $R2 $R3 $R4
|
||||
StrCmp $R5 $R1 done
|
||||
StrCmp $R5 "" done
|
||||
IntOp $R4 $R4 + 1
|
||||
Goto loop
|
||||
done:
|
||||
StrCpy $R1 $R2 "" $R4
|
||||
Pop $R5
|
||||
Pop $R4
|
||||
Pop $R3
|
||||
Pop $R2
|
||||
Exch $R1
|
||||
FunctionEnd
|
||||
!macroend
|
||||
!insertmacro StrStr ""
|
||||
!insertmacro StrStr "un."
|
||||
|
||||
Function Trim ; Added by Pelaca
|
||||
Exch $R1
|
||||
Push $R2
|
||||
Loop:
|
||||
StrCpy $R2 "$R1" 1 -1
|
||||
StrCmp "$R2" " " RTrim
|
||||
StrCmp "$R2" "$\n" RTrim
|
||||
StrCmp "$R2" "$\r" RTrim
|
||||
StrCmp "$R2" ";" RTrim
|
||||
GoTo Done
|
||||
RTrim:
|
||||
StrCpy $R1 "$R1" -1
|
||||
Goto Loop
|
||||
Done:
|
||||
Pop $R2
|
||||
Exch $R1
|
||||
FunctionEnd
|
||||
|
||||
Function ConditionalAddToRegisty
|
||||
Pop $0
|
||||
Pop $1
|
||||
StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
|
||||
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \
|
||||
"$1" "$0"
|
||||
;MessageBox MB_OK "Set Registry: '$1' to '$0'"
|
||||
DetailPrint "Set install registry entry: '$1' to '$0'"
|
||||
ConditionalAddToRegisty_EmptyString:
|
||||
FunctionEnd
|
||||
|
||||
;--------------------------------
|
||||
|
||||
!ifdef CPACK_USES_DOWNLOAD
|
||||
Function DownloadFile
|
||||
IfFileExists $INSTDIR\* +2
|
||||
CreateDirectory $INSTDIR
|
||||
Pop $0
|
||||
|
||||
; Skip if already downloaded
|
||||
IfFileExists $INSTDIR\$0 0 +2
|
||||
Return
|
||||
|
||||
StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
|
||||
|
||||
try_again:
|
||||
NSISdl::download "$1/$0" "$INSTDIR\$0"
|
||||
|
||||
Pop $1
|
||||
StrCmp $1 "success" success
|
||||
StrCmp $1 "Cancelled" cancel
|
||||
MessageBox MB_OK "Download failed: $1"
|
||||
cancel:
|
||||
Return
|
||||
success:
|
||||
FunctionEnd
|
||||
!endif
|
||||
|
||||
;--------------------------------
|
||||
; Define some macro setting for the gui
|
||||
@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
|
||||
@CPACK_NSIS_INSTALLER_ICON_CODE@
|
||||
@CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE@
|
||||
@CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE@
|
||||
@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
|
||||
@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
|
||||
|
||||
;--------------------------------
|
||||
;Pages
|
||||
@CPACK_NSIS_INSTALLER_WELCOME_TITLE_CODE@
|
||||
@CPACK_NSIS_INSTALLER_WELCOME_TITLE_3LINES_CODE@
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
|
||||
!insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
|
||||
Page custom InstallOptionsPage
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
|
||||
;Start Menu Folder Page Configuration
|
||||
;!define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
|
||||
;!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||
;!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
|
||||
;!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
|
||||
|
||||
@CPACK_NSIS_PAGE_COMPONENTS@
|
||||
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
@CPACK_NSIS_INSTALLER_FINISH_TITLE_CODE@
|
||||
@CPACK_NSIS_INSTALLER_FINISH_TITLE_3LINES_CODE@
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
|
||||
;--------------------------------
|
||||
;Languages
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English" ;first language is the default language
|
||||
!insertmacro MUI_LANGUAGE "Albanian"
|
||||
!insertmacro MUI_LANGUAGE "Arabic"
|
||||
!insertmacro MUI_LANGUAGE "Basque"
|
||||
!insertmacro MUI_LANGUAGE "Belarusian"
|
||||
!insertmacro MUI_LANGUAGE "Bosnian"
|
||||
!insertmacro MUI_LANGUAGE "Breton"
|
||||
!insertmacro MUI_LANGUAGE "Bulgarian"
|
||||
!insertmacro MUI_LANGUAGE "Croatian"
|
||||
!insertmacro MUI_LANGUAGE "Czech"
|
||||
!insertmacro MUI_LANGUAGE "Danish"
|
||||
!insertmacro MUI_LANGUAGE "Dutch"
|
||||
!insertmacro MUI_LANGUAGE "Estonian"
|
||||
!insertmacro MUI_LANGUAGE "Farsi"
|
||||
!insertmacro MUI_LANGUAGE "Finnish"
|
||||
!insertmacro MUI_LANGUAGE "French"
|
||||
!insertmacro MUI_LANGUAGE "German"
|
||||
!insertmacro MUI_LANGUAGE "Greek"
|
||||
!insertmacro MUI_LANGUAGE "Hebrew"
|
||||
!insertmacro MUI_LANGUAGE "Hungarian"
|
||||
!insertmacro MUI_LANGUAGE "Icelandic"
|
||||
!insertmacro MUI_LANGUAGE "Indonesian"
|
||||
!insertmacro MUI_LANGUAGE "Irish"
|
||||
!insertmacro MUI_LANGUAGE "Italian"
|
||||
!insertmacro MUI_LANGUAGE "Japanese"
|
||||
!insertmacro MUI_LANGUAGE "Korean"
|
||||
!insertmacro MUI_LANGUAGE "Kurdish"
|
||||
!insertmacro MUI_LANGUAGE "Latvian"
|
||||
!insertmacro MUI_LANGUAGE "Lithuanian"
|
||||
!insertmacro MUI_LANGUAGE "Luxembourgish"
|
||||
!insertmacro MUI_LANGUAGE "Macedonian"
|
||||
!insertmacro MUI_LANGUAGE "Malay"
|
||||
!insertmacro MUI_LANGUAGE "Mongolian"
|
||||
!insertmacro MUI_LANGUAGE "Norwegian"
|
||||
!insertmacro MUI_LANGUAGE "Polish"
|
||||
!insertmacro MUI_LANGUAGE "Portuguese"
|
||||
!insertmacro MUI_LANGUAGE "PortugueseBR"
|
||||
!insertmacro MUI_LANGUAGE "Romanian"
|
||||
!insertmacro MUI_LANGUAGE "Russian"
|
||||
!insertmacro MUI_LANGUAGE "Serbian"
|
||||
!insertmacro MUI_LANGUAGE "SerbianLatin"
|
||||
!insertmacro MUI_LANGUAGE "SimpChinese"
|
||||
!insertmacro MUI_LANGUAGE "Slovak"
|
||||
!insertmacro MUI_LANGUAGE "Slovenian"
|
||||
!insertmacro MUI_LANGUAGE "Spanish"
|
||||
!insertmacro MUI_LANGUAGE "Swedish"
|
||||
!insertmacro MUI_LANGUAGE "Thai"
|
||||
!insertmacro MUI_LANGUAGE "TradChinese"
|
||||
!insertmacro MUI_LANGUAGE "Turkish"
|
||||
!insertmacro MUI_LANGUAGE "Ukrainian"
|
||||
!insertmacro MUI_LANGUAGE "Welsh"
|
||||
|
||||
;--------------------------------
|
||||
;Reserve Files
|
||||
|
||||
;These files should be inserted before other files in the data block
|
||||
;Keep these lines before any File command
|
||||
;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
|
||||
|
||||
ReserveFile "NSIS.InstallOptions.ini"
|
||||
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
|
||||
|
||||
; for UserInfo::GetName and UserInfo::GetAccountType
|
||||
ReserveFile /plugin 'UserInfo.dll'
|
||||
|
||||
;--------------------------------
|
||||
; Installation types
|
||||
@CPACK_NSIS_INSTALLATION_TYPES@
|
||||
|
||||
;--------------------------------
|
||||
; Component sections
|
||||
@CPACK_NSIS_COMPONENT_SECTIONS@
|
||||
|
||||
;--------------------------------
|
||||
;Installer Sections
|
||||
|
||||
Section "-Core installation"
|
||||
;Use the entire tree produced by the INSTALL target. Keep the
|
||||
;list of directories here in sync with the RMDir commands below.
|
||||
SetOutPath "$INSTDIR"
|
||||
@CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
|
||||
@CPACK_NSIS_FULL_INSTALL@
|
||||
|
||||
;Store installation folder
|
||||
WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
|
||||
|
||||
;Create uninstaller
|
||||
WriteUninstaller "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe"
|
||||
Push "DisplayName"
|
||||
Push "@CPACK_NSIS_DISPLAY_NAME@"
|
||||
Call ConditionalAddToRegisty
|
||||
Push "DisplayVersion"
|
||||
Push "@CPACK_PACKAGE_VERSION@"
|
||||
Call ConditionalAddToRegisty
|
||||
Push "Publisher"
|
||||
Push "@CPACK_PACKAGE_VENDOR@"
|
||||
Call ConditionalAddToRegisty
|
||||
Push "UninstallString"
|
||||
Push "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe"
|
||||
Call ConditionalAddToRegisty
|
||||
Push "NoRepair"
|
||||
Push "1"
|
||||
Call ConditionalAddToRegisty
|
||||
|
||||
!ifdef CPACK_NSIS_ADD_REMOVE
|
||||
;Create add/remove functionality
|
||||
Push "ModifyPath"
|
||||
Push "$INSTDIR\AddRemove.exe"
|
||||
Call ConditionalAddToRegisty
|
||||
!else
|
||||
Push "NoModify"
|
||||
Push "1"
|
||||
Call ConditionalAddToRegisty
|
||||
!endif
|
||||
|
||||
; Optional registration
|
||||
Push "DisplayIcon"
|
||||
Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
|
||||
Call ConditionalAddToRegisty
|
||||
Push "HelpLink"
|
||||
Push "@CPACK_NSIS_HELP_LINK@"
|
||||
Call ConditionalAddToRegisty
|
||||
Push "URLInfoAbout"
|
||||
Push "@CPACK_NSIS_URL_INFO_ABOUT@"
|
||||
Call ConditionalAddToRegisty
|
||||
Push "Contact"
|
||||
Push "@CPACK_NSIS_CONTACT@"
|
||||
Call ConditionalAddToRegisty
|
||||
;!insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
|
||||
;!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||
|
||||
;Create shortcuts
|
||||
;CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
|
||||
;@CPACK_NSIS_CREATE_ICONS@
|
||||
;@CPACK_NSIS_CREATE_ICONS_EXTRA@
|
||||
;CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe"
|
||||
|
||||
;Read a value from an InstallOptions INI file
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
|
||||
|
||||
; Write special uninstall registry entries
|
||||
;Push "StartMenu"
|
||||
;Push "$STARTMENU_FOLDER"
|
||||
;Call ConditionalAddToRegisty
|
||||
;Push "DoNotAddToPath"
|
||||
;Push "$DO_NOT_ADD_TO_PATH"
|
||||
;Call ConditionalAddToRegisty
|
||||
;Push "AddToPathAllUsers"
|
||||
;Push "$ADD_TO_PATH_ALL_USERS"
|
||||
;Call ConditionalAddToRegisty
|
||||
;Push "AddToPathCurrentUser"
|
||||
;Push "$ADD_TO_PATH_CURRENT_USER"
|
||||
;Call ConditionalAddToRegisty
|
||||
;Push "InstallToDesktop"
|
||||
;Push "$INSTALL_DESKTOP"
|
||||
;Call ConditionalAddToRegisty
|
||||
|
||||
!insertmacro MUI_STARTMENU_WRITE_END
|
||||
|
||||
@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section "-Add to path"
|
||||
Push $INSTDIR\bin
|
||||
StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
|
||||
StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
|
||||
Call AddToPath
|
||||
doNotAddToPath:
|
||||
SectionEnd
|
||||
|
||||
;--------------------------------
|
||||
; Create custom pages
|
||||
Function InstallOptionsPage
|
||||
!insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
|
||||
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
|
||||
|
||||
FunctionEnd
|
||||
|
||||
;--------------------------------
|
||||
; determine admin versus local install
|
||||
Function un.onInit
|
||||
|
||||
ClearErrors
|
||||
UserInfo::GetName
|
||||
IfErrors noLM
|
||||
Pop $0
|
||||
UserInfo::GetAccountType
|
||||
Pop $1
|
||||
StrCmp $1 "Admin" 0 +3
|
||||
SetShellVarContext all
|
||||
;MessageBox MB_OK 'User "$0" is in the Admin group'
|
||||
Goto done
|
||||
StrCmp $1 "Power" 0 +3
|
||||
SetShellVarContext all
|
||||
;MessageBox MB_OK 'User "$0" is in the Power Users group'
|
||||
Goto done
|
||||
|
||||
noLM:
|
||||
;Get installation folder from registry if available
|
||||
|
||||
done:
|
||||
|
||||
FunctionEnd
|
||||
|
||||
;--- Add/Remove callback functions: ---
|
||||
!macro SectionList MacroName
|
||||
;This macro used to perform operation on multiple sections.
|
||||
;List all of your components in following manner here.
|
||||
@CPACK_NSIS_COMPONENT_SECTION_LIST@
|
||||
!macroend
|
||||
|
||||
Section -FinishComponents
|
||||
;Removes unselected components and writes component status to registry
|
||||
!insertmacro SectionList "FinishSection"
|
||||
|
||||
!ifdef CPACK_NSIS_ADD_REMOVE
|
||||
; Get the name of the installer executable
|
||||
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
|
||||
StrCpy $R3 $R0
|
||||
|
||||
; Strip off the last 13 characters, to see if we have AddRemove.exe
|
||||
StrLen $R1 $R0
|
||||
IntOp $R1 $R0 - 13
|
||||
StrCpy $R2 $R0 13 $R1
|
||||
StrCmp $R2 "AddRemove.exe" addremove_installed
|
||||
|
||||
; We're not running AddRemove.exe, so install it
|
||||
CopyFiles $R3 $INSTDIR\AddRemove.exe
|
||||
|
||||
addremove_installed:
|
||||
!endif
|
||||
SectionEnd
|
||||
;--- End of Add/Remove callback functions ---
|
||||
|
||||
;--------------------------------
|
||||
; Component dependencies
|
||||
Function .onSelChange
|
||||
!insertmacro SectionList MaybeSelectionChanged
|
||||
FunctionEnd
|
||||
|
||||
;--------------------------------
|
||||
;Uninstaller Section
|
||||
|
||||
Section "Uninstall"
|
||||
;ReadRegStr $START_MENU SHCTX \
|
||||
; "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
|
||||
;MessageBox MB_OK "Start menu is in: $START_MENU"
|
||||
ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
|
||||
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath"
|
||||
ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
|
||||
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers"
|
||||
ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
|
||||
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser"
|
||||
;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
|
||||
;ReadRegStr $INSTALL_DESKTOP SHCTX \
|
||||
; "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop"
|
||||
;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
|
||||
|
||||
@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
|
||||
|
||||
;Remove files we installed.
|
||||
;Keep the list of directories here in sync with the File commands above.
|
||||
@CPACK_NSIS_DELETE_FILES@
|
||||
@CPACK_NSIS_DELETE_DIRECTORIES@
|
||||
|
||||
!ifdef CPACK_NSIS_ADD_REMOVE
|
||||
;Remove the add/remove program
|
||||
Delete "$INSTDIR\AddRemove.exe"
|
||||
!endif
|
||||
|
||||
;Remove the uninstaller itself.
|
||||
Delete "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe"
|
||||
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||
|
||||
;Remove the installation directory if it is empty.
|
||||
RMDir "$INSTDIR"
|
||||
|
||||
; Remove the registry entries.
|
||||
DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||
|
||||
; Removes all optional components
|
||||
!insertmacro SectionList "RemoveSection_CPack"
|
||||
|
||||
;!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
|
||||
|
||||
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
|
||||
@CPACK_NSIS_DELETE_ICONS@
|
||||
@CPACK_NSIS_DELETE_ICONS_EXTRA@
|
||||
|
||||
;Delete empty start menu parent directories
|
||||
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
|
||||
|
||||
; startMenuDeleteLoop:
|
||||
; ClearErrors
|
||||
; RMDir $MUI_TEMP
|
||||
; GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
|
||||
;
|
||||
; IfErrors startMenuDeleteLoopDone
|
||||
;
|
||||
; StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
|
||||
; startMenuDeleteLoopDone:
|
||||
|
||||
; If the user changed the shortcut, then untinstall may not work. This should
|
||||
; try to fix it.
|
||||
;StrCpy $MUI_TEMP "$START_MENU"
|
||||
;Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
|
||||
@CPACK_NSIS_DELETE_ICONS_EXTRA@
|
||||
|
||||
;Delete empty start menu parent directories
|
||||
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
|
||||
|
||||
; secondStartMenuDeleteLoop:
|
||||
; ClearErrors
|
||||
; RMDir $MUI_TEMP
|
||||
; GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
|
||||
;
|
||||
; IfErrors secondStartMenuDeleteLoopDone
|
||||
;
|
||||
; StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
|
||||
; secondStartMenuDeleteLoopDone:
|
||||
|
||||
DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||
|
||||
Push $INSTDIR\bin
|
||||
StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
|
||||
Call un.RemoveFromPath
|
||||
doNotRemoveFromPath:
|
||||
SectionEnd
|
||||
|
||||
;--------------------------------
|
||||
; determine admin versus local install
|
||||
; Is install for "AllUsers" or "JustMe"?
|
||||
; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
|
||||
; This function is used for the very first "custom page" of the installer.
|
||||
; This custom page does not show up visibly, but it executes prior to the
|
||||
; first visible page and sets up $INSTDIR properly...
|
||||
; Choose different default installation folder based on SV_ALLUSERS...
|
||||
; "Program Files" for AllUsers, "My Documents" for JustMe...
|
||||
|
||||
Function .onInit
|
||||
StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
|
||||
|
||||
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
|
||||
StrCmp $0 "" inst
|
||||
|
||||
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
|
||||
"@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
|
||||
/SD IDYES IDYES uninst IDNO inst
|
||||
Abort
|
||||
|
||||
;Run the uninstaller
|
||||
uninst:
|
||||
ClearErrors
|
||||
StrLen $2 "\Uninstall.exe"
|
||||
StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path
|
||||
ExecWait '"$0" /S _?=$3' ;Do not copy the uninstaller to a temp file
|
||||
|
||||
IfErrors uninst_failed inst
|
||||
uninst_failed:
|
||||
MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
|
||||
Abort
|
||||
|
||||
|
||||
inst:
|
||||
; Reads components status for registry
|
||||
!insertmacro SectionList "InitSection"
|
||||
|
||||
; check to see if /D has been used to change
|
||||
; the install directory by comparing it to the
|
||||
; install directory that is expected to be the
|
||||
; default
|
||||
StrCpy $IS_DEFAULT_INSTALLDIR 0
|
||||
StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
|
||||
StrCpy $IS_DEFAULT_INSTALLDIR 1
|
||||
|
||||
StrCpy $SV_ALLUSERS "JustMe"
|
||||
; if default install dir then change the default
|
||||
; if it is installed for JustMe
|
||||
StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
|
||||
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||
|
||||
ClearErrors
|
||||
UserInfo::GetName
|
||||
IfErrors noLM
|
||||
Pop $0
|
||||
UserInfo::GetAccountType
|
||||
Pop $1
|
||||
StrCmp $1 "Admin" 0 +4
|
||||
SetShellVarContext all
|
||||
;MessageBox MB_OK 'User "$0" is in the Admin group'
|
||||
StrCpy $SV_ALLUSERS "AllUsers"
|
||||
Goto done
|
||||
StrCmp $1 "Power" 0 +4
|
||||
SetShellVarContext all
|
||||
;MessageBox MB_OK 'User "$0" is in the Power Users group'
|
||||
StrCpy $SV_ALLUSERS "AllUsers"
|
||||
Goto done
|
||||
|
||||
noLM:
|
||||
StrCpy $SV_ALLUSERS "AllUsers"
|
||||
;Get installation folder from registry if available
|
||||
|
||||
done:
|
||||
StrCmp $SV_ALLUSERS "AllUsers" 0 +3
|
||||
StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
|
||||
StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||
|
||||
StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
|
||||
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
|
||||
|
||||
noOptionsPage:
|
||||
FunctionEnd
|
||||
@@ -0,0 +1,209 @@
|
||||
# Copyright 2020 Andreas Atteneder
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#
|
||||
# Retrieving the current version from GIT tags
|
||||
#
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
|
||||
function(git_update_index)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
update-index -q --refresh
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
)
|
||||
if(NOT res EQUAL 0)
|
||||
message(SEND_ERROR "git update-index not successful")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(git_describe_raw _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
describe
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
#ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "exitcode-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_rev_list target_path _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
rev-list -1 HEAD ${target_path}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT res EQUAL 0)
|
||||
message(SEND_ERROR "git update-index not successful")
|
||||
endif()
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_dirty _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
execute_process(COMMAND
|
||||
diff-index --name-only HEAD --
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
)
|
||||
set(${_var} "${res}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(generate_version _var )
|
||||
if(${ARGC} GREATER 1)
|
||||
set(target_path ${ARGN})
|
||||
git_rev_list(${target_path} KTX_REV)
|
||||
git_describe_raw(KTX_VERSION --contains --match v[0-9]* ${KTX_REV})
|
||||
if(NOT KTX_VERSION)
|
||||
git_describe_raw(KTX_VERSION "--match" "v[0-9]*" ${KTX_REV})
|
||||
endif()
|
||||
else()
|
||||
git_describe_raw(KTX_VERSION "--match" "v[0-9]*" "HEAD" )
|
||||
endif()
|
||||
|
||||
git_update_index()
|
||||
git_dirty(GIT_DIRTY)
|
||||
if(GIT_DIRTY)
|
||||
set(KTX_VERSION ${KTX_VERSION}-dirty)
|
||||
endif()
|
||||
set(${_var} "${KTX_VERSION}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Get latest tag from git if not passed to cmake
|
||||
# This property can be passed to cmake when building from tar.gz
|
||||
if(NOT KTX_GIT_VERSION_FULL)
|
||||
git_describe_raw(KTX_GIT_VERSION_FULL --abbrev=0 --match v[0-9]*)
|
||||
endif()
|
||||
#message("KTX git full version: ${KTX_GIT_VERSION_FULL}")
|
||||
|
||||
# generate_version(TOKTX_VERSION tools/toktx)
|
||||
# message("TOKTX_VERSION: ${TOKTX_VERSION}")
|
||||
|
||||
# First try a full regex ( vMAJOR.MINOR.PATCH-TWEAK )
|
||||
string(REGEX MATCH "^v([0-9]*)\.([0-9]*)\.([0-9]*)(-[^\.]*)"
|
||||
KTX_VERSION ${KTX_GIT_VERSION_FULL})
|
||||
|
||||
if(KTX_VERSION)
|
||||
set(KTX_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(KTX_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(KTX_VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
set(KTX_VERSION_TWEAK ${CMAKE_MATCH_4})
|
||||
else()
|
||||
# If full regex failed, go for vMAJOR.MINOR.PATCH
|
||||
string(REGEX MATCH "^v([0-9]*)\.([0-9]*)\.([^\.]*)"
|
||||
KTX_VERSION ${KTX_GIT_VERSION_FULL})
|
||||
|
||||
if(KTX_VERSION)
|
||||
set(KTX_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(KTX_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(KTX_VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
|
||||
string(REGEX MATCH "^[0-9]*$"
|
||||
KTX_VERSION_PATCH_INT ${KTX_VERSION_PATCH})
|
||||
|
||||
if(KTX_VERSION_PATCH_INT)
|
||||
set(KTX_VERSION_TWEAK "")
|
||||
else()
|
||||
if(KTX_VERSION_PATCH)
|
||||
set(KTX_VERSION_TWEAK "-${KTX_VERSION_PATCH}")
|
||||
else()
|
||||
set(KTX_VERSION_TWEAK "")
|
||||
endif()
|
||||
set(KTX_VERSION_PATCH "0")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Error retrieving version from GIT tag. Falling back to 0.0.0-noversion ")
|
||||
set(KTX_VERSION_MAJOR "0" )
|
||||
set(KTX_VERSION_MINOR "0" )
|
||||
set(KTX_VERSION_PATCH "0" )
|
||||
set(KTX_VERSION_TWEAK "-noversion" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(KTX_VERSION ${KTX_VERSION_MAJOR}.${KTX_VERSION_MINOR}.${KTX_VERSION_PATCH})
|
||||
set(KTX_VERSION_FULL ${KTX_VERSION}${KTX_VERSION_TWEAK})
|
||||
|
||||
#message("KTX version: ${KTX_VERSION} major:${KTX_VERSION_MAJOR} minor:${KTX_VERSION_MINOR} patch:${KTX_VERSION_PATCH} tweak:${KTX_VERSION_TWEAK}")
|
||||
|
||||
|
||||
#
|
||||
# Create a version.h header file using the mkversion shell script.
|
||||
# Dignum memoria (worth remembering): you need to run CMake config
|
||||
# after adding a new tag or making a software change in order for the
|
||||
# version to be updated.
|
||||
#
|
||||
|
||||
function( create_version_header dest_path target )
|
||||
|
||||
set( version_h_output ${PROJECT_SOURCE_DIR}/${dest_path}/version.h)
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
add_custom_command(
|
||||
OUTPUT ${version_h_output}
|
||||
# On Windows this command has to be invoked by a shell in order to work
|
||||
COMMAND ${BASH_EXECUTABLE} -c "\"scripts/mkversion\" \"-v\" \"${KTX_GIT_VERSION_FULL}\" \"-o\" \"version.h\" \"${dest_path}\""
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generate ${version_h_output}"
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
OUTPUT ${version_h_output}
|
||||
COMMAND scripts/mkversion -v ${KTX_GIT_VERSION_FULL} -o version.h ${dest_path}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generate ${version_h_output}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
set( version_target ${target}_version )
|
||||
add_custom_target( ${version_target} DEPENDS ${version_h_output} )
|
||||
add_dependencies( ${target} ${version_target} )
|
||||
target_sources( ${target} PRIVATE ${version_h_output} )
|
||||
|
||||
endfunction()
|
||||
|
||||
function( create_version_file )
|
||||
file(WRITE ${PROJECT_BINARY_DIR}/ktx.version "${KTX_VERSION_FULL}")
|
||||
endfunction()
|
||||
|
||||
# vim:ai:ts=4:sts=4:sw=2:expandtab:textwidth=70
|
||||
Reference in New Issue
Block a user