| 1 |
cmake_minimum_required(VERSION 3.19) |
| 2 |
set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 3 |
|
| 4 |
# Adhere to GNU filesystem layout conventions |
| 5 |
include(GNUInstallDirs) |
| 6 |
|
| 7 |
option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON) |
| 8 |
option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON) |
| 9 |
option(ENABLE_OPT "Enables spirv-opt capability if present" OFF) |
| 10 |
|
| 11 |
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32) |
| 12 |
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE) |
| 13 |
endif() |
| 14 |
|
| 15 |
project(../glslang) |
| 16 |
# make testing optional |
| 17 |
include(CTest) |
| 18 |
|
| 19 |
#if (LINUX) |
| 20 |
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") |
| 21 |
#endif() |
| 22 |
|
| 23 |
if(ENABLE_AMD_EXTENSIONS) |
| 24 |
add_definitions(-DAMD_EXTENSIONS) |
| 25 |
endif(ENABLE_AMD_EXTENSIONS) |
| 26 |
|
| 27 |
if(ENABLE_NV_EXTENSIONS) |
| 28 |
add_definitions(-DNV_EXTENSIONS) |
| 29 |
endif(ENABLE_NV_EXTENSIONS) |
| 30 |
|
| 31 |
#if(ENABLE_HLSL) |
| 32 |
# add_definitions(-DENABLE_HLSL) |
| 33 |
#endif(ENABLE_HLSL) |
| 34 |
|
| 35 |
if(WIN32) |
| 36 |
set(CMAKE_DEBUG_POSTFIX "d") |
| 37 |
add_definitions(-DGLSLANG_OSINCLUDE_WIN32) |
| 38 |
elseif(UNIX) |
| 39 |
add_definitions(-DGLSLANG_OSINCLUDE_UNIX) |
| 40 |
else(WIN32) |
| 41 |
message("unknown platform") |
| 42 |
endif(WIN32) |
| 43 |
|
| 44 |
function(glslang_set_link_args TARGET) |
| 45 |
# For MinGW compiles, statically link against the GCC and C++ runtimes. |
| 46 |
# This avoids the need to ship those runtimes as DLLs. |
| 47 |
if (WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") |
| 48 |
set_target_properties(${TARGET} PROPERTIES |
| 49 |
LINK_FLAGS "-static -static-libgcc -static-libstdc++") |
| 50 |
endif() |
| 51 |
endfunction(glslang_set_link_args) |
| 52 |
|
| 53 |
# We keep the optimizer disabled, we call it ourselves |
| 54 |
# if(ENABLE_OPT) |
| 55 |
# message(STATUS "SPIR-V optimizer enabled") |
| 56 |
# add_definitions(-DENABLE_OPT) |
| 57 |
# elseif(ENABLE_HLSL) |
| 58 |
# message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL") |
| 59 |
# endif() |
| 60 |
|
| 61 |
find_package(PythonInterp 3 REQUIRED) |
| 62 |
|
| 63 |
# Root directory for build-time generated include files |
| 64 |
set(GLSLANG_GENERATED_INCLUDEDIR "${CMAKE_BINARY_DIR}/include") |
| 65 |
|
| 66 |
################################################################################ |
| 67 |
# Build version information generation |
| 68 |
################################################################################ |
| 69 |
set(GLSLANG_CHANGES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../CHANGES.md") |
| 70 |
set(GLSLANG_BUILD_INFO_PY "${CMAKE_CURRENT_SOURCE_DIR}/../build_info.py") |
| 71 |
set(GLSLANG_BUILD_INFO_H_TMPL "${CMAKE_CURRENT_SOURCE_DIR}/../build_info.h.tmpl") |
| 72 |
set(GLSLANG_BUILD_INFO_H "${GLSLANG_GENERATED_INCLUDEDIR}/glslang/build_info.h") |
| 73 |
|
| 74 |
# Command to build the build_info.h file |
| 75 |
add_custom_command( |
| 76 |
OUTPUT ${GLSLANG_BUILD_INFO_H} |
| 77 |
COMMAND ${PYTHON_EXECUTABLE} "${GLSLANG_BUILD_INFO_PY}" |
| 78 |
${CMAKE_CURRENT_SOURCE_DIR}/.. |
| 79 |
"-i" ${GLSLANG_BUILD_INFO_H_TMPL} |
| 80 |
"-o" ${GLSLANG_BUILD_INFO_H} |
| 81 |
DEPENDS ${GLSLANG_BUILD_INFO_PY} |
| 82 |
${GLSLANG_CHANGES_FILE} |
| 83 |
${GLSLANG_BUILD_INFO_H_TMPL} |
| 84 |
COMMENT "Generating ${GLSLANG_BUILD_INFO_H}") |
| 85 |
|
| 86 |
# Target to build the build_info.h file |
| 87 |
add_custom_target(glslang-build-info DEPENDS ${GLSLANG_BUILD_INFO_H}) |
| 88 |
|
| 89 |
# Populate the CMake GLSLANG_VERSION* variables with the build version |
| 90 |
# information. |
| 91 |
execute_process( |
| 92 |
COMMAND ${PYTHON_EXECUTABLE} "${GLSLANG_BUILD_INFO_PY}" |
| 93 |
${CMAKE_CURRENT_SOURCE_DIR}/.. "<major>.<minor>.<patch><-flavor>;<major>;<minor>;<patch>;<flavor>" |
| 94 |
OUTPUT_VARIABLE "GLSLANG_VERSIONS" |
| 95 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 96 |
list(GET "GLSLANG_VERSIONS" 0 "GLSLANG_VERSION") |
| 97 |
list(GET "GLSLANG_VERSIONS" 1 "GLSLANG_VERSION_MAJOR") |
| 98 |
list(GET "GLSLANG_VERSIONS" 2 "GLSLANG_VERSION_MINOR") |
| 99 |
list(GET "GLSLANG_VERSIONS" 3 "GLSLANG_VERSION_PATCH") |
| 100 |
list(GET "GLSLANG_VERSIONS" 4 "GLSLANG_VERSION_FLAVOR") |
| 101 |
configure_file(${GLSLANG_CHANGES_FILE} "${CMAKE_CURRENT_BINARY_DIR}/CHANGES.md") # Required to re-run cmake on version change |
| 102 |
|
| 103 |
# glslang_add_build_info_dependency() adds the glslang-build-info dependency and |
| 104 |
# generated include directories to target. |
| 105 |
function(glslang_add_build_info_dependency target) |
| 106 |
target_include_directories(${target} PUBLIC $<BUILD_INTERFACE:${GLSLANG_GENERATED_INCLUDEDIR}>) |
| 107 |
add_dependencies(${target} glslang-build-info) |
| 108 |
endfunction() |
| 109 |
|
| 110 |
|
| 111 |
add_subdirectory(../glslang/tnt "${CMAKE_CURRENT_BINARY_DIR}/glslang") |
| 112 |
add_subdirectory(../OGLCompilersDLL/tnt "${CMAKE_CURRENT_BINARY_DIR}/OGLCompilersDLL") |
| 113 |
add_subdirectory(../SPIRV/tnt "${CMAKE_CURRENT_BINARY_DIR}/SPIRV") |