2016-03-20 00:13:06 +03:00
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(SPIRV-Cross)
|
|
|
|
enable_testing()
|
|
|
|
|
2016-12-15 22:46:10 +03:00
|
|
|
option(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS "Instead of throwing exceptions assert" OFF)
|
2016-12-13 00:33:22 +03:00
|
|
|
|
2016-03-20 00:13:06 +03:00
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Makefile")
|
|
|
|
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
message(FATAL_ERROR "Build out of tree to avoid overwriting Makefile")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-10-05 22:43:04 +03:00
|
|
|
add_library(spirv-cross-core STATIC
|
2016-11-11 20:04:14 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/GLSL.std.450.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_common.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.cpp)
|
2016-03-20 00:13:06 +03:00
|
|
|
|
2016-10-05 22:43:04 +03:00
|
|
|
add_library(spirv-cross-glsl STATIC
|
2016-11-11 20:04:14 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.hpp)
|
2016-10-05 22:43:04 +03:00
|
|
|
|
|
|
|
add_library(spirv-cross-cpp STATIC
|
2016-11-11 20:04:14 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.cpp)
|
2016-10-05 22:43:04 +03:00
|
|
|
|
|
|
|
add_library(spirv-cross-msl STATIC
|
2016-11-11 20:04:14 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.cpp)
|
2016-10-05 22:43:04 +03:00
|
|
|
|
2017-01-25 19:20:43 +03:00
|
|
|
add_library(spirv-cross-hlsl STATIC
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.hpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.cpp)
|
|
|
|
|
2016-10-05 22:43:04 +03:00
|
|
|
add_executable(spirv-cross main.cpp)
|
2017-01-25 19:20:43 +03:00
|
|
|
target_link_libraries(spirv-cross spirv-cross-glsl spirv-cross-cpp spirv-cross-msl spirv-cross-hlsl spirv-cross-core)
|
2016-10-05 22:43:04 +03:00
|
|
|
target_link_libraries(spirv-cross-glsl spirv-cross-core)
|
|
|
|
target_link_libraries(spirv-cross-msl spirv-cross-glsl)
|
|
|
|
target_link_libraries(spirv-cross-cpp spirv-cross-glsl)
|
2017-01-25 19:20:43 +03:00
|
|
|
target_link_libraries(spirv-cross-hlsl spirv-cross-glsl)
|
2016-10-05 22:43:04 +03:00
|
|
|
target_include_directories(spirv-cross-core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
2016-03-20 00:13:06 +03:00
|
|
|
|
2016-12-15 22:46:10 +03:00
|
|
|
set(spirv-compiler-options "")
|
|
|
|
set(spirv-compiler-defines "")
|
|
|
|
|
|
|
|
if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
|
|
|
|
set(spirv-compiler-defines ${spirv-compiler-defines} SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
|
|
|
|
endif()
|
|
|
|
|
2016-03-20 00:13:06 +03:00
|
|
|
# To specify special debug or optimization options, use
|
|
|
|
# -DCMAKE_CXX_COMPILE_FLAGS
|
|
|
|
# However, we require the C++11 dialect.
|
|
|
|
if (NOT "${MSVC}")
|
2016-12-15 22:46:10 +03:00
|
|
|
set(spirv-compiler-options ${spirv-compiler-options} -std=c++11 -Wall -Wextra -Werror -Wshadow)
|
|
|
|
set(spirv-compiler-defines ${spirv-compiler-defines} __STDC_LIMIT_MACROS)
|
2016-12-13 00:33:22 +03:00
|
|
|
|
|
|
|
if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
|
|
|
|
set(spirv-compiler-options ${spirv-compiler-options} -fno-exceptions)
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-03-20 00:13:06 +03:00
|
|
|
|
2016-12-15 22:46:10 +03:00
|
|
|
target_compile_options(spirv-cross-core PRIVATE ${spirv-compiler-options})
|
|
|
|
target_compile_options(spirv-cross-glsl PRIVATE ${spirv-compiler-options})
|
|
|
|
target_compile_options(spirv-cross-msl PRIVATE ${spirv-compiler-options})
|
|
|
|
target_compile_options(spirv-cross-cpp PRIVATE ${spirv-compiler-options})
|
2017-01-25 19:20:43 +03:00
|
|
|
target_compile_options(spirv-cross-hlsl PRIVATE ${spirv-compiler-options})
|
2016-12-15 22:46:10 +03:00
|
|
|
target_compile_options(spirv-cross PRIVATE ${spirv-compiler-options})
|
|
|
|
target_compile_definitions(spirv-cross-core PRIVATE ${spirv-compiler-defines})
|
|
|
|
target_compile_definitions(spirv-cross-glsl PRIVATE ${spirv-compiler-defines})
|
|
|
|
target_compile_definitions(spirv-cross-msl PRIVATE ${spirv-compiler-defines})
|
|
|
|
target_compile_definitions(spirv-cross-cpp PRIVATE ${spirv-compiler-defines})
|
2017-01-25 19:20:43 +03:00
|
|
|
target_compile_definitions(spirv-cross-hlsl PRIVATE ${spirv-compiler-defines})
|
2016-12-15 22:46:10 +03:00
|
|
|
target_compile_definitions(spirv-cross PRIVATE ${spirv-compiler-defines})
|
2016-03-20 00:13:06 +03:00
|
|
|
|
|
|
|
# Set up tests, using only the simplest modes of the test_shaders
|
|
|
|
# script. You have to invoke the script manually to:
|
|
|
|
# - Update the reference files
|
|
|
|
# - Get cycle counts from malisc
|
|
|
|
# - Keep failing outputs
|
2016-11-19 01:02:48 +03:00
|
|
|
find_package(PythonInterp)
|
2017-01-12 12:57:44 +03:00
|
|
|
if (${PYTHONINTERP_FOUND})
|
|
|
|
if (${PYTHON_VERSION_MAJOR} GREATER 2)
|
|
|
|
add_test(NAME spirv-cross-test
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/shaders)
|
2017-01-18 21:05:57 +03:00
|
|
|
add_test(NAME spirv-cross-test-metal
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl)
|
2017-01-28 10:58:39 +03:00
|
|
|
add_test(NAME spirv-cross-test-hlsl
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl)
|
2017-01-12 12:57:44 +03:00
|
|
|
endif()
|
2016-11-19 01:02:48 +03:00
|
|
|
else()
|
2016-12-13 00:33:22 +03:00
|
|
|
message(WARNING "Testing disabled. Could not find python3. If you have python3 installed try running "
|
|
|
|
"cmake with -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python3 to help it find the executable")
|
2016-03-20 00:13:06 +03:00
|
|
|
endif()
|