CMakeLists.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Copyright (C) 2020-2023 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. if(GLSLANG_TESTS)
  34. if(TARGET gmock)
  35. message(STATUS "Google Mock found - building tests")
  36. set(TEST_SOURCES
  37. # Framework related source files
  38. ${CMAKE_CURRENT_SOURCE_DIR}/Initializer.h
  39. ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
  40. ${CMAKE_CURRENT_SOURCE_DIR}/Settings.cpp
  41. ${CMAKE_CURRENT_SOURCE_DIR}/Settings.h
  42. ${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.cpp
  43. ${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.h
  44. # Test related source files
  45. ${CMAKE_CURRENT_SOURCE_DIR}/AST.FromFile.cpp
  46. ${CMAKE_CURRENT_SOURCE_DIR}/BuiltInResource.FromFile.cpp
  47. ${CMAKE_CURRENT_SOURCE_DIR}/Common.cpp
  48. ${CMAKE_CURRENT_SOURCE_DIR}/Config.FromFile.cpp
  49. ${CMAKE_CURRENT_SOURCE_DIR}/HexFloat.cpp
  50. ${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp
  51. ${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
  52. ${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp
  53. ${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
  54. ${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp
  55. ${CMAKE_CURRENT_SOURCE_DIR}/VkRelaxed.FromFile.cpp
  56. ${CMAKE_CURRENT_SOURCE_DIR}/GlslMapIO.FromFile.cpp)
  57. if(ENABLE_SPVREMAPPER)
  58. set(TEST_SOURCES ${TEST_SOURCES}
  59. ${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
  60. endif()
  61. add_executable(glslangtests ${TEST_SOURCES})
  62. glslang_pch(glslangtests ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
  63. set_property(TARGET glslangtests PROPERTY FOLDER tests)
  64. glslang_set_link_args(glslangtests)
  65. set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
  66. # Supply a default test root directory, so that manual testing
  67. # doesn't have to specify the --test-root option in the normal
  68. # case that you want to use the tests from the same source tree.
  69. target_compile_definitions(glslangtests
  70. PRIVATE GLSLANG_TEST_DIRECTORY="${GLSLANG_TEST_DIRECTORY}")
  71. target_include_directories(glslangtests PRIVATE
  72. ${CMAKE_CURRENT_SOURCE_DIR}
  73. ${PROJECT_SOURCE_DIR}
  74. ${gmock_SOURCE_DIR}/include
  75. ${gtest_SOURCE_DIR}/include)
  76. if(ENABLE_OPT)
  77. target_link_libraries(glslangtests
  78. PRIVATE SPIRV-Tools-opt
  79. )
  80. endif()
  81. set(LIBRARIES
  82. glslang glslang-default-resource-limits)
  83. if(ENABLE_SPVREMAPPER)
  84. set(LIBRARIES ${LIBRARIES} SPVRemapper)
  85. endif()
  86. target_link_libraries(glslangtests PRIVATE ${LIBRARIES} gmock)
  87. add_test(NAME glslang-gtests
  88. COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}")
  89. endif()
  90. endif()