1 # Copyright (C) 2020 The Khronos Group Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
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.
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.
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.
36 message(STATUS "Google Mock found - building tests")
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
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}/Common.cpp
51 ${CMAKE_CURRENT_SOURCE_DIR}/Config.FromFile.cpp
52 ${CMAKE_CURRENT_SOURCE_DIR}/HexFloat.cpp
53 ${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp
54 ${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
55 ${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp
56 ${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
57 ${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp)
59 if(ENABLE_SPVREMAPPER)
60 set(TEST_SOURCES ${TEST_SOURCES}
61 ${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
65 add_executable(glslangtests ${TEST_SOURCES})
66 glslang_pch(glslangtests ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
67 set_property(TARGET glslangtests PROPERTY FOLDER tests)
68 glslang_set_link_args(glslangtests)
69 if(ENABLE_GLSLANG_INSTALL)
70 install(TARGETS glslangtests EXPORT glslangtestsTargets
71 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
72 install(EXPORT glslangtestsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
73 endif(ENABLE_GLSLANG_INSTALL)
75 set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
76 # Supply a default test root directory, so that manual testing
77 # doesn't have to specify the --test-root option in the normal
78 # case that you want to use the tests from the same source tree.
79 target_compile_definitions(glslangtests
80 PRIVATE GLSLANG_TEST_DIRECTORY="${GLSLANG_TEST_DIRECTORY}")
81 target_include_directories(glslangtests PRIVATE
82 ${CMAKE_CURRENT_SOURCE_DIR}
84 ${gmock_SOURCE_DIR}/include
85 ${gtest_SOURCE_DIR}/include)
88 target_include_directories(glslangtests
89 PRIVATE ${spirv-tools_SOURCE_DIR}/include
94 glslang OSDependent OGLCompiler glslang
95 SPIRV glslang-default-resource-limits)
97 if(ENABLE_SPVREMAPPER)
98 set(LIBRARIES ${LIBRARIES} SPVRemapper)
102 set(LIBRARIES ${LIBRARIES} HLSL)
104 target_link_libraries(glslangtests PRIVATE ${LIBRARIES} gmock)
106 add_test(NAME glslang-gtests
107 COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}")