From d6580c3dc008168cea0d7a12749b632264cbbffb Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Wed, 10 Jul 2024 11:07:57 -0400 Subject: [PATCH] Support use of external/system GTest installation (#1469) * Support use of system/external GTest installation * Create working directory for tests explicitly --- CMakeLists.txt | 8 +++++++- test/unit/CMakeLists.txt | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4933b6c929..3e764c89f0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,6 +133,7 @@ set(CUTLASS_ENABLE_PERFORMANCE ${CUTLASS_ENABLE_PROFILER} CACHE BOOL "Enable CUT set(CUTLASS_ENABLE_TESTS ${CUTLASS_ENABLE_TESTS_INIT} CACHE BOOL "Enable CUTLASS Tests") set(CUTLASS_ENABLE_GTEST_UNIT_TESTS ${CUTLASS_ENABLE_TESTS} CACHE BOOL "Enable CUTLASS GTest-based Unit Tests") +set(CUTLASS_USE_SYSTEM_GOOGLETEST OFF CACHE BOOL "Use system/external installation of GTest") ################################################################################ set(CUTLASS_NVCC_ARCHS_SUPPORTED "") @@ -702,7 +703,11 @@ include(CTest) enable_testing() if (CUTLASS_ENABLE_GTEST_UNIT_TESTS) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/googletest.cmake) + if (CUTLASS_USE_SYSTEM_GOOGLETEST) + find_package(GTest REQUIRED) + else() + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/googletest.cmake) + endif() endif() if (NOT TARGET test_all) @@ -747,6 +752,7 @@ set(CUTLASS_DEFAULT_ACTIVE_TEST_SETS "default" CACHE STRING "Default with CUTLASS_TEST_SETS environment variable when running the ctest executable.") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}") set(CUTLASS_CTEST_TEMPLATE_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/CTestTestfile.configure.cmake) set(CUTLASS_CTEST_GENERATED_FILES "" CACHE INTERNAL "") diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 16252a0aef..800ffc6857 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -42,7 +42,7 @@ target_link_libraries( CUTLASS cutlass_tools_util_includes $<$:nvidia::cublas> - gtest + GTest::gtest cudart cuda_driver ) @@ -84,7 +84,7 @@ function(cutlass_test_unit_add_executable NAME) target_link_libraries( ${NAME} PUBLIC - gtest + GTest::gtest ) else() target_link_libraries(