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
# This file provides various functions used by the PowerVR SDK build files
set(FUNCTIONS_INTERNAL_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "")
function(add_subdirectory_if_not_already_included TARGET SUBDIR_FOLDER SUBDIR_BIN_FOLDER)
if (NOT TARGET ${TARGET})
......@@ -101,14 +102,38 @@ function(add_rule_generate_spirv_from_shaders INPUT_SHADER_NAMES)
foreach(SHADER ${INPUT_SHADER_NAMES})
get_filename_component(SHADER_NAME ${SHADER} NAME)
get_glslang_validator_type(SHADER_TYPE SHADER_NAME)
set (GLSLANG_VALIDATOR_COMPILE_CURRENT_COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME} -o ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv -S ${SHADER_TYPE})
add_custom_command(
DEPENDS glslangValidator
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv
PRE_BUILD
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}
COMMAND echo glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME} -o ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv -S ${SHADER_TYPE}
COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME} -o ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv -S ${SHADER_TYPE}
COMMENT "${CMAKE_PROJECT_NAME}: Compiling ${SHADER_NAME} to ${SHADER_NAME}.spv"
COMMAND echo ${GLSLANG_VALIDATOR_COMPILE_CURRENT_COMMAND}
COMMAND ${GLSLANG_VALIDATOR_COMPILE_CURRENT_COMMAND}
COMMENT "${PROJECT_NAME}: Compiling ${SHADER_NAME} to ${SHADER_NAME}.spv"
)
endforeach()
endfunction(add_rule_generate_spirv_from_shaders)
function(download_external_project external_project_name external_project_cmake_files_dir external_project_src_dir external_project_download_dir external_project_url external_project_byproducts)
# See here for details: https://crascit.com/2015/07/25/cmake-gtest/
configure_file(${FUNCTIONS_INTERNAL_DIR}/external_project_download.cmake ${external_project_cmake_files_dir}/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -D "CMAKE_MAKE_PROGRAM:FILE=${CMAKE_MAKE_PROGRAM}" .
WORKING_DIRECTORY "${external_project_cmake_files_dir}"
RESULT_VARIABLE download_configure_result
OUTPUT_VARIABLE download_configure_output
ERROR_VARIABLE download_configure_output)
if(download_configure_result)
message(FATAL_ERROR "${external_project_name} download configure step failed (${download_configure_result}): ${download_configure_output}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY "${external_project_cmake_files_dir}"
RESULT_VARIABLE download_build_result
OUTPUT_VARIABLE download_build_output
ERROR_VARIABLE download_build_output)
if(download_build_result)
message(FATAL_ERROR "${external_project_name} download build step failed (${download_build_result}): ${download_build_output}")
endif()
endfunction(download_external_project)
\ No newline at end of file
......@@ -2,17 +2,18 @@ cmake_minimum_required(VERSION 3.3)
include(ExternalProject)
project(external_VulkanMemoryAllocator-download NONE)
project(${external_project_name}-download NONE)
# Setup the ExternalProject_Add call for VulkanMemoryAllocator
ExternalProject_Add(external_VulkanMemoryAllocator
PREFIX ${VulkanMemoryAllocator_PREFIX}
SOURCE_DIR ${VulkanMemoryAllocator_SRC_DIR}
# Setup the ExternalProject_Add call
ExternalProject_Add(external_${external_project_name}
PREFIX ${external_project_cmake_files_dir}
SOURCE_DIR ${external_project_src_dir}
UPDATE_COMMAND ""
URL ${VulkanMemoryAllocator_URL}
DOWNLOAD_DIR ${VulkanMemoryAllocator_DOWNLOAD_DIR}
URL ${external_project_url}
DOWNLOAD_DIR ${external_project_download_dir}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
BUILD_BYPRODUCTS ${external_project_byproducts}
)
\ No newline at end of file
......@@ -16,21 +16,18 @@ set(VulkanMemoryAllocator_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/VulkanMemo
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
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
if(EXISTS ${VulkanMemoryAllocator_DOWNLOAD_DIR}/${external_VulkanMemoryAllocator_VERSION}.tar.gz AND EXISTS ${VulkanMemoryAllocator_SRC_DIR}/src/vk_mem_alloc.h)
# 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)
set(VulkanMemoryAllocator_URL "" CACHE INTERNAL "")
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")
# Remove the existing VulkanMemoryAllocator downloads so that only the newest version of VulkanMemoryAllocator will be present
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/
configure_file(external.cmake ${VulkanMemoryAllocator_PREFIX}/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" . WORKING_DIRECTORY "${VulkanMemoryAllocator_PREFIX}")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${VulkanMemoryAllocator_PREFIX}")
download_external_project("VulkanMemoryAllocator" "${VulkanMemoryAllocator_PREFIX}" "${VulkanMemoryAllocator_SRC_DIR}" "${VulkanMemoryAllocator_DOWNLOAD_DIR}" "${VulkanMemoryAllocator_URL}" "")
endif()
add_library(VulkanMemoryAllocator INTERFACE IMPORTED GLOBAL)
......
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
......@@ -2,30 +2,17 @@ cmake_minimum_required(VERSION 3.3)
include(ExternalProject)
project(external_glslangValidator-download NONE)
# Setup the ExternalProject_Add call for glslangValidator
ExternalProject_Add(external_glslangValidator
PREFIX ${glslangValidator_PREFIX}
SOURCE_DIR ${glslang_SRC_DIR}
SOURCE_DIR ${EXTERNAL_RELEASE_BIN_FOLDER}
UPDATE_COMMAND ""
URL ""
DOWNLOAD_DIR ""
URL ${glslangValidator_URL}
DOWNLOAD_DIR ${glslang_DOWNLOAD_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
BUILD_BYPRODUCTS
${glslangValidator_RELEASE_EXECUTABLE}
CONFIGURE_COMMAND
"${CMAKE_COMMAND}"
"-H${glslang_SRC_DIR}"
"-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
......@@ -16,33 +16,35 @@ set(pugixml_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/pugixml_downloads CACHE
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
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"
IMPORTED_LOCATION ${pugixml_LIB})
else()
# 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)
# 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)
set(pugixml_URL "" CACHE INTERNAL "")
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 "")
# Remove the existing pugixml downloads so that only the newest version of pugixml will be present
file(REMOVE_RECURSE ${pugixml_DOWNLOAD_DIR})
endif()
message("pugixml was not found so will be downloaded: ${pugixml_URL}")
endif()
download_external_project("pugixml" "${pugixml_PREFIX}" "${pugixml_SRC_DIR}" "${pugixml_DOWNLOAD_DIR}" "${pugixml_URL}" "")
# pugixml
# See here for details: https://crascit.com/2015/07/25/cmake-gtest/
configure_file(external.cmake ${pugixml_PREFIX}/configure/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" . WORKING_DIRECTORY "${pugixml_PREFIX}/configure")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${pugixml_PREFIX}/configure")
if(EXISTS ${pugixml_SRC_DIR}/tests/)
# 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/)
endif()
add_subdirectory_if_not_already_included(pugixml "${pugixml_SRC_DIR}" "${pugixml_PREFIX}/build")
add_subdirectory_if_not_already_included(pugixml "${pugixml_SRC_DIR}" "${pugixml_PREFIX}/build")
set_target_properties(pugixml PROPERTIES
set_target_properties(pugixml PROPERTIES
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