aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/nextpnr-gtest.patch
blob: e940bd51c5b72b3d9d5ac7535d61394c4f1fe32c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Upstream-status: https://github.com/YosysHQ/nextpnr/pull/1478

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47d60330..88463984 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -217,7 +217,13 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/3rdparty/sanitizers-cmake/cmake" ${CM
 find_package(Sanitizers)
 
 if (BUILD_TESTS)
-    add_subdirectory(3rdparty/googletest/googletest EXCLUDE_FROM_ALL)
+    find_package(GTest)
+    if(GTest_FOUND)
+        add_library(gtest_main ALIAS GTest::gtest_main)
+    else()
+        add_subdirectory(3rdparty/googletest/googletest EXCLUDE_FROM_ALL)
+        set(gtest_include_dir ${CMAKE_SOURCE_DIR}/3rdparty/googletest/googletest/include)
+    endif()
     enable_testing()
 endif()
 
@@ -366,7 +372,7 @@ function(add_nextpnr_architecture target)
         add_executable(nextpnr-${target}-test ${arg_TEST_SOURCES})
         set_property(TARGET nextpnr-${target}-test PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
 
-        target_include_directories(nextpnr-${target}-test PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/googletest/googletest/include)
+        target_include_directories(nextpnr-${target}-test PRIVATE gtest_include_dir)
 
         target_link_libraries(nextpnr-${target}-test PRIVATE gtest_main nextpnr-${target}-core)
         if (BUILD_GUI)