2016-01-07 18:44:22 +00:00
|
|
|
# Copyright (c) 2015-2016 The Khronos Group Inc.
|
2015-05-22 17:26:19 +00:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
# copy of this software and/or associated documentation files (the
|
|
|
|
# "Materials"), to deal in the Materials without restriction, including
|
|
|
|
# without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
# distribute, sublicense, and/or sell copies of the Materials, and to
|
|
|
|
# permit persons to whom the Materials are furnished to do so, subject to
|
|
|
|
# the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included
|
|
|
|
# in all copies or substantial portions of the Materials.
|
|
|
|
#
|
|
|
|
# MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
|
|
|
|
# KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
|
|
|
|
# SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
|
|
|
|
# https://www.khronos.org/registry/
|
|
|
|
#
|
|
|
|
# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
|
|
|
2016-03-14 12:41:32 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2015-07-29 19:22:09 +00:00
|
|
|
project(spirv-tools)
|
2016-02-02 19:41:35 +00:00
|
|
|
enable_testing()
|
2015-11-18 14:22:10 +00:00
|
|
|
set(SPIRV_TOOLS "SPIRV-Tools")
|
2015-05-22 17:26:19 +00:00
|
|
|
|
2016-04-03 22:21:35 +00:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
2015-05-22 17:26:19 +00:00
|
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
|
|
|
add_definitions(-DSPIRV_LINUX)
|
|
|
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
|
add_definitions(-DSPIRV_WINDOWS)
|
|
|
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
|
|
add_definitions(-DSPIRV_MAC)
|
2016-04-18 14:59:47 +00:00
|
|
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
|
|
|
|
add_definitions(-DSPIRV_ANDROID)
|
2015-05-22 17:26:19 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Your platform '${CMAKE_SYSTEM_NAME}' is not supported!")
|
|
|
|
endif()
|
|
|
|
|
2015-11-18 14:22:10 +00:00
|
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
2015-05-22 17:26:19 +00:00
|
|
|
message(STATUS "No build type selected, default to Debug")
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
|
|
endif()
|
|
|
|
|
2015-11-19 14:22:53 +00:00
|
|
|
option(SPIRV_WERROR "Enable error on warning" ON)
|
2016-02-29 06:01:04 +00:00
|
|
|
if((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
|
|
|
|
set(COMPILER_IS_LIKE_GNU TRUE)
|
|
|
|
endif()
|
|
|
|
if(${COMPILER_IS_LIKE_GNU})
|
2015-11-18 14:22:10 +00:00
|
|
|
set(SPIRV_WARNINGS -Wall -Wextra -Wno-missing-field-initializers)
|
2015-10-15 20:43:14 +00:00
|
|
|
|
2015-12-09 16:40:56 +00:00
|
|
|
option(SPIRV_WARN_EVERYTHING "Enable -Weverything" ${SPIRV_WARN_EVERYTHING})
|
2015-11-18 14:22:10 +00:00
|
|
|
if(${SPIRV_WARN_EVERYTHING})
|
2015-12-09 16:40:56 +00:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
set(SPIRV_WARNINGS ${SPIRV_WARNINGS}
|
|
|
|
-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded)
|
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
set(SPIRV_WARNINGS ${SPIRV_WARNINGS} -Wpedantic -pedantic-errors)
|
|
|
|
else()
|
|
|
|
message(STATUS "Unknown compiler ${CMAKE_CXX_COMPILER_ID}, "
|
|
|
|
"so SPIRV_WARN_EVERYTHING has no effect")
|
|
|
|
endif()
|
2015-10-15 20:43:14 +00:00
|
|
|
endif()
|
|
|
|
|
2015-11-18 14:22:10 +00:00
|
|
|
if(${SPIRV_WERROR})
|
|
|
|
set(SPIRV_WARNINGS ${SPIRV_WARNINGS} -Werror)
|
2015-05-22 17:26:19 +00:00
|
|
|
endif()
|
2016-02-29 06:01:04 +00:00
|
|
|
elseif(MSVC)
|
2015-11-18 14:22:10 +00:00
|
|
|
set(SPIRV_WARNINGS -D_CRT_SECURE_NO_WARNINGS /wd4800)
|
2015-11-19 14:22:53 +00:00
|
|
|
|
|
|
|
if(${SPIRV_WERROR})
|
|
|
|
set(SPIRV_WARNINGS ${SPIRV_WARNINGS} /WX)
|
|
|
|
endif()
|
2015-05-22 17:26:19 +00:00
|
|
|
endif()
|
|
|
|
|
2016-06-02 22:51:05 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source)
|
|
|
|
|
2015-11-12 16:44:42 +00:00
|
|
|
option(SPIRV_COLOR_TERMINAL "Enable color terminal output" ON)
|
|
|
|
if(${SPIRV_COLOR_TERMINAL})
|
|
|
|
add_definitions(-DSPIRV_COLOR_TERMINAL)
|
2015-05-22 17:26:19 +00:00
|
|
|
endif()
|
|
|
|
|
2016-01-26 23:04:55 +00:00
|
|
|
function(spvtools_default_compile_options TARGET)
|
2015-11-18 14:22:10 +00:00
|
|
|
target_compile_options(${TARGET} PRIVATE ${SPIRV_WARNINGS})
|
2016-02-29 06:01:04 +00:00
|
|
|
|
|
|
|
if (${COMPILER_IS_LIKE_GNU})
|
2015-11-18 14:22:10 +00:00
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
-std=c++11 -fno-exceptions -fno-rtti)
|
2016-01-11 15:54:20 +00:00
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
-Wall -Wextra -Wno-long-long -Wshadow -Wundef -Wconversion
|
|
|
|
-Wno-sign-conversion)
|
2015-11-18 14:22:10 +00:00
|
|
|
# For good call stacks in profiles, keep the frame pointers.
|
|
|
|
if(NOT "${SPIRV_PERF}" STREQUAL "")
|
|
|
|
target_compile_options(${TARGET} PRIVATE -fno-omit-frame-pointer)
|
|
|
|
endif()
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
set(SPIRV_USE_SANITIZER "" CACHE STRING
|
|
|
|
"Use the clang sanitizer [address|memory|thread|...]")
|
|
|
|
if(NOT "${SPIRV_USE_SANITIZER}" STREQUAL "")
|
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
-fsanitize=${SPIRV_USE_SANITIZER})
|
|
|
|
endif()
|
2016-01-11 15:54:20 +00:00
|
|
|
else()
|
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
-Wno-missing-field-initializers)
|
2015-11-18 14:22:10 +00:00
|
|
|
endif()
|
2015-05-22 17:26:19 +00:00
|
|
|
endif()
|
2016-02-29 06:01:04 +00:00
|
|
|
|
|
|
|
# For MinGW cross compile, statically link to the C++ runtime.
|
|
|
|
# But it still depends on MSVCRT.dll.
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
|
|
|
if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
|
|
|
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS
|
|
|
|
-static -static-libgcc -static-libstdc++)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-11-18 14:22:10 +00:00
|
|
|
endfunction()
|
2015-05-22 17:26:19 +00:00
|
|
|
|
2016-02-24 15:11:07 +00:00
|
|
|
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_host_package(PythonInterp)
|
|
|
|
|
2016-02-22 21:07:19 +00:00
|
|
|
|
2015-12-09 16:40:56 +00:00
|
|
|
# Defaults to OFF if the user didn't set it.
|
2015-11-18 14:22:10 +00:00
|
|
|
option(SPIRV_SKIP_EXECUTABLES
|
2015-12-09 16:40:56 +00:00
|
|
|
"Skip building the executable and tests along with the library"
|
|
|
|
${SPIRV_SKIP_EXECUTABLES})
|
2015-09-04 19:13:57 +00:00
|
|
|
|
2016-03-17 02:43:31 +00:00
|
|
|
add_subdirectory(external)
|
2015-11-18 14:22:10 +00:00
|
|
|
|
2016-03-17 02:43:31 +00:00
|
|
|
add_subdirectory(source)
|
|
|
|
add_subdirectory(tools)
|
2015-05-22 17:26:19 +00:00
|
|
|
|
2016-03-17 02:43:31 +00:00
|
|
|
add_subdirectory(test)
|
2015-05-22 17:26:19 +00:00
|
|
|
|
2016-02-17 19:44:00 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/libspirv.h
|
|
|
|
DESTINATION include/spirv-tools/)
|