Changed cross-compiled build behavior.

Removed the host compilation of glslangValidator when cross compiling as this had the potential to fail quite easily. This also required a dependency of host toolsets for cross compiled builds which wasn't desirable. For cross-compiled builds we now download the matching glslang binary release package (https://github.com/KhronosGroup/glslang/releases/download/) for the host platform and extract it into the correct place (SDK/bin). Only do this if a glslangValidator binary isn't already in the host bin directory meaning the step will only happen if a cross compiled build is the first build of the SDK on a particular host platform. Removed duplicated code for downloading external projects using a common function defined in cmake/Functions.cmake.
parent 095e0bf3
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.3)
include(ExternalProject) include(ExternalProject)
project(external_VulkanMemoryAllocator-download NONE) project(${external_project_name}-download NONE)
# Setup the ExternalProject_Add call for VulkanMemoryAllocator # Setup the ExternalProject_Add call
ExternalProject_Add(external_VulkanMemoryAllocator ExternalProject_Add(external_${external_project_name}
PREFIX ${VulkanMemoryAllocator_PREFIX} PREFIX ${external_project_cmake_files_dir}
SOURCE_DIR ${VulkanMemoryAllocator_SRC_DIR} SOURCE_DIR ${external_project_src_dir}
UPDATE_COMMAND "" UPDATE_COMMAND ""
URL ${VulkanMemoryAllocator_URL} URL ${external_project_url}
DOWNLOAD_DIR ${VulkanMemoryAllocator_DOWNLOAD_DIR} DOWNLOAD_DIR ${external_project_download_dir}
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND ""
BUILD_BYPRODUCTS ${external_project_byproducts}
) )
\ No newline at end of file
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.3)
include(../../cmake/Common.cmake) include(../../cmake/Common.cmake)
# Set current VulkanMemoryAllocator version # Set current VulkanMemoryAllocator version
set(external_VulkanMemoryAllocator_VERSION "v2.2.0" CACHE INTERNAL "") set(external_VulkanMemoryAllocator_VERSION "v2.2.0" CACHE INTERNAL "")
# Set VulkanMemoryAllocator prefix location # Set VulkanMemoryAllocator prefix location
set(VulkanMemoryAllocator_PREFIX ${EXTERNAL_CMAKE_FILES_FOLDER}/external_VulkanMemoryAllocator CACHE INTERNAL "") set(VulkanMemoryAllocator_PREFIX ${EXTERNAL_CMAKE_FILES_FOLDER}/external_VulkanMemoryAllocator CACHE INTERNAL "")
# Set the VulkanMemoryAllocator source directory # Set the VulkanMemoryAllocator source directory
set(VulkanMemoryAllocator_SRC_DIR ${SDK_ROOT}/external/VulkanMemoryAllocator/src CACHE INTERNAL "") set(VulkanMemoryAllocator_SRC_DIR ${SDK_ROOT}/external/VulkanMemoryAllocator/src CACHE INTERNAL "")
# Set VulkanMemoryAllocator download directory - we use a downloads directory to allow us to maintain cleanliness # Set VulkanMemoryAllocator download directory - we use a downloads directory to allow us to maintain cleanliness
set(VulkanMemoryAllocator_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/VulkanMemoryAllocator_downloads CACHE INTERNAL "") set(VulkanMemoryAllocator_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/VulkanMemoryAllocator_downloads CACHE INTERNAL "")
get_directory_property(HAS_PARENT PARENT_DIRECTORY) get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if(NOT HAS_PARENT OR NOT USE_PREBUILT_DEPENDENCIES) if(NOT HAS_PARENT OR NOT USE_PREBUILT_DEPENDENCIES)
# Don't download if it is already present - this handles cases where internet connectivity may be limited but all packages are already available # Don't download if it is already present - this handles cases where internet connectivity may be limited but all packages are already available
if(EXISTS ${VulkanMemoryAllocator_DOWNLOAD_DIR}/${external_VulkanMemoryAllocator_VERSION}.tar.gz AND EXISTS ${VulkanMemoryAllocator_SRC_DIR}/src/vk_mem_alloc.h) if(EXISTS ${VulkanMemoryAllocator_DOWNLOAD_DIR}/${external_VulkanMemoryAllocator_VERSION}.tar.gz AND EXISTS ${VulkanMemoryAllocator_SRC_DIR}/src/vk_mem_alloc.h)
set(VulkanMemoryAllocator_URL "" CACHE INTERNAL "") set(VulkanMemoryAllocator_URL "" CACHE INTERNAL "")
message("VulkanMemoryAllocator was found so will not be downloaded: ${VulkanMemoryAllocator_SRC_DIR}") message("VulkanMemoryAllocator was found so will not be downloaded: ${VulkanMemoryAllocator_SRC_DIR}")
else() else()
set(VulkanMemoryAllocator_URL "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/archive/${external_VulkanMemoryAllocator_VERSION}.tar.gz") set(VulkanMemoryAllocator_URL "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/archive/${external_VulkanMemoryAllocator_VERSION}.tar.gz")
# Remove the existing VulkanMemoryAllocator downloads so that only the newest version of VulkanMemoryAllocator will be present # Remove the existing VulkanMemoryAllocator downloads so that only the newest version of VulkanMemoryAllocator will be present
file(REMOVE_RECURSE ${VulkanMemoryAllocator_DOWNLOAD_DIR}) file(REMOVE_RECURSE ${VulkanMemoryAllocator_DOWNLOAD_DIR})
endif() message("VulkanMemoryAllocator was not found so will be downloaded: ${VulkanMemoryAllocator_URL}")
endif()
# VulkanMemoryAllocator
# See here for details: https://crascit.com/2015/07/25/cmake-gtest/ download_external_project("VulkanMemoryAllocator" "${VulkanMemoryAllocator_PREFIX}" "${VulkanMemoryAllocator_SRC_DIR}" "${VulkanMemoryAllocator_DOWNLOAD_DIR}" "${VulkanMemoryAllocator_URL}" "")
configure_file(external.cmake ${VulkanMemoryAllocator_PREFIX}/CMakeLists.txt) endif()
execute_process(COMMAND "${CMAKE_COMMAND}" . WORKING_DIRECTORY "${VulkanMemoryAllocator_PREFIX}")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${VulkanMemoryAllocator_PREFIX}") add_library(VulkanMemoryAllocator INTERFACE IMPORTED GLOBAL)
endif()
set_target_properties(VulkanMemoryAllocator PROPERTIES
add_library(VulkanMemoryAllocator INTERFACE IMPORTED GLOBAL) INTERFACE_INCLUDE_DIRECTORIES ${VulkanMemoryAllocator_SRC_DIR}/src)
set_target_properties(VulkanMemoryAllocator PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${VulkanMemoryAllocator_SRC_DIR}/src)
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {
compileSdkVersion 28 compileSdkVersion 28
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 26 targetSdkVersion 26
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
externalNativeBuild { externalNativeBuild {
cmake { cmake {
cppFlags "-fexceptions" cppFlags "-fexceptions"
arguments "-DANDROID_STL=c++_static" arguments "-DANDROID_STL=c++_static"
targets "glslang", "SPIRV", "OGLCompiler", "OSDependent" targets "glslang", "SPIRV", "OGLCompiler", "OSDependent"
} }
} }
ndk ndk
{ {
abiFilters "$ANDROID_ABI".replace(" ", "").split(",") abiFilters "$ANDROID_ABI".replace(" ", "").split(",")
} }
} }
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path "../CMakeLists.txt" path "../CMakeLists.txt"
} }
} }
} }
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.3.0' classpath 'com.android.tools.build:gradle:3.3.0'
} }
} }
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
} }
} }
\ No newline at end of file
cmake_minimum_required(VERSION 3.3)
include(ExternalProject)
project(external_glslang-download NONE)
# Setup the ExternalProject_Add call for glslang
ExternalProject_Add(external_glslang
PREFIX ${glslang_PREFIX}
SOURCE_DIR ${glslang_SRC_DIR}
UPDATE_COMMAND ""
URL ${glslang_URL}
DOWNLOAD_DIR ${glslang_DOWNLOAD_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
\ No newline at end of file
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.3)
include(ExternalProject) include(ExternalProject)
# Setup the ExternalProject_Add call for glslangValidator project(external_glslangValidator-download NONE)
ExternalProject_Add(external_glslangValidator
PREFIX ${glslangValidator_PREFIX} # Setup the ExternalProject_Add call for glslangValidator
SOURCE_DIR ${glslang_SRC_DIR} ExternalProject_Add(external_glslangValidator
UPDATE_COMMAND "" PREFIX ${glslangValidator_PREFIX}
URL "" SOURCE_DIR ${EXTERNAL_RELEASE_BIN_FOLDER}
DOWNLOAD_DIR "" UPDATE_COMMAND ""
TEST_COMMAND "" URL ${glslangValidator_URL}
BUILD_BYPRODUCTS DOWNLOAD_DIR ${glslang_DOWNLOAD_DIR}
${glslangValidator_RELEASE_EXECUTABLE} CONFIGURE_COMMAND ""
CONFIGURE_COMMAND BUILD_COMMAND ""
"${CMAKE_COMMAND}" INSTALL_COMMAND ""
"-H${glslang_SRC_DIR}" TEST_COMMAND ""
"-B${glslangValidator_PREFIX}"
"-DCMAKE_INSTALL_PREFIX=${EXTERNAL_RELEASE_BIN_FOLDER}"
"-DCMAKE_BUILD_TYPE=Release"
"-DBUILD_TESTING=OFF"
"-DENABLE_HLSL=OFF"
"-DENABLE_OPT=OFF"
"-DENABLE_AMD_EXTENSIONS=OFF"
"-DENABLE_NV_EXTENSIONS=OFF"
"-DENABLE_GLSLANG_BINARIES=ON"
BUILD_COMMAND
"${CMAKE_COMMAND}" --build ${glslangValidator_PREFIX} --config Release
INSTALL_COMMAND
"${CMAKE_COMMAND}" --build ${glslangValidator_PREFIX} --target install --config Release
) )
\ No newline at end of file
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.3)
include(../../cmake/Common.cmake) include(../../cmake/Common.cmake)
# Set current pugixml version # Set current pugixml version
set(external_pugixml_VERSION "v1.9" CACHE INTERNAL "") set(external_pugixml_VERSION "v1.9" CACHE INTERNAL "")
# Set pugixml prefix location # Set pugixml prefix location
set(pugixml_PREFIX ${EXTERNAL_CMAKE_FILES_FOLDER}/external_pugixml CACHE INTERNAL "") set(pugixml_PREFIX ${EXTERNAL_CMAKE_FILES_FOLDER}/external_pugixml CACHE INTERNAL "")
# Set the pugixml source directory # Set the pugixml source directory
set(pugixml_SRC_DIR ${SDK_ROOT}/external/pugixml/src CACHE INTERNAL "") set(pugixml_SRC_DIR ${SDK_ROOT}/external/pugixml/src CACHE INTERNAL "")
# Set pugixml download directory - we use a downloads directory to allow us to maintain cleanliness # Set pugixml download directory - we use a downloads directory to allow us to maintain cleanliness
set(pugixml_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/pugixml_downloads CACHE INTERNAL "") set(pugixml_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/pugixml_downloads CACHE INTERNAL "")
get_directory_property(HAS_PARENT PARENT_DIRECTORY) get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if(HAS_PARENT AND USE_PREBUILT_DEPENDENCIES) if(HAS_PARENT AND USE_PREBUILT_DEPENDENCIES)
add_library(pugixml STATIC IMPORTED GLOBAL) add_library(pugixml STATIC IMPORTED GLOBAL)
set(pugixml_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX}) set(pugixml_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX})
set_target_properties(pugixml PROPERTIES set_target_properties(pugixml PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${pugixml_SRC_DIR}/src" INTERFACE_INCLUDE_DIRECTORIES "${pugixml_SRC_DIR}/src"
IMPORTED_LOCATION ${pugixml_LIB}) IMPORTED_LOCATION ${pugixml_LIB})
else() else()
# Don't download if it is already present - this handles cases where internet connectivity may be limited but all packages are already available # Don't download if it is already present - this handles cases where internet connectivity may be limited but all packages are already available
if(EXISTS ${pugixml_DOWNLOAD_DIR}/${external_pugixml_VERSION}.tar.gz AND EXISTS ${pugixml_SRC_DIR}/CMakeLists.txt) if(EXISTS ${pugixml_DOWNLOAD_DIR}/${external_pugixml_VERSION}.tar.gz AND EXISTS ${pugixml_SRC_DIR}/CMakeLists.txt)
set(pugixml_URL "" CACHE INTERNAL "") set(pugixml_URL "" CACHE INTERNAL "")
message("pugixml was found so will not be downloaded: ${pugixml_SRC_DIR}") message("pugixml was found so will not be downloaded: ${pugixml_SRC_DIR}")
else() else()
set(pugixml_URL "https://github.com/zeux/pugixml/archive/${external_pugixml_VERSION}.tar.gz" CACHE INTERNAL "") set(pugixml_URL "https://github.com/zeux/pugixml/archive/${external_pugixml_VERSION}.tar.gz" CACHE INTERNAL "")
# Remove the existing pugixml downloads so that only the newest version of pugixml will be present # Remove the existing pugixml downloads so that only the newest version of pugixml will be present
file(REMOVE_RECURSE ${pugixml_DOWNLOAD_DIR}) file(REMOVE_RECURSE ${pugixml_DOWNLOAD_DIR})
endif() message("pugixml was not found so will be downloaded: ${pugixml_URL}")
endif()
# pugixml
# See here for details: https://crascit.com/2015/07/25/cmake-gtest/ download_external_project("pugixml" "${pugixml_PREFIX}" "${pugixml_SRC_DIR}" "${pugixml_DOWNLOAD_DIR}" "${pugixml_URL}" "")
configure_file(external.cmake ${pugixml_PREFIX}/configure/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" . WORKING_DIRECTORY "${pugixml_PREFIX}/configure") if(EXISTS ${pugixml_SRC_DIR}/tests/)
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${pugixml_PREFIX}/configure") # Remove the tests/ folder from pugixml. The use of filenames with unicode characters cause issues in various places. As we are not currently using pugixml tests we'll remove the tests/ directory.
file(REMOVE_RECURSE ${pugixml_SRC_DIR}/tests/)
add_subdirectory_if_not_already_included(pugixml "${pugixml_SRC_DIR}" "${pugixml_PREFIX}/build") endif()
set_target_properties(pugixml PROPERTIES add_subdirectory_if_not_already_included(pugixml "${pugixml_SRC_DIR}" "${pugixml_PREFIX}/build")
ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}) set_target_properties(pugixml PROPERTIES
endif() ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER})
endif()
cmake_minimum_required(VERSION 3.3)
include(ExternalProject)
project(external_pugixml-download NONE)
# Setup the ExternalProject_Add call for pugixml
ExternalProject_Add(external_pugixml
PREFIX ${pugixml_PREFIX}
SOURCE_DIR ${pugixml_SRC_DIR}
UPDATE_COMMAND ""
URL ${pugixml_URL}
DOWNLOAD_DIR ${pugixml_DOWNLOAD_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment