diff --git a/etc/DependencyInstaller.sh b/etc/DependencyInstaller.sh index 6a92a7d4608..0ba712d6e8d 100755 --- a/etc/DependencyInstaller.sh +++ b/etc/DependencyInstaller.sh @@ -75,6 +75,9 @@ _installCommonDev() { cuddVersion=3.0.0 lemonVersion=1.3.1 spdlogVersion=1.8.1 + gtestVersion=1.13.0 + gtestChecksum="a1279c6fb5bf7d4a5e0d0b2a4adb39ac" + rm -rf "${baseDir}" mkdir -p "${baseDir}" @@ -201,6 +204,22 @@ _installCommonDev() { echo "spdlog already installed." fi + # gtest + gtestPrefix=${PREFIX:-"/usr/local"} + if [[ ! -d ${gtestPrefix}/include/gtest ]]; then + cd "${baseDir}" + wget https://github.com/google/googletest/archive/refs/tags/v${gtestVersion}.zip + md5sum -c <(echo "${gtestChecksum} v${gtestVersion}.zip") || exit 1 + unzip v${gtestVersion}.zip + cd googletest-${gtestVersion} + ${cmakePrefix}/bin/cmake -DCMAKE_INSTALL_PREFIX="${gtestPrefix}" -B build . + # FIXME: The override does not work if a system gtest is present so something more should be done + # Conversely our install will still be used if a system gtest is install afterwards + ${cmakePrefix}/bin/cmake --build build --target install + else + echo "gtest already installed." + fi + if [[ ${equivalenceDeps} == "yes" ]]; then _equivalenceDeps fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ff954a6dfb..f1ecea31ce1 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -174,6 +174,12 @@ include(UseSWIG) find_package(Boost REQUIRED) message(STATUS "boost: ${Boost_VERSION}") + +if (ENABLE_TESTS) + find_package(GTest REQUIRED) + message(STATUS "GTest: ${GTest_VERSION}") +endif() + find_package(Python3 COMPONENTS Development REQUIRED) option(BUILD_PYTHON "Build the Python3 interface" ON) diff --git a/src/cts/test/CMakeLists.txt b/src/cts/test/CMakeLists.txt index e3781819ad0..5f2087ae2df 100644 --- a/src/cts/test/CMakeLists.txt +++ b/src/cts/test/CMakeLists.txt @@ -39,8 +39,8 @@ target_include_directories(cts_unittest ) target_link_libraries(cts_unittest - gtest - gtest_main + GTest::gtest + GTest::gtest_main cts_lib utl_lib dbSta_lib diff --git a/src/dft/test/cpp/CMakeLists.txt b/src/dft/test/cpp/CMakeLists.txt index 58559d4e66d..3c963ae76b4 100644 --- a/src/dft/test/cpp/CMakeLists.txt +++ b/src/dft/test/cpp/CMakeLists.txt @@ -1,9 +1,9 @@ include("openroad") set(TEST_LIBS - gtest - gmock - gtest_main + GTest::gtest + GTest::gtest_main + GTest::gmock odb dft_base_scan_cell_lib dft_config_lib diff --git a/src/dpl/test/CMakeLists.txt b/src/dpl/test/CMakeLists.txt index 007cb0c2122..e17d063148e 100644 --- a/src/dpl/test/CMakeLists.txt +++ b/src/dpl/test/CMakeLists.txt @@ -77,9 +77,9 @@ endforeach() add_executable(dpl_test dpl_test.cc) -target_link_libraries(dpl_test - gtest - gtest_main +target_link_libraries(dpl_test + GTest::gtest + GTest::gtest_main dpl_lib ) diff --git a/src/gpl/test/CMakeLists.txt b/src/gpl/test/CMakeLists.txt index 6617fc1acf4..ddd56e52dec 100644 --- a/src/gpl/test/CMakeLists.txt +++ b/src/gpl/test/CMakeLists.txt @@ -44,8 +44,8 @@ target_include_directories(fft_test ) target_link_libraries(fft_test - gtest - gtest_main + GTest::gtest + GTest::gtest_main spdlog::spdlog ) diff --git a/src/mpl2/test/cpp/CMakeLists.txt b/src/mpl2/test/cpp/CMakeLists.txt index e06fac37cdf..f5c3a3eb5e3 100644 --- a/src/mpl2/test/cpp/CMakeLists.txt +++ b/src/mpl2/test/cpp/CMakeLists.txt @@ -7,9 +7,9 @@ include("openroad") set(TEST_LIBS - gtest - gmock - gtest_main + GTest::gtest + GTest::gtest_main + GTest::gmock odb mpl2_lib ) @@ -19,9 +19,9 @@ target_link_libraries(TestSnapper ${TEST_LIBS}) gtest_discover_tests(TestSnapper WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) add_executable(mpl2_test mpl2_test.cc) -target_link_libraries(mpl2_test - gtest - gtest_main +target_link_libraries(mpl2_test + GTest::gtest + GTest::gtest_main mpl2_lib ) gtest_discover_tests(mpl2_test diff --git a/src/odb/test/cpp/scan/CMakeLists.txt b/src/odb/test/cpp/scan/CMakeLists.txt index 2701a438db8..ac1ffa49e1c 100644 --- a/src/odb/test/cpp/scan/CMakeLists.txt +++ b/src/odb/test/cpp/scan/CMakeLists.txt @@ -11,9 +11,10 @@ set(TEST_LIBS cdl ${TCL_LIBRARY} Boost::boost - utl_lib gtest - gmock - gtest_main + utl_lib + GTest::gtest + GTest::gtest_main + GTest::gmock odb_test_helper ) diff --git a/src/rmp/test/cpp/CMakeLists.txt b/src/rmp/test/cpp/CMakeLists.txt index 88e447d3e4d..95dc2a3cdaf 100644 --- a/src/rmp/test/cpp/CMakeLists.txt +++ b/src/rmp/test/cpp/CMakeLists.txt @@ -3,9 +3,9 @@ include(openroad) add_executable(RmpGTests TestAbc.cc) target_link_libraries(RmpGTests OpenSTA - gtest - gmock - gtest_main + GTest::gtest + GTest::gtest_main + GTest::gmock rmp_abc_library dbSta_lib utl_lib diff --git a/src/rsz/test/cpp/CMakeLists.txt b/src/rsz/test/cpp/CMakeLists.txt index 256ce923d28..93885de5a1b 100644 --- a/src/rsz/test/cpp/CMakeLists.txt +++ b/src/rsz/test/cpp/CMakeLists.txt @@ -3,9 +3,9 @@ include(openroad) add_executable(TestBufRem1 TestBufferRemoval.cc) target_link_libraries(TestBufRem1 OpenSTA - gtest - gmock - gtest_main + GTest::gtest + GTest::gtest_main + GTest::gmock dbSta_lib utl_lib rsz_lib diff --git a/src/utl/test/cpp/CMakeLists.txt b/src/utl/test/cpp/CMakeLists.txt index 2b22b9cd643..697a691cf1b 100644 --- a/src/utl/test/cpp/CMakeLists.txt +++ b/src/utl/test/cpp/CMakeLists.txt @@ -1,8 +1,8 @@ include("openroad") set(TEST_LIBS - gtest - gtest_main + GTest::gtest + GTest::gtest_main utl_lib ) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index d863c490c4c..ed5762faf62 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -34,10 +34,6 @@ ############################################################################### -if(ENABLE_TESTS) - add_subdirectory(gtest EXCLUDE_FROM_ALL) -endif() - if (NOT USE_SYSTEM_ABC) set(ABC_USE_NAMESPACE "abc") diff --git a/third-party/gtest/CMakeLists.txt b/third-party/gtest/CMakeLists.txt deleted file mode 100644 index 499f432238a..00000000000 --- a/third-party/gtest/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include(FetchContent) -FetchContent_Declare( - googletest - DOWNLOAD_EXTRACT_TIMESTAMP TRUE - # Specify the commit you depend on and update it regularly. - URL "https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip" -) -FetchContent_MakeAvailable(googletest)