1617a3babSopenharmony_ci# Copyright (C) 2020-2023 The Khronos Group Inc. 2617a3babSopenharmony_ci# 3617a3babSopenharmony_ci# All rights reserved. 4617a3babSopenharmony_ci# 5617a3babSopenharmony_ci# Redistribution and use in source and binary forms, with or without 6617a3babSopenharmony_ci# modification, are permitted provided that the following conditions 7617a3babSopenharmony_ci# are met: 8617a3babSopenharmony_ci# 9617a3babSopenharmony_ci# Redistributions of source code must retain the above copyright 10617a3babSopenharmony_ci# notice, this list of conditions and the following disclaimer. 11617a3babSopenharmony_ci# 12617a3babSopenharmony_ci# Redistributions in binary form must reproduce the above 13617a3babSopenharmony_ci# copyright notice, this list of conditions and the following 14617a3babSopenharmony_ci# disclaimer in the documentation and/or other materials provided 15617a3babSopenharmony_ci# with the distribution. 16617a3babSopenharmony_ci# 17617a3babSopenharmony_ci# Neither the name of The Khronos Group Inc. nor the names of its 18617a3babSopenharmony_ci# contributors may be used to endorse or promote products derived 19617a3babSopenharmony_ci# from this software without specific prior written permission. 20617a3babSopenharmony_ci# 21617a3babSopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22617a3babSopenharmony_ci# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23617a3babSopenharmony_ci# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24617a3babSopenharmony_ci# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25617a3babSopenharmony_ci# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26617a3babSopenharmony_ci# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27617a3babSopenharmony_ci# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28617a3babSopenharmony_ci# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29617a3babSopenharmony_ci# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30617a3babSopenharmony_ci# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31617a3babSopenharmony_ci# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32617a3babSopenharmony_ci# POSSIBILITY OF SUCH DAMAGE. 33617a3babSopenharmony_cicmake_minimum_required(VERSION 3.17.2) 34617a3babSopenharmony_ciproject(glslang) 35617a3babSopenharmony_ci 36617a3babSopenharmony_ciif (CMAKE_VERSION VERSION_LESS "3.21") 37617a3babSopenharmony_ci # https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html 38617a3babSopenharmony_ci string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL) 39617a3babSopenharmony_ciendif() 40617a3babSopenharmony_ci 41617a3babSopenharmony_ciset_property(GLOBAL PROPERTY USE_FOLDERS ON) 42617a3babSopenharmony_ci 43617a3babSopenharmony_ci# Adhere to GNU filesystem layout conventions 44617a3babSopenharmony_ciinclude(GNUInstallDirs) 45617a3babSopenharmony_ciinclude(CMakePackageConfigHelpers) 46617a3babSopenharmony_ci 47617a3babSopenharmony_ci# Needed for CMAKE_DEPENDENT_OPTION macro 48617a3babSopenharmony_ciinclude(CMakeDependentOption) 49617a3babSopenharmony_ci 50617a3babSopenharmony_cioption(BUILD_SHARED_LIBS "Build Shared Libraries") 51617a3babSopenharmony_cioption(BUILD_EXTERNAL "Build external dependencies in /External" ON) 52617a3babSopenharmony_cioption(BUILD_WERROR "Enable warnings as errors (default is OFF)" OFF) 53617a3babSopenharmony_ci 54617a3babSopenharmony_ciset(LIB_TYPE STATIC) 55617a3babSopenharmony_ci 56617a3babSopenharmony_ciif(BUILD_SHARED_LIBS) 57617a3babSopenharmony_ci set(LIB_TYPE SHARED) 58617a3babSopenharmony_ciendif() 59617a3babSopenharmony_ci 60617a3babSopenharmony_ciif ("${CMAKE_BUILD_TYPE}" STREQUAL "") 61617a3babSopenharmony_ci # This logic inside SPIRV-Tools, which can upset build target dependencies 62617a3babSopenharmony_ci # if changed after targets are already defined. To prevent these issues, 63617a3babSopenharmony_ci # ensure CMAKE_BUILD_TYPE is assigned early and at the glslang root scope. 64617a3babSopenharmony_ci message(STATUS "No build type selected, default to Debug") 65617a3babSopenharmony_ci set(CMAKE_BUILD_TYPE "Debug") 66617a3babSopenharmony_ciendif() 67617a3babSopenharmony_ci 68617a3babSopenharmony_ci# Currently iOS and Android are very similar. 69617a3babSopenharmony_ci# They both have their own packaging (APP/APK). 70617a3babSopenharmony_ci# Which makes regular executables/testing problematic. 71617a3babSopenharmony_ci# 72617a3babSopenharmony_ci# Currently the only deliverables for these platforms are 73617a3babSopenharmony_ci# libraries (either STATIC or SHARED). 74617a3babSopenharmony_ci# 75617a3babSopenharmony_ci# Furthermore testing is equally problematic. 76617a3babSopenharmony_ciif (IOS OR ANDROID) 77617a3babSopenharmony_ci set(ENABLE_GLSLANG_BINARIES OFF) 78617a3babSopenharmony_ci set(GLSLANG_TESTS OFF) 79617a3babSopenharmony_ciendif() 80617a3babSopenharmony_ci 81617a3babSopenharmony_cioption(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" ON) 82617a3babSopenharmony_ci 83617a3babSopenharmony_cioption(ENABLE_GLSLANG_BINARIES "Builds glslang and spirv-remap" ON) 84617a3babSopenharmony_ci 85617a3babSopenharmony_cioption(ENABLE_GLSLANG_JS "If using Emscripten, build glslang.js. Otherwise, builds a sample executable for binary-size testing.") 86617a3babSopenharmony_ciCMAKE_DEPENDENT_OPTION(ENABLE_EMSCRIPTEN_SINGLE_FILE 87617a3babSopenharmony_ci "If using Emscripten, enables SINGLE_FILE build" 88617a3babSopenharmony_ci OFF "ENABLE_GLSLANG_JS AND EMSCRIPTEN" 89617a3babSopenharmony_ci OFF) 90617a3babSopenharmony_ciCMAKE_DEPENDENT_OPTION(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE 91617a3babSopenharmony_ci "If using Emscripten, builds to run on Node instead of Web" 92617a3babSopenharmony_ci OFF "ENABLE_GLSLANG_JS AND EMSCRIPTEN" 93617a3babSopenharmony_ci OFF) 94617a3babSopenharmony_ci 95617a3babSopenharmony_cioption(ENABLE_HLSL "Enables HLSL input support" ON) 96617a3babSopenharmony_cioption(ENABLE_RTTI "Enables RTTI") 97617a3babSopenharmony_cioption(ENABLE_EXCEPTIONS "Enables Exceptions") 98617a3babSopenharmony_cioption(ENABLE_OPT "Enables spirv-opt capability if present" ON) 99617a3babSopenharmony_ci 100617a3babSopenharmony_ciif(MINGW OR (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")) 101617a3babSopenharmony_ci # Workaround for CMake behavior on Mac OS with gcc, cmake generates -Xarch_* arguments 102617a3babSopenharmony_ci # which gcc rejects 103617a3babSopenharmony_ci set(ENABLE_PCH OFF) 104617a3babSopenharmony_ci message(NOTICE "Disabling PCH") 105617a3babSopenharmony_ciendif() 106617a3babSopenharmony_ci 107617a3babSopenharmony_cioption(ENABLE_PCH "Enables Precompiled header" ON) 108617a3babSopenharmony_ci 109617a3babSopenharmony_ciif(ENABLE_HLSL) 110617a3babSopenharmony_ci add_compile_definitions(ENABLE_HLSL) 111617a3babSopenharmony_ciendif() 112617a3babSopenharmony_ci 113617a3babSopenharmony_ciif(WIN32) 114617a3babSopenharmony_ci set(CMAKE_DEBUG_POSTFIX "d") 115617a3babSopenharmony_ci add_definitions(-DGLSLANG_OSINCLUDE_WIN32) 116617a3babSopenharmony_cielseif(UNIX OR ANDROID) 117617a3babSopenharmony_ci add_definitions(-DGLSLANG_OSINCLUDE_UNIX) 118617a3babSopenharmony_cielse() 119617a3babSopenharmony_ci message("unknown platform") 120617a3babSopenharmony_ciendif() 121617a3babSopenharmony_ci 122617a3babSopenharmony_ciif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") 123617a3babSopenharmony_ci add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs 124617a3babSopenharmony_ci -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions) 125617a3babSopenharmony_ci if(NOT ENABLE_RTTI) 126617a3babSopenharmony_ci add_compile_options(-fno-rtti) 127617a3babSopenharmony_ci endif() 128617a3babSopenharmony_ci if(NOT ENABLE_EXCEPTIONS) 129617a3babSopenharmony_ci add_compile_options(-fno-exceptions) 130617a3babSopenharmony_ci endif() 131617a3babSopenharmony_ci if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0") 132617a3babSopenharmony_ci add_compile_options(-Werror=deprecated-copy) 133617a3babSopenharmony_ci endif() 134617a3babSopenharmony_ci 135617a3babSopenharmony_ci if(NOT (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")) 136617a3babSopenharmony_ci if (NOT APPLE) 137617a3babSopenharmony_ci # Error if there's symbols that are not found at link time. 138617a3babSopenharmony_ci add_link_options("-Wl,--no-undefined") 139617a3babSopenharmony_ci endif() 140617a3babSopenharmony_ci endif() 141617a3babSopenharmony_cielseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC) 142617a3babSopenharmony_ci add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs 143617a3babSopenharmony_ci -Wunused-parameter -Wunused-value -Wunused-variable) 144617a3babSopenharmony_ci if(NOT ENABLE_RTTI) 145617a3babSopenharmony_ci add_compile_options(-fno-rtti) 146617a3babSopenharmony_ci endif() 147617a3babSopenharmony_ci if(NOT ENABLE_EXCEPTIONS) 148617a3babSopenharmony_ci add_compile_options(-fno-exceptions) 149617a3babSopenharmony_ci endif() 150617a3babSopenharmony_ci 151617a3babSopenharmony_ci if(NOT (CMAKE_SYSTEM_NAME MATCHES "OpenBSD|Emscripten")) 152617a3babSopenharmony_ci # Error if there's symbols that are not found at link time. Some linkers do not support this flag. 153617a3babSopenharmony_ci if(NOT APPLE) 154617a3babSopenharmony_ci add_link_options("-Wl,--no-undefined") 155617a3babSopenharmony_ci endif() 156617a3babSopenharmony_ci endif() 157617a3babSopenharmony_cielseif(MSVC) 158617a3babSopenharmony_ci if(NOT ENABLE_RTTI) 159617a3babSopenharmony_ci string(FIND "${CMAKE_CXX_FLAGS}" "/GR" MSVC_HAS_GR) 160617a3babSopenharmony_ci if(MSVC_HAS_GR) 161617a3babSopenharmony_ci string(REGEX REPLACE "/GR" "/GR-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 162617a3babSopenharmony_ci else() 163617a3babSopenharmony_ci add_compile_options(/GR-) # Disable RTTI 164617a3babSopenharmony_ci endif() 165617a3babSopenharmony_ci endif() 166617a3babSopenharmony_ci if(ENABLE_EXCEPTIONS) 167617a3babSopenharmony_ci add_compile_options(/EHsc) # Enable Exceptions 168617a3babSopenharmony_ci else() 169617a3babSopenharmony_ci string(REGEX REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Try to remove default /EHsc cxx_flag 170617a3babSopenharmony_ci add_compile_options(/D_HAS_EXCEPTIONS=0) 171617a3babSopenharmony_ci endif() 172617a3babSopenharmony_ciendif() 173617a3babSopenharmony_ci 174617a3babSopenharmony_ci# NOTE we could potentially replace this logic with COMPILE_WARNING_AS_ERROR if cmake minimum is bumped to >= 3.24 175617a3babSopenharmony_ciif (BUILD_WERROR) 176617a3babSopenharmony_ci if (NOT MSVC) 177617a3babSopenharmony_ci add_compile_options(-Werror) 178617a3babSopenharmony_ci else() 179617a3babSopenharmony_ci add_compile_options(/WX) 180617a3babSopenharmony_ci endif() 181617a3babSopenharmony_ciendif() 182617a3babSopenharmony_ci 183617a3babSopenharmony_ciif(ENABLE_GLSLANG_JS) 184617a3babSopenharmony_ci if(MSVC) 185617a3babSopenharmony_ci add_compile_options(/Os /GR-) 186617a3babSopenharmony_ci else() 187617a3babSopenharmony_ci add_compile_options(-Os -fno-rtti -fno-exceptions) 188617a3babSopenharmony_ci if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC) 189617a3babSopenharmony_ci add_compile_options(-Wno-unused-parameter) 190617a3babSopenharmony_ci add_compile_options(-Wno-unused-variable -Wno-unused-const-variable) 191617a3babSopenharmony_ci endif() 192617a3babSopenharmony_ci endif() 193617a3babSopenharmony_ciendif() 194617a3babSopenharmony_ci 195617a3babSopenharmony_ci# Request C++17 196617a3babSopenharmony_ciset(CMAKE_CXX_STANDARD 17) 197617a3babSopenharmony_ciset(CMAKE_CXX_STANDARD_REQUIRED ON) 198617a3babSopenharmony_ciset(CMAKE_CXX_EXTENSIONS OFF) 199617a3babSopenharmony_ci 200617a3babSopenharmony_cifunction(glslang_set_link_args TARGET) 201617a3babSopenharmony_ci # For MinGW compiles, statically link against the GCC and C++ runtimes. 202617a3babSopenharmony_ci # This avoids the need to ship those runtimes as DLLs. 203617a3babSopenharmony_ci # This is supported by GCC and Clang. 204617a3babSopenharmony_ci if(WIN32 AND NOT MSVC) 205617a3babSopenharmony_ci set_target_properties(${TARGET} PROPERTIES 206617a3babSopenharmony_ci LINK_FLAGS "-static -static-libgcc -static-libstdc++") 207617a3babSopenharmony_ci endif() 208617a3babSopenharmony_ciendfunction(glslang_set_link_args) 209617a3babSopenharmony_ci 210617a3babSopenharmony_ci# Root directory for build-time generated include files 211617a3babSopenharmony_ciset(GLSLANG_GENERATED_INCLUDEDIR "${CMAKE_BINARY_DIR}/include") 212617a3babSopenharmony_ci 213617a3babSopenharmony_ci################################################################################ 214617a3babSopenharmony_ci# Build version information generation 215617a3babSopenharmony_ci################################################################################ 216617a3babSopenharmony_ciinclude(parse_version.cmake) 217617a3babSopenharmony_ciset(GLSLANG_CHANGES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES.md") 218617a3babSopenharmony_ciset(GLSLANG_BUILD_INFO_H_TMPL "${CMAKE_CURRENT_SOURCE_DIR}/build_info.h.tmpl") 219617a3babSopenharmony_ciset(GLSLANG_BUILD_INFO_H "${GLSLANG_GENERATED_INCLUDEDIR}/glslang/build_info.h") 220617a3babSopenharmony_ci 221617a3babSopenharmony_ciparse_version(${GLSLANG_CHANGES_FILE} GLSLANG) 222617a3babSopenharmony_ci 223617a3babSopenharmony_cifunction(configurate_version) 224617a3babSopenharmony_ci set(major ${GLSLANG_VERSION_MAJOR}) 225617a3babSopenharmony_ci set(minor ${GLSLANG_VERSION_MINOR}) 226617a3babSopenharmony_ci set(patch ${GLSLANG_VERSION_PATCH}) 227617a3babSopenharmony_ci set(flavor ${GLSLANG_VERSION_FLAVOR}) 228617a3babSopenharmony_ci configure_file(${GLSLANG_BUILD_INFO_H_TMPL} ${GLSLANG_BUILD_INFO_H} @ONLY) 229617a3babSopenharmony_ciendfunction() 230617a3babSopenharmony_ci 231617a3babSopenharmony_ciconfigurate_version() 232617a3babSopenharmony_ci 233617a3babSopenharmony_ci# glslang_add_build_info_dependency() adds the glslang-build-info dependency and 234617a3babSopenharmony_ci# generated include directories to target. 235617a3babSopenharmony_cifunction(glslang_add_build_info_dependency target) 236617a3babSopenharmony_ci target_include_directories(${target} PUBLIC $<BUILD_INTERFACE:${GLSLANG_GENERATED_INCLUDEDIR}>) 237617a3babSopenharmony_ciendfunction() 238617a3babSopenharmony_ci 239617a3babSopenharmony_ci# glslang_only_export_explicit_symbols() makes the symbol visibility hidden by 240617a3babSopenharmony_ci# default for <target> when building shared libraries, and sets the 241617a3babSopenharmony_ci# GLSLANG_IS_SHARED_LIBRARY define, and GLSLANG_EXPORTING to 1 when specifically 242617a3babSopenharmony_ci# building <target>. 243617a3babSopenharmony_cifunction(glslang_only_export_explicit_symbols target) 244617a3babSopenharmony_ci if(BUILD_SHARED_LIBS) 245617a3babSopenharmony_ci target_compile_definitions(${target} PUBLIC "GLSLANG_IS_SHARED_LIBRARY=1") 246617a3babSopenharmony_ci set_target_properties(${target} PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden) 247617a3babSopenharmony_ci if(WIN32) 248617a3babSopenharmony_ci target_compile_definitions(${target} PRIVATE "GLSLANG_EXPORTING=1") 249617a3babSopenharmony_ci endif() 250617a3babSopenharmony_ci endif() 251617a3babSopenharmony_ciendfunction() 252617a3babSopenharmony_ci 253617a3babSopenharmony_ci# glslang_pch() adds precompiled header rules to <target> for the pre-compiled 254617a3babSopenharmony_ci# header file <pch>. As target_precompile_headers() was added in CMake 3.16, 255617a3babSopenharmony_ci# this is a no-op if called on earlier versions of CMake. 256617a3babSopenharmony_cifunction(glslang_pch target pch) 257617a3babSopenharmony_ci if(ENABLE_PCH) 258617a3babSopenharmony_ci target_precompile_headers(${target} PRIVATE ${pch}) 259617a3babSopenharmony_ci endif() 260617a3babSopenharmony_ciendfunction() 261617a3babSopenharmony_ci 262617a3babSopenharmony_ciif(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External) 263617a3babSopenharmony_ci # We depend on these for later projects, so they should come first. 264617a3babSopenharmony_ci add_subdirectory(External) 265617a3babSopenharmony_ciendif() 266617a3babSopenharmony_ci 267617a3babSopenharmony_cioption(ALLOW_EXTERNAL_SPIRV_TOOLS "Allows to build against installed SPIRV-Tools-opt") 268617a3babSopenharmony_ciif(NOT TARGET SPIRV-Tools-opt) 269617a3babSopenharmony_ci if(ALLOW_EXTERNAL_SPIRV_TOOLS) 270617a3babSopenharmony_ci # Look for external SPIR-V Tools build, if not building in-tree 271617a3babSopenharmony_ci message(STATUS "Trying to find local SPIR-V tools") 272617a3babSopenharmony_ci find_package(SPIRV-Tools-opt) 273617a3babSopenharmony_ci if(NOT TARGET SPIRV-Tools-opt) 274617a3babSopenharmony_ci if(ENABLE_OPT) 275617a3babSopenharmony_ci message(WARNING "ENABLE_OPT set but SPIR-V tools not found! Disabling SPIR-V optimization.") 276617a3babSopenharmony_ci endif() 277617a3babSopenharmony_ci set(ENABLE_OPT OFF) 278617a3babSopenharmony_ci endif() 279617a3babSopenharmony_ci else() 280617a3babSopenharmony_ci if(ENABLE_OPT) 281617a3babSopenharmony_ci message(SEND_ERROR "ENABLE_OPT set but SPIR-V tools not found. Please run update_glslang_sources.py, " 282617a3babSopenharmony_ci "set the ALLOW_EXTERNAL_SPIRV_TOOLS option to use a local install of SPIRV-Tools, or set ENABLE_OPT=0.") 283617a3babSopenharmony_ci endif() 284617a3babSopenharmony_ci endif() 285617a3babSopenharmony_ciendif() 286617a3babSopenharmony_ci 287617a3babSopenharmony_ciif(ENABLE_OPT) 288617a3babSopenharmony_ci message(STATUS "optimizer enabled") 289617a3babSopenharmony_ci add_definitions(-DENABLE_OPT=1) 290617a3babSopenharmony_cielse() 291617a3babSopenharmony_ci if(ENABLE_HLSL) 292617a3babSopenharmony_ci message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL") 293617a3babSopenharmony_ci endif() 294617a3babSopenharmony_ci add_definitions(-DENABLE_OPT=0) 295617a3babSopenharmony_ciendif() 296617a3babSopenharmony_ci 297617a3babSopenharmony_ciadd_subdirectory(glslang) 298617a3babSopenharmony_ciif(ENABLE_GLSLANG_BINARIES) 299617a3babSopenharmony_ci add_subdirectory(StandAlone) 300617a3babSopenharmony_ciendif() 301617a3babSopenharmony_ciadd_subdirectory(SPIRV) 302617a3babSopenharmony_ci 303617a3babSopenharmony_ci# Testing / installation only makes sense when the project is top level. 304617a3babSopenharmony_ci# 305617a3babSopenharmony_ci# Otherwise add_subdirectory users have a harder time consuming the library. 306617a3babSopenharmony_ci# Since glslang will pollute the installation and add undesirable testing. 307617a3babSopenharmony_ciif(PROJECT_IS_TOP_LEVEL) 308617a3babSopenharmony_ci option(GLSLANG_TESTS "Enable glslang testing") 309617a3babSopenharmony_ci if(GLSLANG_TESTS) 310617a3babSopenharmony_ci enable_testing() 311617a3babSopenharmony_ci add_subdirectory(gtests) 312617a3babSopenharmony_ci 313617a3babSopenharmony_ci # glslang-testsuite runs a bash script on Windows. 314617a3babSopenharmony_ci # Make sure to use '-o igncr' flag to ignore carriage returns (\r). 315617a3babSopenharmony_ci set(IGNORE_CR_FLAG "") 316617a3babSopenharmony_ci if(WIN32) 317617a3babSopenharmony_ci set(IGNORE_CR_FLAG -o igncr) 318617a3babSopenharmony_ci endif() 319617a3babSopenharmony_ci 320617a3babSopenharmony_ci if (CMAKE_CONFIGURATION_TYPES) 321617a3babSopenharmony_ci set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/localResults) 322617a3babSopenharmony_ci set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIG>/glslang) 323617a3babSopenharmony_ci set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIG>/spirv-remap) 324617a3babSopenharmony_ci else() 325617a3babSopenharmony_ci set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/localResults) 326617a3babSopenharmony_ci set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/glslang) 327617a3babSopenharmony_ci set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/spirv-remap) 328617a3babSopenharmony_ci endif() 329617a3babSopenharmony_ci 330617a3babSopenharmony_ci add_test(NAME glslang-testsuite 331617a3babSopenharmony_ci COMMAND bash ${IGNORE_CR_FLAG} runtests ${RESULTS_PATH} ${VALIDATOR_PATH} ${REMAP_PATH} 332617a3babSopenharmony_ci WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Test/) 333617a3babSopenharmony_ci endif() 334617a3babSopenharmony_ci 335617a3babSopenharmony_ci file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake.in" [=[ 336617a3babSopenharmony_ci @PACKAGE_INIT@ 337617a3babSopenharmony_ci @INSTALL_CONFIG_UNIX@ 338617a3babSopenharmony_ci include("@PACKAGE_PATH_EXPORT_TARGETS@") 339617a3babSopenharmony_ci ]=]) 340617a3babSopenharmony_ci 341617a3babSopenharmony_ci set(PATH_EXPORT_TARGETS "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/glslang-targets.cmake") 342617a3babSopenharmony_ci if(UNIX OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") 343617a3babSopenharmony_ci set(INSTALL_CONFIG_UNIX [=[ 344617a3babSopenharmony_ci include(CMakeFindDependencyMacro) 345617a3babSopenharmony_ci set(THREADS_PREFER_PTHREAD_FLAG ON) 346617a3babSopenharmony_ci find_dependency(Threads REQUIRED) 347617a3babSopenharmony_ci ]=]) 348617a3babSopenharmony_ci endif() 349617a3babSopenharmony_ci configure_package_config_file( 350617a3babSopenharmony_ci "${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake.in" 351617a3babSopenharmony_ci "${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake" 352617a3babSopenharmony_ci PATH_VARS 353617a3babSopenharmony_ci PATH_EXPORT_TARGETS 354617a3babSopenharmony_ci INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} 355617a3babSopenharmony_ci ) 356617a3babSopenharmony_ci 357617a3babSopenharmony_ci write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/glslang-config-version.cmake" 358617a3babSopenharmony_ci VERSION ${GLSLANG_VERSION} 359617a3babSopenharmony_ci COMPATIBILITY SameMajorVersion 360617a3babSopenharmony_ci ) 361617a3babSopenharmony_ci 362617a3babSopenharmony_ci install( 363617a3babSopenharmony_ci EXPORT glslang-targets 364617a3babSopenharmony_ci NAMESPACE "glslang::" 365617a3babSopenharmony_ci DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" 366617a3babSopenharmony_ci ) 367617a3babSopenharmony_ci 368617a3babSopenharmony_ci install( 369617a3babSopenharmony_ci FILES 370617a3babSopenharmony_ci "${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake" 371617a3babSopenharmony_ci "${CMAKE_CURRENT_BINARY_DIR}/glslang-config-version.cmake" 372617a3babSopenharmony_ci DESTINATION 373617a3babSopenharmony_ci "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" 374617a3babSopenharmony_ci ) 375617a3babSopenharmony_ciendif() 376