Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ if(ENABLE_GLSLANG_BINARIES)
add_subdirectory(StandAlone)
endif()

option(ALLOW_EXTERNAL_GTEST "Allows to build against installed googletest. This is unsupported if the commit isn't the one in known_good.json")
set(GMOCK_TARGET gmock)
if(NOT TARGET ${GMOCK_TARGET})
if(ALLOW_EXTERNAL_GTEST)
message(STATUS "Trying to find local googletest")
find_package(GTest)
if(TARGET GTest::gmock)
set(GMOCK_TARGET GTest::gmock)
endif()
endif()
endif()

if(GLSLANG_TESTS)
enable_testing()
add_subdirectory(gtests)
Expand Down
8 changes: 3 additions & 5 deletions gtests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# POSSIBILITY OF SUCH DAMAGE.

if(GLSLANG_TESTS)
if(TARGET gmock)
if(TARGET ${GMOCK_TARGET})
message(STATUS "Google Mock found - building tests")

set(TEST_SOURCES
Expand Down Expand Up @@ -76,9 +76,7 @@ if(GLSLANG_TESTS)
PRIVATE GLSLANG_TEST_BUILD=1)
target_include_directories(glslangtests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}
${gmock_SOURCE_DIR}/include
${gtest_SOURCE_DIR}/include)
${PROJECT_SOURCE_DIR})

if(ENABLE_OPT)
target_link_libraries(glslangtests
Expand All @@ -90,7 +88,7 @@ if(GLSLANG_TESTS)
glslang glslang-default-resource-limits
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>)

target_link_libraries(glslangtests PRIVATE ${LIBRARIES} gmock)
target_link_libraries(glslangtests PRIVATE ${LIBRARIES} ${GMOCK_TARGET})

# The TARGET_RUNTIME_DLL_DIRS feature requires CMake 3.27 or greater.
if(WIN32 AND BUILD_SHARED_LIBS AND CMAKE_VERSION VERSION_LESS "3.27")
Expand Down