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 # 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}) function(add_subdirectory_if_not_already_included TARGET SUBDIR_FOLDER SUBDIR_BIN_FOLDER)
add_subdirectory(${SUBDIR_FOLDER} ${SUBDIR_BIN_FOLDER} EXCLUDE_FROM_ALL) if (NOT TARGET ${TARGET})
endif() add_subdirectory(${SUBDIR_FOLDER} ${SUBDIR_BIN_FOLDER} EXCLUDE_FROM_ALL)
endfunction(add_subdirectory_if_not_already_included) endif()
endfunction(add_subdirectory_if_not_already_included)
function(add_platform_specific_resource_files INPUT_SRC_FILES INPUT_RESOURCE_FILES)
if (WIN32) function(add_platform_specific_resource_files INPUT_SRC_FILES INPUT_RESOURCE_FILES)
set(RESOURCE_LIST "") if (WIN32)
foreach(RESOURCE ${${INPUT_RESOURCE_FILES}}) set(RESOURCE_LIST "")
get_filename_component(RESOURCE_NAME ${RESOURCE} NAME) foreach(RESOURCE ${${INPUT_RESOURCE_FILES}})
file(RELATIVE_PATH RESOURCE ${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources ${RESOURCE}) get_filename_component(RESOURCE_NAME ${RESOURCE} NAME)
file(TO_NATIVE_PATH "${RESOURCE}" RESOURCE) file(RELATIVE_PATH RESOURCE ${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources ${RESOURCE})
string(REPLACE "\\" "\\\\" RESOURCE "${RESOURCE}") file(TO_NATIVE_PATH "${RESOURCE}" RESOURCE)
set(RESOURCE_LIST ${RESOURCE_LIST} "${RESOURCE_NAME} RCDATA \"${RESOURCE}\"\n") string(REPLACE "\\" "\\\\" RESOURCE "${RESOURCE}")
endforeach() set(RESOURCE_LIST ${RESOURCE_LIST} "${RESOURCE_NAME} RCDATA \"${RESOURCE}\"\n")
string(REPLACE ";" "" RESOURCE_LIST "${RESOURCE_LIST}") endforeach()
configure_file(${SDK_ROOT}/res/Windows/Resources.rc.in ${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/Resources.rc) string(REPLACE ";" "" RESOURCE_LIST "${RESOURCE_LIST}")
#Add the resource files needed for windows (icons, asset files etc). configure_file(${SDK_ROOT}/res/Windows/Resources.rc.in ${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/Resources.rc)
list(APPEND ${INPUT_SRC_FILES} #Add the resource files needed for windows (icons, asset files etc).
"${SDK_ROOT}/res/Windows/shared.rc" list(APPEND ${INPUT_SRC_FILES}
"${SDK_ROOT}/res/Windows/resource.h" "${SDK_ROOT}/res/Windows/shared.rc"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/Resources.rc") "${SDK_ROOT}/res/Windows/resource.h"
elseif(APPLE) "${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/Resources.rc")
if (IOS) elseif(APPLE)
set(INFO_PLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/iOS_Info.plist" PARENT_SCOPE) if (IOS)
file(GLOB ICONS LIST_DIRECTORIES false ${SDK_ROOT}/res/iOS/* ${SDK_ROOT}/res/iOS/OpenGLES/*) set(INFO_PLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/iOS_Info.plist" PARENT_SCOPE)
list(APPEND ${INPUT_RESOURCE_FILES} ${ICONS}) file(GLOB ICONS LIST_DIRECTORIES false ${SDK_ROOT}/res/iOS/* ${SDK_ROOT}/res/iOS/OpenGLES/*)
else() list(APPEND ${INPUT_RESOURCE_FILES} ${ICONS})
set(INFO_PLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/macOS_Info.plist" PARENT_SCOPE) else()
list(APPEND ${INPUT_RESOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/MainMenu.xib") set(INFO_PLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/macOS_Info.plist" PARENT_SCOPE)
endif() list(APPEND ${INPUT_RESOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/cmake-resources/MainMenu.xib")
source_group(Resources FILES ${${INPUT_RESOURCE_FILES}}) endif()
set_source_files_properties(${${INPUT_RESOURCE_FILES}} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) source_group(Resources FILES ${${INPUT_RESOURCE_FILES}})
endif() set_source_files_properties(${${INPUT_RESOURCE_FILES}} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
SET(${INPUT_SRC_FILES} ${${INPUT_SRC_FILES}} PARENT_SCOPE) endif()
SET(${INPUT_RESOURCE_FILES} ${${INPUT_RESOURCE_FILES}} PARENT_SCOPE) SET(${INPUT_SRC_FILES} ${${INPUT_SRC_FILES}} PARENT_SCOPE)
endfunction() SET(${INPUT_RESOURCE_FILES} ${${INPUT_RESOURCE_FILES}} PARENT_SCOPE)
endfunction()
function(add_platform_specific_executable EXECUTABLE_NAME INPUT_SRC_FILES INPUT_RESOURCE_FILES)
if (WIN32) function(add_platform_specific_executable EXECUTABLE_NAME INPUT_SRC_FILES INPUT_RESOURCE_FILES)
add_executable(${EXECUTABLE_NAME} WIN32 ${INPUT_SRC_FILES}) if (WIN32)
elseif (ANDROID) add_executable(${EXECUTABLE_NAME} WIN32 ${INPUT_SRC_FILES})
add_library(${EXECUTABLE_NAME} SHARED ${INPUT_SRC_FILES}) elseif (ANDROID)
# Force export ANativeActivity_onCreate(), add_library(${EXECUTABLE_NAME} SHARED ${INPUT_SRC_FILES})
# Refer to: https://github.com/android-ndk/ndk/issues/381 # Force export ANativeActivity_onCreate(),
set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS " -u ANativeActivity_onCreate") # Refer to: https://github.com/android-ndk/ndk/issues/381
elseif (APPLE) set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS " -u ANativeActivity_onCreate")
if (IOS) elseif (APPLE)
add_executable(${EXECUTABLE_NAME} MACOSX_BUNDLE ${INPUT_SRC_FILES} ${INPUT_RESOURCE_FILES}) if (IOS)
else () add_executable(${EXECUTABLE_NAME} MACOSX_BUNDLE ${INPUT_SRC_FILES} ${INPUT_RESOURCE_FILES})
list(APPEND FRAMEWORK_FILES "${EXTERNAL_LIB_FOLDER}/libEGL.dylib" "${EXTERNAL_LIB_FOLDER}/libGLESv2.dylib") else ()
set_source_files_properties(${FRAMEWORK_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) list(APPEND FRAMEWORK_FILES "${EXTERNAL_LIB_FOLDER}/libEGL.dylib" "${EXTERNAL_LIB_FOLDER}/libGLESv2.dylib")
source_group(Frameworks FILES ${FRAMEWORK_FILES}) set_source_files_properties(${FRAMEWORK_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
add_executable(${EXECUTABLE_NAME} MACOSX_BUNDLE ${INPUT_SRC_FILES} ${INPUT_RESOURCE_FILES} ${FRAMEWORK_FILES}) source_group(Frameworks FILES ${FRAMEWORK_FILES})
endif () add_executable(${EXECUTABLE_NAME} MACOSX_BUNDLE ${INPUT_SRC_FILES} ${INPUT_RESOURCE_FILES} ${FRAMEWORK_FILES})
set_target_properties(${EXECUTABLE_NAME} PROPERTIES RESOURCE "${INPUT_RESOURCE_FILES}") endif ()
set_target_properties(${EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${INFO_PLIST_FILE}") set_target_properties(${EXECUTABLE_NAME} PROPERTIES RESOURCE "${INPUT_RESOURCE_FILES}")
elseif (UNIX OR QNX) set_target_properties(${EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${INFO_PLIST_FILE}")
add_executable(${EXECUTABLE_NAME} ${INPUT_SRC_FILES}) elseif (UNIX OR QNX)
endif() add_executable(${EXECUTABLE_NAME} ${INPUT_SRC_FILES})
endfunction() endif()
endfunction()
# CAUTION - For this rule to work, the asset files must actually be added as sources to the executable
function(add_rule_copy_assets_to_asset_folder INPUT_RESOURCE_FILES INPUT_OUTPUT_FOLDER) # CAUTION - For this rule to work, the asset files must actually be added as sources to the executable
if (UNIX OR QNX) function(add_rule_copy_assets_to_asset_folder INPUT_RESOURCE_FILES INPUT_OUTPUT_FOLDER)
#Copy all assets to the Assets folder in order for the executable to be able to locate it if (UNIX OR QNX)
foreach(ASSET_FILE_PATH ${INPUT_RESOURCE_FILES}) #Copy all assets to the Assets folder in order for the executable to be able to locate it
get_filename_component(ASSET_FILE_NAME ${ASSET_FILE_PATH} NAME) foreach(ASSET_FILE_PATH ${INPUT_RESOURCE_FILES})
add_custom_command( get_filename_component(ASSET_FILE_NAME ${ASSET_FILE_PATH} NAME)
OUTPUT ${INPUT_OUTPUT_FOLDER}/${ASSET_FILE_NAME} add_custom_command(
PRE_BUILD OUTPUT ${INPUT_OUTPUT_FOLDER}/${ASSET_FILE_NAME}
MAIN_DEPENDENCY ${ASSET_FILE_PATH} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${ASSET_FILE_PATH} ${INPUT_OUTPUT_FOLDER}/${ASSET_FILE_NAME} MAIN_DEPENDENCY ${ASSET_FILE_PATH}
COMMENT "${CMAKE_PROJECT_NAME}: Copying ${ASSET_FILE_PATH} to ${INPUT_OUTPUT_FOLDER}/${ASSET_FILE_NAME}" COMMAND ${CMAKE_COMMAND} -E copy ${ASSET_FILE_PATH} ${INPUT_OUTPUT_FOLDER}/${ASSET_FILE_NAME}
) COMMENT "${CMAKE_PROJECT_NAME}: Copying ${ASSET_FILE_PATH} to ${INPUT_OUTPUT_FOLDER}/${ASSET_FILE_NAME}"
endforeach() )
endif() #All other platforms package: Windows resources, MacOS package, Android Assets etc. endforeach()
endfunction() endif() #All other platforms package: Windows resources, MacOS package, Android Assets etc.
endfunction()
function(get_glslang_validator_type out_glslang_validator_type INPUT_SHADER_NAME)
if(${INPUT_SHADER_NAME} MATCHES ".fsh$") function(get_glslang_validator_type out_glslang_validator_type INPUT_SHADER_NAME)
set(${out_glslang_validator_type} frag PARENT_SCOPE) if(${INPUT_SHADER_NAME} MATCHES ".fsh$")
elseif(${INPUT_SHADER_NAME} MATCHES ".vsh$") set(${out_glslang_validator_type} frag PARENT_SCOPE)
set(${out_glslang_validator_type} vert PARENT_SCOPE) elseif(${INPUT_SHADER_NAME} MATCHES ".vsh$")
elseif(${INPUT_SHADER_NAME} MATCHES ".csh$") set(${out_glslang_validator_type} vert PARENT_SCOPE)
set(${out_glslang_validator_type} comp PARENT_SCOPE) elseif(${INPUT_SHADER_NAME} MATCHES ".csh$")
elseif(${INPUT_SHADER_NAME} MATCHES ".gsh$") set(${out_glslang_validator_type} comp PARENT_SCOPE)
set(${out_glslang_validator_type} geom PARENT_SCOPE) elseif(${INPUT_SHADER_NAME} MATCHES ".gsh$")
elseif(${INPUT_SHADER_NAME} MATCHES ".tcsh$") set(${out_glslang_validator_type} geom PARENT_SCOPE)
set(${out_glslang_validator_type} tesc PARENT_SCOPE) elseif(${INPUT_SHADER_NAME} MATCHES ".tcsh$")
elseif(${INPUT_SHADER_NAME} MATCHES ".tesh$") set(${out_glslang_validator_type} tesc PARENT_SCOPE)
set(${out_glslang_validator_type} tese PARENT_SCOPE) elseif(${INPUT_SHADER_NAME} MATCHES ".tesh$")
endif() set(${out_glslang_validator_type} tese PARENT_SCOPE)
endfunction(get_glslang_validator_type) endif()
endfunction(get_glslang_validator_type)
function(add_rule_generate_spirv_from_shaders INPUT_SHADER_NAMES)
#GENERATE A PRE-BUILD STEP FOR COMPILING GLSL TO SPIRV function(add_rule_generate_spirv_from_shaders INPUT_SHADER_NAMES)
foreach(SHADER ${INPUT_SHADER_NAMES}) #GENERATE A PRE-BUILD STEP FOR COMPILING GLSL TO SPIRV
get_filename_component(SHADER_NAME ${SHADER} NAME) foreach(SHADER ${INPUT_SHADER_NAMES})
get_glslang_validator_type(SHADER_TYPE SHADER_NAME) get_filename_component(SHADER_NAME ${SHADER} NAME)
add_custom_command( get_glslang_validator_type(SHADER_TYPE SHADER_NAME)
DEPENDS glslangValidator 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})
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv add_custom_command(
PRE_BUILD DEPENDS glslangValidator
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME} OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv
COMMAND echo glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME} -o ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv -S ${SHADER_TYPE} PRE_BUILD
COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME} -o ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}.spv -S ${SHADER_TYPE} MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_NAME}
COMMENT "${CMAKE_PROJECT_NAME}: Compiling ${SHADER_NAME} to ${SHADER_NAME}.spv" COMMAND echo ${GLSLANG_VALIDATOR_COMPILE_CURRENT_COMMAND}
) COMMAND ${GLSLANG_VALIDATOR_COMPILE_CURRENT_COMMAND}
endforeach() COMMENT "${PROJECT_NAME}: Compiling ${SHADER_NAME} to ${SHADER_NAME}.spv"
endfunction(add_rule_generate_spirv_from_shaders) )
\ No newline at end of file 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
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)
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.3)
include(../../cmake/Common.cmake) include(../../cmake/Common.cmake)
# Set current glslang version # Set current glslang version
set(external_glslang_VERSION "7.11.3113" CACHE INTERNAL "") set(external_glslang_VERSION "7.11.3113" CACHE INTERNAL "")
# Set glslang prefix location # Set glslang prefix location
set(glslang_PREFIX ${EXTERNAL_CMAKE_FILES_FOLDER}/external_glslang CACHE INTERNAL "") set(glslang_PREFIX ${EXTERNAL_CMAKE_FILES_FOLDER}/external_glslang CACHE INTERNAL "")
# Set the glslang source directory # Set the glslang source directory
set(glslang_SRC_DIR ${SDK_ROOT}/external/glslang/src CACHE INTERNAL "") set(glslang_SRC_DIR ${SDK_ROOT}/external/glslang/src CACHE INTERNAL "")
# Set glslang download directory - we use a downloads directory to allow us to maintain cleanliness # Set glslang download directory - we use a downloads directory to allow us to maintain cleanliness
set(glslang_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/glslang_downloads CACHE INTERNAL "") set(glslang_DOWNLOAD_DIR ${SDK_ROOT}/external/downloads/glslang_downloads CACHE INTERNAL "")
# Set glslangValidator prefix location # Set glslangValidator prefix location
set(glslangValidator_PREFIX ${EXTERNAL_RELEASE_BIN_FOLDER}/cmake/external_glslangValidator CACHE INTERNAL "") set(glslangValidator_PREFIX ${EXTERNAL_CMAKE_FILES_FOLDER}/external_glslangValidator CACHE INTERNAL "")
set(glslangValidator_RELEASE_EXECUTABLE ${EXTERNAL_RELEASE_BIN_FOLDER}/bin/glslangValidator${HOST_EXECUTABLE_SUFFIX} CACHE INTERNAL "") set(glslangValidator_RELEASE_EXECUTABLE ${EXTERNAL_RELEASE_BIN_FOLDER}/bin/glslangValidator${HOST_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
get_directory_property(HAS_PARENT PARENT_DIRECTORY) get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if((HAS_PARENT AND USE_PREBUILT_DEPENDENCIES) OR GLSLANG_INSTALL_DIR OR GLSLANG_VALIDATOR_INSTALL_DIR) # If a glslang and glslangValidator already exists
add_library(glslang STATIC IMPORTED GLOBAL) if((HAS_PARENT AND USE_PREBUILT_DEPENDENCIES) OR GLSLANG_INSTALL_DIR OR GLSLANG_VALIDATOR_INSTALL_DIR)
add_library(SPIRV STATIC IMPORTED GLOBAL) add_library(glslang STATIC IMPORTED GLOBAL)
add_library(OGLCompiler STATIC IMPORTED GLOBAL) add_library(SPIRV STATIC IMPORTED GLOBAL)
add_library(OSDependent STATIC IMPORTED GLOBAL) add_library(OGLCompiler STATIC IMPORTED GLOBAL)
add_library(OSDependent STATIC IMPORTED GLOBAL)
add_executable(glslangValidator IMPORTED GLOBAL)
add_executable(glslangValidator IMPORTED GLOBAL)
if(NOT GLSLANG_INSTALL_DIR)
set(glslang_INCLUDE_DIRECTORIES ${glslang_SRC_DIR}) if(NOT GLSLANG_INSTALL_DIR)
set(glslang_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}glslang${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(glslang_INCLUDE_DIRECTORIES ${glslang_SRC_DIR})
set(SPIRV_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}SPIRV${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(glslang_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}glslang${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(OGLCompiler_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}OGLCompiler${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(SPIRV_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}SPIRV${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(OSDependent_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}OSDependent${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(OGLCompiler_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}OGLCompiler${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
else() set(OSDependent_LIB ${EXTERNAL_LIB_CONFIG_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}OSDependent${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(glslang_INCLUDE_DIRECTORIES ${GLSLANG_INSTALL_DIR}/include) else()
set(glslang_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}glslang${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(glslang_INCLUDE_DIRECTORIES ${GLSLANG_INSTALL_DIR}/include)
set(SPIRV_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}SPIRV${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(glslang_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}glslang${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(OGLCompiler_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}OGLCompiler${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(SPIRV_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}SPIRV${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(OSDependent_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}OSDependent${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(OGLCompiler_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}OGLCompiler${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
endif() set(OSDependent_LIB ${GLSLANG_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}OSDependent${glslang_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
if(GLSLANG_VALIDATOR_INSTALL_DIR)
set(glslangValidator_RELEASE_EXECUTABLE ${GLSLANG_VALIDATOR_INSTALL_DIR}/bin/glslangValidator${HOST_EXECUTABLE_SUFFIX} CACHE INTERNAL "") set_target_properties(glslang PROPERTIES
endif() INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES}
IMPORTED_LOCATION ${glslang_LIB})
set_target_properties(glslang PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES} set_target_properties(SPIRV PROPERTIES
IMPORTED_LOCATION ${glslang_LIB}) INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES}
IMPORTED_LOCATION ${SPIRV_LIB})
set_target_properties(SPIRV PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES} set_target_properties(OGLCompiler PROPERTIES
IMPORTED_LOCATION ${SPIRV_LIB}) INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES}
IMPORTED_LOCATION ${OGLCompiler_LIB})
set_target_properties(OGLCompiler PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES} set_target_properties(OSDependent PROPERTIES
IMPORTED_LOCATION ${OGLCompiler_LIB}) INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES}
IMPORTED_LOCATION ${OSDependent_LIB})
set_target_properties(OSDependent PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${glslang_INCLUDE_DIRECTORIES} if(GLSLANG_VALIDATOR_INSTALL_DIR)
IMPORTED_LOCATION ${OSDependent_LIB}) set(glslangValidator_RELEASE_EXECUTABLE ${GLSLANG_VALIDATOR_INSTALL_DIR}/bin/glslangValidator${HOST_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
endif()
set_target_properties(glslangValidator PROPERTIES
IMPORTED_LOCATION ${glslangValidator_RELEASE_EXECUTABLE}) set_target_properties(glslangValidator PROPERTIES
else() IMPORTED_LOCATION ${glslangValidator_RELEASE_EXECUTABLE})
# Don't download if it is already present - this handles cases where internet connectivity may be limited but all packages are already available else()
if(EXISTS ${glslang_DOWNLOAD_DIR}/${external_glslang_VERSION}.tar.gz AND EXISTS ${glslang_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
set(glslang_URL "" CACHE INTERNAL "") if(EXISTS ${glslang_DOWNLOAD_DIR}/${external_glslang_VERSION}.tar.gz AND EXISTS ${glslang_SRC_DIR}/CMakeLists.txt)
message("glslang was found so will not be downloaded: ${glslang_SRC_DIR}") set(glslang_URL "" CACHE INTERNAL "")
else() message("glslang was found so will not be downloaded: ${glslang_SRC_DIR}")
set(glslang_URL "https://github.com/KhronosGroup/glslang/archive/${external_glslang_VERSION}.tar.gz" CACHE INTERNAL "") else()
# Remove the existing glslang downloads so that only the newest version of glslang will be present set(glslang_URL "https://github.com/KhronosGroup/glslang/archive/${external_glslang_VERSION}.tar.gz" CACHE INTERNAL "")
file(REMOVE_RECURSE ${glslang_DOWNLOAD_DIR}) # Remove the existing glslang downloads so that only the newest version of glslang will be present
endif() file(REMOVE_RECURSE ${glslang_DOWNLOAD_DIR})
message("glslang was not found so will be downloaded: ${glslang_URL}")
# glslang endif()
# See here for details: https://crascit.com/2015/07/25/cmake-gtest/
configure_file(external_glslang.cmake ${glslang_PREFIX}/build/CMakeLists.txt) # glslang
execute_process(COMMAND "${CMAKE_COMMAND}" . WORKING_DIRECTORY "${glslang_PREFIX}/build") download_external_project("glslang" "${glslang_PREFIX}" "${glslang_SRC_DIR}" "${glslang_DOWNLOAD_DIR}" "${glslang_URL}" "")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${glslang_PREFIX}/build")
# These options are used for both glslang and glslangValidator
# These options are used for both glslang and glslangValidator set(SKIP_GLSLANG_INSTALL ON CACHE INTERNAL "")
set(SKIP_GLSLANG_INSTALL ON CACHE INTERNAL "") set(BUILD_TESTING OFF CACHE INTERNAL "")
set(BUILD_TESTING OFF CACHE INTERNAL "") set(ENABLE_HLSL OFF CACHE INTERNAL "")
set(ENABLE_HLSL OFF CACHE INTERNAL "")
set(ENABLE_OPT OFF CACHE INTERNAL "") # If CMAKE_CROSSCOMPILING then do not build glslangValidator using normal add_subdirectory logic
set(ENABLE_AMD_EXTENSIONS OFF CACHE INTERNAL "") if(CMAKE_CROSSCOMPILING)
set(ENABLE_NV_EXTENSIONS OFF CACHE INTERNAL "") # See glslangValidator/CMakeLists.txt for how glslangValidator is built when cross-compiling
set(ENABLE_GLSLANG_BINARIES OFF CACHE INTERNAL "")
# If CMAKE_CROSSCOMPILING then do not build glslangValidator using normal add_subdirectory logic else()
if(CMAKE_CROSSCOMPILING) set(ENABLE_GLSLANG_BINARIES ON CACHE INTERNAL "")
set(ENABLE_GLSLANG_BINARIES OFF CACHE INTERNAL "") endif()
else()
set(ENABLE_GLSLANG_BINARIES ON CACHE INTERNAL "") add_subdirectory_if_not_already_included(glslang "${glslang_SRC_DIR}" "${glslang_PREFIX}/build")
endif()
set_target_properties(glslang PROPERTIES
add_subdirectory_if_not_already_included(glslang "${glslang_SRC_DIR}" "${glslang_PREFIX}/build") ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER})
set_target_properties(glslang PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER} set_target_properties(SPIRV PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}) ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER})
set_target_properties(SPIRV PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER} set_target_properties(OGLCompiler PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}) ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER})
set_target_properties(OGLCompiler PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER} set_target_properties(OSDependent PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}) ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER})
set_target_properties(OSDependent PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER} # If CMAKE_CROSSCOMPILING then we configure glslangValidator separately and import the executable
LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIB_CONFIG_FOLDER}) if(CMAKE_CROSSCOMPILING)
# Don't download if it is already present - this handles cases where internet connectivity may be limited but all packages are already available
# If CMAKE_CROSSCOMPILING then we configure glslangValidator separately and import the executable if(NOT EXISTS ${glslangValidator_RELEASE_EXECUTABLE})
if(CMAKE_CROSSCOMPILING) set(glslangValidator_base_URL "https://github.com/KhronosGroup/glslang/releases/download/${external_glslang_VERSION}")
# glslangValidator if(CMAKE_HOST_WIN32)
# See here for details: https://crascit.com/2015/07/25/cmake-gtest/ set(glslangValidator_URL "${glslangValidator_base_URL}/glslang-master-windows-x64-Release.zip" CACHE INTERNAL "")
# cmake "CC" and "CXX" environment variables are erroneously being set for child processes. elseif(CMAKE_HOST_APPLE)
# We must unset these variables during the configuration step for glslangValidator: https://gitlab.kitware.com/cmake/cmake/issues/16356 set(glslangValidator_URL "${glslangValidator_base_URL}/glslang-master-osx-Release.zip" CACHE INTERNAL "")
configure_file(external_glslangValidator.cmake ${glslangValidator_PREFIX}/build/CMakeLists.txt) elseif(CMAKE_HOST_UNIX)
execute_process(COMMAND set(glslangValidator_URL "${glslangValidator_base_URL}/glslang-master-linux-Release.zip" CACHE INTERNAL "")
${CMAKE_COMMAND} -E env --unset=CC --unset=CXX endif()
${CMAKE_COMMAND} . WORKING_DIRECTORY "${glslangValidator_PREFIX}/build")
execute_process(COMMAND message("glslangValidator was not found and we are cross compiling so it will be downloaded: ${glslangValidator_URL}")
${CMAKE_COMMAND} -E env --unset=CC --unset=CXX
${CMAKE_COMMAND} --build . --config Release WORKING_DIRECTORY "${glslangValidator_PREFIX}/build") # glslangValidator
download_external_project("glslangValidator" "${glslangValidator_PREFIX}" "${EXTERNAL_RELEASE_BIN_FOLDER}" "${glslang_DOWNLOAD_DIR}" "${glslangValidator_URL}" "${glslangValidator_RELEASE_EXECUTABLE}")
# glslangValidator will be built during the configuration step using ExternalProject_add endif()
# Create an import target for glslangValidator so we can use the target name directly
add_executable(glslangValidator IMPORTED GLOBAL) # Create an import target for glslangValidator so we can use the target name directly
set_target_properties(glslangValidator PROPERTIES add_executable(glslangValidator IMPORTED GLOBAL)
IMPORTED_LOCATION ${glslangValidator_RELEASE_EXECUTABLE}) set_target_properties(glslangValidator PROPERTIES
else() IMPORTED_LOCATION ${glslangValidator_RELEASE_EXECUTABLE})
# else ensure that the glslangValidator runtime output directory matches the installed directory else()
set_target_properties(glslangValidator PROPERTIES # Else glslangValidator will be built as part of the standard build
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXTERNAL_DEBUG_BIN_FOLDER}/bin/ # Ensure that the glslangValidator runtime output directory matches the installed directory
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXTERNAL_RELEASE_BIN_FOLDER}/bin/) set_target_properties(glslangValidator PROPERTIES
endif() RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXTERNAL_DEBUG_BIN_FOLDER}/bin/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXTERNAL_RELEASE_BIN_FOLDER}/bin/)
if(WIN32) endif()
set(CMAKE_DEBUG_POSTFIX "" CACHE INTERNAL "Removes the postfix for debug-built libraries which was set by glslang.") if(WIN32)
endif() set(CMAKE_DEBUG_POSTFIX "" CACHE INTERNAL "Removes the postfix for debug-built libraries which was set by glslang.")
endif() endif()
endif()
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