Merge pull request #1940 from tsuoranta/fix-gcc9
[platform/upstream/glslang.git] / gtests / CMakeLists.txt
1 if(BUILD_TESTING)
2     if(TARGET gmock)
3         message(STATUS "Google Mock found - building tests")
4
5         set(TEST_SOURCES
6             # Framework related source files
7             ${CMAKE_CURRENT_SOURCE_DIR}/Initializer.h
8             ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
9             ${CMAKE_CURRENT_SOURCE_DIR}/Settings.cpp
10             ${CMAKE_CURRENT_SOURCE_DIR}/Settings.h
11             ${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.cpp
12             ${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.h
13
14             # Test related source files
15             ${CMAKE_CURRENT_SOURCE_DIR}/AST.FromFile.cpp
16             ${CMAKE_CURRENT_SOURCE_DIR}/BuiltInResource.FromFile.cpp
17             ${CMAKE_CURRENT_SOURCE_DIR}/Config.FromFile.cpp
18             ${CMAKE_CURRENT_SOURCE_DIR}/HexFloat.cpp
19             ${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp
20             ${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
21             ${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp
22             ${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
23             ${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp)
24
25         if(ENABLE_SPVREMAPPER)
26             set(TEST_SOURCES ${TEST_SOURCES}
27                 ${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
28         endif()
29
30         glslang_pch(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp)
31
32         add_executable(glslangtests ${TEST_SOURCES})
33         set_property(TARGET glslangtests PROPERTY FOLDER tests)
34         glslang_set_link_args(glslangtests)
35         if(ENABLE_GLSLANG_INSTALL)
36             install(TARGETS glslangtests EXPORT glslangtestsTargets
37                     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
38                         install(EXPORT glslangtestsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
39         endif(ENABLE_GLSLANG_INSTALL)
40
41         set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
42         # Supply a default test root directory, so that manual testing
43         # doesn't have to specify the --test-root option in the normal
44         # case that you want to use the tests from the same source tree.
45         target_compile_definitions(glslangtests
46                                    PRIVATE GLSLANG_TEST_DIRECTORY="${GLSLANG_TEST_DIRECTORY}")
47         target_include_directories(glslangtests PRIVATE
48                                    ${CMAKE_CURRENT_SOURCE_DIR}
49                                    ${PROJECT_SOURCE_DIR}
50                                    ${gmock_SOURCE_DIR}/include
51                                    ${gtest_SOURCE_DIR}/include)
52
53         set(LIBRARIES
54             glslang OSDependent OGLCompiler glslang
55             SPIRV glslang-default-resource-limits)
56
57         if(ENABLE_SPVREMAPPER)
58             set(LIBRARIES ${LIBRARIES} SPVRemapper)
59         endif()
60
61         if(ENABLE_HLSL)
62             set(LIBRARIES ${LIBRARIES} HLSL)
63         endif(ENABLE_HLSL)
64         target_link_libraries(glslangtests PRIVATE ${LIBRARIES} gmock)
65
66         add_test(NAME glslang-gtests
67                  COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}")
68     endif()
69 endif()