2017-04-20 18:38:20 +00:00
|
|
|
# Copyright 2017 The NXT Authors
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
# GLFW, only build the library
|
|
|
|
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
|
|
|
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
|
|
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
|
|
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
|
|
|
|
add_subdirectory(glfw)
|
2017-07-07 18:41:17 +00:00
|
|
|
NXTExternalTarget("third_party" glfw)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
# GoogleTest
|
|
|
|
set(GTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googletest)
|
|
|
|
set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock)
|
|
|
|
add_library(gtest STATIC ${GTEST_DIR}/src/gtest-all.cc ${GMOCK_DIR}/src/gmock-all.cc)
|
|
|
|
target_include_directories(gtest SYSTEM PUBLIC ${GTEST_DIR}/include ${GMOCK_DIR}/include)
|
2017-07-22 00:00:22 +00:00
|
|
|
target_include_directories(gtest SYSTEM PRIVATE ${GTEST_DIR} ${GMOCK_DIR})
|
2017-04-20 18:38:20 +00:00
|
|
|
find_package(Threads)
|
|
|
|
target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT})
|
2017-07-07 18:41:17 +00:00
|
|
|
NXTExternalTarget("third_party" gtest)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
# Glad
|
2017-05-29 18:21:33 +00:00
|
|
|
add_library(glad STATIC
|
2017-04-20 18:38:20 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/glad/src/glad.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/glad/include/glad/glad.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/glad/include/KHR/khrplatform.h
|
|
|
|
)
|
2017-07-22 00:00:22 +00:00
|
|
|
target_include_directories(glad SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/glad/include)
|
2017-07-07 18:41:17 +00:00
|
|
|
NXTExternalTarget("third_party" glad)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
# ShaderC
|
2017-07-10 23:08:46 +00:00
|
|
|
# Prevent SPIRV-Tools from using Werror as it has a warning on MSVC
|
2017-07-19 22:41:17 +00:00
|
|
|
set(SPIRV_WERROR OFF CACHE BOOL "" FORCE)
|
2017-07-10 23:08:46 +00:00
|
|
|
# Don't add unnecessary shaderc targets
|
2017-04-20 18:38:20 +00:00
|
|
|
set(SHADERC_SKIP_TESTS ON)
|
2017-11-28 18:08:17 +00:00
|
|
|
set(SHADERC_SKIP_INSTALL ON)
|
|
|
|
# Remove unused glslang and spirv-tools parts
|
|
|
|
# set(ENABLE_HLSL OFF CACHE BOOL "")
|
|
|
|
set(ENABLE_OPT OFF CACHE BOOL "")
|
|
|
|
set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "")
|
|
|
|
set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "")
|
|
|
|
set(SKIP_SPIRV_TOOLS_INSTALL ON CACHE BOOL "")
|
|
|
|
set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "")
|
2017-07-10 23:08:46 +00:00
|
|
|
# Help shaderc find the non-standard paths for its dependencies
|
2017-04-20 18:38:20 +00:00
|
|
|
set(SHADERC_GOOGLE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest CACHE STRING "Location of googletest source")
|
|
|
|
set(SHADERC_GLSLANG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/glslang" CACHE STRING "Location of glslang source")
|
|
|
|
set(SHADERC_SPIRV_TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools CACHE STRING "Location of spirv-tools source")
|
2017-07-03 13:52:12 +00:00
|
|
|
# Help shaderc find the python executable when run inside VS.
|
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
set(PYTHON_EXE ${PYTHON_EXECUTABLE})
|
2017-04-20 18:38:20 +00:00
|
|
|
# Need to include this for spirv-tools to find it
|
|
|
|
add_subdirectory(spirv-headers)
|
|
|
|
add_subdirectory(shaderc)
|
2017-07-10 23:08:46 +00:00
|
|
|
# Namespace the shaderc targets in a folder to avoid cluttering the
|
|
|
|
# Visual Studio solution explorer
|
|
|
|
set_target_properties(
|
|
|
|
add-copyright
|
|
|
|
build-version
|
|
|
|
check-copyright
|
|
|
|
glslc
|
|
|
|
glslc_exe
|
|
|
|
install-headers
|
|
|
|
shaderc
|
2017-11-28 18:08:17 +00:00
|
|
|
shaderc_shared
|
2017-07-10 23:08:46 +00:00
|
|
|
shaderc_util
|
|
|
|
shaderc_combined_genfile
|
|
|
|
shaderc-online-compile testdata
|
|
|
|
SPIRV-Headers-example
|
|
|
|
SPIRV-Headers-example-1.1
|
|
|
|
PROPERTIES FOLDER "third_party/shaderc"
|
|
|
|
)
|
2017-11-28 18:08:17 +00:00
|
|
|
# Remove a bunch of targets we don't need that are pulled by shaderc and glslang
|
|
|
|
set_target_properties(
|
|
|
|
SPIRV-Headers-example-1.1
|
|
|
|
SPIRV-Headers-example
|
|
|
|
glslc_exe
|
|
|
|
SPIRV-Tools-link
|
|
|
|
SPVRemapper
|
|
|
|
shaderc
|
|
|
|
shaderc-online-compile
|
|
|
|
shaderc_combined_genfile
|
|
|
|
PROPERTIES EXCLUDE_FROM_ALL true
|
|
|
|
)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
# SPIRV-Cross
|
2017-08-29 15:19:34 +00:00
|
|
|
set(SPIRV_CROSS_SOURCES
|
2017-04-20 18:38:20 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/GLSL.std.450.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_common.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cfg.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cfg.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cross.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cross.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv.hpp
|
|
|
|
)
|
2017-08-29 15:19:34 +00:00
|
|
|
|
|
|
|
set(NEED_SPIRV_CROSS_GLSL OFF)
|
|
|
|
if (NXT_ENABLE_D3D12)
|
|
|
|
list(APPEND SPIRV_CROSS_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_hlsl.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_hlsl.hpp
|
|
|
|
)
|
|
|
|
set(NEED_SPIRV_CROSS_GLSL ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NXT_ENABLE_METAL)
|
|
|
|
list(APPEND SPIRV_CROSS_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_msl.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_msl.hpp
|
|
|
|
)
|
|
|
|
set(NEED_SPIRV_CROSS_GLSL ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NXT_ENABLE_OPENGL OR NEED_SPIRV_CROSS_GLSL)
|
|
|
|
list(APPEND SPIRV_CROSS_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_glsl.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_glsl.hpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_library(spirv_cross STATIC ${SPIRV_CROSS_SOURCES})
|
2017-07-22 00:00:22 +00:00
|
|
|
target_include_directories(spirv_cross SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
2017-07-07 18:41:17 +00:00
|
|
|
NXTExternalTarget("third_party" spirv_cross)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
# STB, used for stb_image
|
|
|
|
set(STB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stb PARENT_SCOPE)
|
|
|
|
|
|
|
|
# glm matrix math library
|
|
|
|
set(GLM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glm PARENT_SCOPE)
|
2017-11-17 21:59:47 +00:00
|
|
|
|
|
|
|
# Vulkan headers
|
|
|
|
set(VULKAN_HEADERS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
|