First Commit
This commit is contained in:
39
3rdparty/shaderc/cmake/linux-mingw-toolchain.cmake
vendored
Normal file
39
3rdparty/shaderc/cmake/linux-mingw-toolchain.cmake
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright 2020 The Shaderc Authors. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
set(MINGW_COMPILER_PREFIX "i686-w64-mingw32" CACHE STRING
|
||||
"What compiler prefix to use for mingw")
|
||||
|
||||
set(MINGW_SYSROOT "/usr/${MINGW_COMPILER_PREFIX}" CACHE STRING
|
||||
"What sysroot to use for mingw")
|
||||
|
||||
# Which compilers to use for C and C++
|
||||
find_program(CMAKE_RC_COMPILER NAMES ${MINGW_COMPILER_PREFIX}-windres)
|
||||
find_program(CMAKE_C_COMPILER NAMES
|
||||
${MINGW_COMPILER_PREFIX}-gcc-posix
|
||||
${MINGW_COMPILER_PREFIX}-gcc)
|
||||
find_program(CMAKE_CXX_COMPILER NAMES
|
||||
${MINGW_COMPILER_PREFIX}-g++-posix
|
||||
${MINGW_COMPILER_PREFIX}-g++)
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH ${MINGW_SYSROOT})
|
||||
|
||||
# Adjust the default behaviour of the FIND_XXX() commands:
|
||||
# Search headers and libraries in the target environment; search
|
||||
# programs in the host environment.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
67
3rdparty/shaderc/cmake/setup_build.cmake
vendored
Normal file
67
3rdparty/shaderc/cmake/setup_build.cmake
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
# Copyright 2020 The Shaderc Authors. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if(NOT COMMAND find_host_package)
|
||||
macro(find_host_package)
|
||||
find_package(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
if(NOT COMMAND find_host_program)
|
||||
macro(find_host_program)
|
||||
find_program(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
|
||||
# Find asciidoctor; see shaderc_add_asciidoc() from utils.cmake for
|
||||
# adding documents.
|
||||
find_program(ASCIIDOCTOR_EXE NAMES asciidoctor)
|
||||
if (NOT ASCIIDOCTOR_EXE)
|
||||
message(STATUS "asciidoctor was not found - no documentation will be"
|
||||
" generated")
|
||||
endif()
|
||||
|
||||
# On Windows, CMake by default compiles with the shared CRT.
|
||||
# Ensure that gmock compiles the same, otherwise failures will occur.
|
||||
if(WIN32)
|
||||
# TODO(awoloszyn): Once we support selecting CRT versions,
|
||||
# make sure this matches correctly.
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
endif(WIN32)
|
||||
|
||||
if (ANDROID)
|
||||
# For android let's preemptively find the correct packages so that
|
||||
# child projects (glslang, googletest) do not fail to find them.
|
||||
|
||||
# Tests in glslc and SPIRV-Tools tests require Python 3, or a Python 2
|
||||
# with the "future" package. Require Python 3 because we can't force
|
||||
# developers to manually install the "future" package.
|
||||
find_host_package(PythonInterp 3 REQUIRED)
|
||||
find_host_package(BISON)
|
||||
else()
|
||||
find_package(Python COMPONENTS Interpreter REQUIRED)
|
||||
endif()
|
||||
|
||||
option(DISABLE_RTTI "Disable RTTI in builds")
|
||||
if(DISABLE_RTTI)
|
||||
if(UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
endif(UNIX)
|
||||
endif(DISABLE_RTTI)
|
||||
|
||||
option(DISABLE_EXCEPTIONS "Disables exceptions in builds")
|
||||
if(DISABLE_EXCEPTIONS)
|
||||
if(UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||
endif(UNIX)
|
||||
endif(DISABLE_EXCEPTIONS)
|
||||
12
3rdparty/shaderc/cmake/shaderc.pc.in
vendored
Normal file
12
3rdparty/shaderc/cmake/shaderc.pc.in
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: shaderc
|
||||
Description: Tools and libraries for Vulkan shader compilation
|
||||
Version: @CURRENT_VERSION@
|
||||
URL: https://github.com/google/shaderc
|
||||
|
||||
Libs: -L${libdir} @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
12
3rdparty/shaderc/cmake/shaderc_combined.pc.in
vendored
Normal file
12
3rdparty/shaderc/cmake/shaderc_combined.pc.in
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: shaderc
|
||||
Description: Tools and libraries for Vulkan shader compilation
|
||||
Version: @CURRENT_VERSION@
|
||||
URL: https://github.com/google/shaderc
|
||||
|
||||
Libs: -L${libdir} @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
12
3rdparty/shaderc/cmake/shaderc_static.pc.in
vendored
Normal file
12
3rdparty/shaderc/cmake/shaderc_static.pc.in
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: shaderc
|
||||
Description: Tools and libraries for Vulkan shader compilation
|
||||
Version: @CURRENT_VERSION@
|
||||
URL: https://github.com/google/shaderc
|
||||
|
||||
Libs: -L${libdir} @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
182
3rdparty/shaderc/cmake/utils.cmake
vendored
Normal file
182
3rdparty/shaderc/cmake/utils.cmake
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
# Copyright 2020 The Shaderc Authors. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# utility functions
|
||||
|
||||
function (shaderc_use_gmock TARGET)
|
||||
target_include_directories(${TARGET} PRIVATE
|
||||
${gmock_SOURCE_DIR}/include
|
||||
${gtest_SOURCE_DIR}/include)
|
||||
target_link_libraries(${TARGET} PRIVATE gmock gtest_main)
|
||||
endfunction(shaderc_use_gmock)
|
||||
|
||||
function(shaderc_default_c_compile_options TARGET)
|
||||
if (NOT "${MSVC}")
|
||||
if (SHADERC_ENABLE_WERROR_COMPILE)
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -Werror -fvisibility=hidden)
|
||||
else()
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -fvisibility=hidden)
|
||||
endif()
|
||||
check_cxx_compiler_flag(-fPIC COMPILER_SUPPORTS_PIC)
|
||||
if (NOT "${MINGW}" AND COMPILER_SUPPORTS_PIC)
|
||||
target_compile_options(${TARGET} PRIVATE -fPIC)
|
||||
endif()
|
||||
if (ENABLE_CODE_COVERAGE)
|
||||
# The --coverage option is a synonym for -fprofile-arcs -ftest-coverage
|
||||
# when compiling.
|
||||
target_compile_options(${TARGET} PRIVATE -g -O0 --coverage)
|
||||
# The --coverage option is a synonym for -lgcov when linking for gcc.
|
||||
# For clang, it links in a different library, libclang_rt.profile, which
|
||||
# requires clang to be built with compiler-rt.
|
||||
target_link_libraries(${TARGET} PRIVATE --coverage)
|
||||
endif()
|
||||
if (NOT SHADERC_ENABLE_SHARED_CRT)
|
||||
if (WIN32)
|
||||
# For MinGW cross compile, statically link to the libgcc runtime.
|
||||
# But it still depends on MSVCRT.dll.
|
||||
set_target_properties(${TARGET} PROPERTIES
|
||||
LINK_FLAGS "-static -static-libgcc")
|
||||
endif(WIN32)
|
||||
endif(NOT SHADERC_ENABLE_SHARED_CRT)
|
||||
else()
|
||||
# disable warning C4800: 'int' : forcing value to bool 'true' or 'false'
|
||||
# (performance warning)
|
||||
target_compile_options(${TARGET} PRIVATE /wd4800)
|
||||
endif()
|
||||
endfunction(shaderc_default_c_compile_options)
|
||||
|
||||
function(shaderc_default_compile_options TARGET)
|
||||
shaderc_default_c_compile_options(${TARGET})
|
||||
if (NOT "${MSVC}")
|
||||
if (NOT SHADERC_ENABLE_SHARED_CRT)
|
||||
if (WIN32)
|
||||
# For MinGW cross compile, statically link to the C++ runtime.
|
||||
# But it still depends on MSVCRT.dll.
|
||||
set_target_properties(${TARGET} PROPERTIES
|
||||
LINK_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||
endif(WIN32)
|
||||
endif(NOT SHADERC_ENABLE_SHARED_CRT)
|
||||
endif()
|
||||
endfunction(shaderc_default_compile_options)
|
||||
|
||||
# Build an asciidoc file; additional arguments past the base filename specify
|
||||
# additional dependencies for the file.
|
||||
function(shaderc_add_asciidoc TARGET FILE)
|
||||
if (ASCIIDOCTOR_EXE)
|
||||
set(DEST ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.html)
|
||||
add_custom_command(
|
||||
COMMAND ${ASCIIDOCTOR_EXE} -a toc -o ${DEST}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.asciidoc
|
||||
DEPENDS ${FILE}.asciidoc ${ARGN}
|
||||
OUTPUT ${DEST})
|
||||
# Create the target, but the default build target does not depend on it.
|
||||
# Some Asciidoctor installations are mysteriously broken, and it's hard
|
||||
# to detect those cases. Generating HTML is not critical by default.
|
||||
add_custom_target(${TARGET} DEPENDS ${DEST})
|
||||
endif(ASCIIDOCTOR_EXE)
|
||||
endfunction()
|
||||
|
||||
# Adds a set of tests.
|
||||
# This function accepts the following parameters:
|
||||
# TEST_PREFIX: a prefix for each test target name
|
||||
# TEST_NAMES: a list of test names where each TEST_NAME has a corresponding
|
||||
# file residing at src/${TEST_NAME}_test.cc
|
||||
# LINK_LIBS: (optional) a list of libraries to be linked to the test target
|
||||
# INCLUDE_DIRS: (optional) a list of include directories to be searched
|
||||
# for header files.
|
||||
function(shaderc_add_tests)
|
||||
if(${SHADERC_ENABLE_TESTS})
|
||||
cmake_parse_arguments(PARSED_ARGS
|
||||
""
|
||||
"TEST_PREFIX"
|
||||
"TEST_NAMES;LINK_LIBS;INCLUDE_DIRS"
|
||||
${ARGN})
|
||||
if (NOT PARSED_ARGS_TEST_NAMES)
|
||||
message(FATAL_ERROR "Tests must have a target")
|
||||
endif()
|
||||
if (NOT PARSED_ARGS_TEST_PREFIX)
|
||||
message(FATAL_ERROR "Tests must have a prefix")
|
||||
endif()
|
||||
foreach(TARGET ${PARSED_ARGS_TEST_NAMES})
|
||||
set(TEST_NAME ${PARSED_ARGS_TEST_PREFIX}_${TARGET}_test)
|
||||
add_executable(${TEST_NAME} src/${TARGET}_test.cc)
|
||||
shaderc_default_compile_options(${TEST_NAME})
|
||||
if (MINGW)
|
||||
target_compile_options(${TEST_NAME} PRIVATE -DSHADERC_DISABLE_THREADED_TESTS)
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
# Disable this warning, which is useless in test code.
|
||||
# Fixes https://github.com/google/shaderc/issues/334
|
||||
target_compile_options(${TEST_NAME} PRIVATE -Wno-noexcept-type)
|
||||
endif()
|
||||
if (PARSED_ARGS_LINK_LIBS)
|
||||
target_link_libraries(${TEST_NAME} PRIVATE
|
||||
${PARSED_ARGS_LINK_LIBS})
|
||||
endif()
|
||||
if (PARSED_ARGS_INCLUDE_DIRS)
|
||||
target_include_directories(${TEST_NAME} PRIVATE
|
||||
${PARSED_ARGS_INCLUDE_DIRS})
|
||||
endif()
|
||||
shaderc_use_gmock(${TEST_NAME})
|
||||
add_test(
|
||||
NAME ${PARSED_ARGS_TEST_PREFIX}_${TARGET}
|
||||
COMMAND ${TEST_NAME})
|
||||
endforeach()
|
||||
endif(${SHADERC_ENABLE_TESTS})
|
||||
endfunction(shaderc_add_tests)
|
||||
|
||||
# Finds all transitive static library dependencies of a given target
|
||||
# including possibly the target itself.
|
||||
# This will skip libraries that were statically linked that were not
|
||||
# built by CMake, for example -lpthread.
|
||||
macro(shaderc_get_transitive_libs target out_list)
|
||||
if (TARGET ${target})
|
||||
get_target_property(libtype ${target} TYPE)
|
||||
# If this target is a static library, get anything it depends on.
|
||||
if ("${libtype}" STREQUAL "STATIC_LIBRARY")
|
||||
# Get the original library if this is an alias library. This is
|
||||
# to avoid putting both the original library and the alias library
|
||||
# in the list (given we are deduplicating according to target names).
|
||||
# Otherwise, we may pack the same library twice, resulting in
|
||||
# duplicated symbols.
|
||||
get_target_property(aliased_target ${target} ALIASED_TARGET)
|
||||
if (aliased_target)
|
||||
list(INSERT ${out_list} 0 "${aliased_target}")
|
||||
else()
|
||||
list(INSERT ${out_list} 0 "${target}")
|
||||
endif()
|
||||
|
||||
get_target_property(libs ${target} LINK_LIBRARIES)
|
||||
if (libs)
|
||||
foreach(lib ${libs})
|
||||
shaderc_get_transitive_libs(${lib} ${out_list})
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
# If we know the location (i.e. if it was made with CMake) then we
|
||||
# can add it to our list.
|
||||
LIST(REMOVE_DUPLICATES ${out_list})
|
||||
endmacro()
|
||||
|
||||
# Combines the static library "target" with all of its transitive static
|
||||
# library dependencies into a single static library "new_target".
|
||||
function(shaderc_combine_static_lib new_target target)
|
||||
set(all_libs "")
|
||||
shaderc_get_transitive_libs(${target} all_libs)
|
||||
add_library(${new_target} STATIC)
|
||||
foreach(lib IN LISTS all_libs)
|
||||
target_sources(${new_target} PRIVATE $<TARGET_OBJECTS:${lib}>)
|
||||
endforeach()
|
||||
endfunction()
|
||||
31
3rdparty/shaderc/cmake/write_pkg_config.cmake
vendored
Normal file
31
3rdparty/shaderc/cmake/write_pkg_config.cmake
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2017 Pierre Moreau
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# First, retrieve the current version from CHANGES
|
||||
file(STRINGS ${CHANGES_FILE} CHANGES_CONTENT)
|
||||
string(
|
||||
REGEX
|
||||
MATCH "v[0-9]+(.[0-9]+)?(-dev)? [0-9]+-[0-9]+-[0-9]+"
|
||||
FIRST_VERSION_LINE
|
||||
${CHANGES_CONTENT})
|
||||
string(
|
||||
REGEX
|
||||
REPLACE "^v([^ ]+) .+$" "\\1"
|
||||
CURRENT_VERSION
|
||||
"${FIRST_VERSION_LINE}")
|
||||
# If this is a development version, replace "-dev" by ".0" as pkg-config nor
|
||||
# CMake support "-dev" in the version.
|
||||
# If it's not a "-dev" version then ensure it ends with ".1"
|
||||
string(REGEX REPLACE "-dev.1" ".0" CURRENT_VERSION "${CURRENT_VERSION}.1")
|
||||
configure_file(${TEMPLATE_FILE} ${OUT_FILE} @ONLY)
|
||||
Reference in New Issue
Block a user