| 1 |
# Copyright (C) 2020 The Khronos Group Inc. |
| 2 |
# |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# Redistribution and use in source and binary forms, with or without |
| 6 |
# modification, are permitted provided that the following conditions |
| 7 |
# are met: |
| 8 |
# |
| 9 |
# Redistributions of source code must retain the above copyright |
| 10 |
# notice, this list of conditions and the following disclaimer. |
| 11 |
# |
| 12 |
# Redistributions in binary form must reproduce the above |
| 13 |
# copyright notice, this list of conditions and the following |
| 14 |
# disclaimer in the documentation and/or other materials provided |
| 15 |
# with the distribution. |
| 16 |
# |
| 17 |
# Neither the name of The Khronos Group Inc. nor the names of its |
| 18 |
# contributors may be used to endorse or promote products derived |
| 19 |
# from this software without specific prior written permission. |
| 20 |
# |
| 21 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 22 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 23 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 24 |
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 25 |
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 26 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 27 |
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 28 |
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 29 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 30 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 31 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 32 |
# POSSIBILITY OF SUCH DAMAGE. |
| 33 |
|
| 34 |
if(BUILD_TESTING) |
| 35 |
if(TARGET gmock) |
| 36 |
message(STATUS "Google Mock found - building tests") |
| 37 |
|
| 38 |
set(TEST_SOURCES |
| 39 |
# Framework related source files |
| 40 |
${CMAKE_CURRENT_SOURCE_DIR}/Initializer.h |
| 41 |
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp |
| 42 |
${CMAKE_CURRENT_SOURCE_DIR}/Settings.cpp |
| 43 |
${CMAKE_CURRENT_SOURCE_DIR}/Settings.h |
| 44 |
${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.cpp |
| 45 |
${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.h |
| 46 |
|
| 47 |
# Test related source files |
| 48 |
${CMAKE_CURRENT_SOURCE_DIR}/AST.FromFile.cpp |
| 49 |
${CMAKE_CURRENT_SOURCE_DIR}/BuiltInResource.FromFile.cpp |
| 50 |
${CMAKE_CURRENT_SOURCE_DIR}/Config.FromFile.cpp |
| 51 |
${CMAKE_CURRENT_SOURCE_DIR}/HexFloat.cpp |
| 52 |
${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp |
| 53 |
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp |
| 54 |
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp |
| 55 |
${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp |
| 56 |
${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp) |
| 57 |
|
| 58 |
if(ENABLE_SPVREMAPPER) |
| 59 |
set(TEST_SOURCES ${TEST_SOURCES} |
| 60 |
${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp) |
| 61 |
endif() |
| 62 |
|
| 63 |
|
| 64 |
add_executable(glslangtests ${TEST_SOURCES}) |
| 65 |
glslang_pch(glslangtests ${CMAKE_CURRENT_SOURCE_DIR}/pch.h) |
| 66 |
set_property(TARGET glslangtests PROPERTY FOLDER tests) |
| 67 |
glslang_set_link_args(glslangtests) |
| 68 |
if(ENABLE_GLSLANG_INSTALL) |
| 69 |
install(TARGETS glslangtests EXPORT glslangtestsTargets |
| 70 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 71 |
install(EXPORT glslangtestsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) |
| 72 |
endif(ENABLE_GLSLANG_INSTALL) |
| 73 |
|
| 74 |
set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test") |
| 75 |
# Supply a default test root directory, so that manual testing |
| 76 |
# doesn't have to specify the --test-root option in the normal |
| 77 |
# case that you want to use the tests from the same source tree. |
| 78 |
target_compile_definitions(glslangtests |
| 79 |
PRIVATE GLSLANG_TEST_DIRECTORY="${GLSLANG_TEST_DIRECTORY}") |
| 80 |
target_include_directories(glslangtests PRIVATE |
| 81 |
${CMAKE_CURRENT_SOURCE_DIR} |
| 82 |
${PROJECT_SOURCE_DIR} |
| 83 |
${gmock_SOURCE_DIR}/include |
| 84 |
${gtest_SOURCE_DIR}/include) |
| 85 |
|
| 86 |
if(ENABLE_OPT) |
| 87 |
target_include_directories(glslangtests |
| 88 |
PRIVATE ${spirv-tools_SOURCE_DIR}/include |
| 89 |
) |
| 90 |
endif(ENABLE_OPT) |
| 91 |
|
| 92 |
set(LIBRARIES |
| 93 |
glslang OSDependent OGLCompiler glslang |
| 94 |
SPIRV glslang-default-resource-limits) |
| 95 |
|
| 96 |
if(ENABLE_SPVREMAPPER) |
| 97 |
set(LIBRARIES ${LIBRARIES} SPVRemapper) |
| 98 |
endif() |
| 99 |
|
| 100 |
if(ENABLE_HLSL) |
| 101 |
set(LIBRARIES ${LIBRARIES} HLSL) |
| 102 |
endif(ENABLE_HLSL) |
| 103 |
target_link_libraries(glslangtests PRIVATE ${LIBRARIES} gmock) |
| 104 |
|
| 105 |
add_test(NAME glslang-gtests |
| 106 |
COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}") |
| 107 |
endif() |
| 108 |
endif() |