Download gtest unless PHMAP_DOWNLOAD_GTEST is turned off.

This commit is contained in:
greg7mdp
2025-10-15 22:49:31 -04:00
parent 8bd66dc8ed
commit 8d29d95536
+15 -7
View File
@@ -84,6 +84,7 @@ endif()
## ------------------------- building tests and examples ------------- ## ------------------------- building tests and examples -------------
option(PHMAP_BUILD_TESTS "Whether or not to build the tests" ${PHMAP_MASTER_PROJECT}) option(PHMAP_BUILD_TESTS "Whether or not to build the tests" ${PHMAP_MASTER_PROJECT})
option(PHMAP_BUILD_EXAMPLES "Whether or not to build the examples" ${PHMAP_MASTER_PROJECT}) option(PHMAP_BUILD_EXAMPLES "Whether or not to build the examples" ${PHMAP_MASTER_PROJECT})
option(PHMAP_DOWNLOAD_GTEST "Whether to download gtest or use installed version" ON)
if(MSVC) if(MSVC)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>") add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>")
@@ -94,12 +95,16 @@ if (PHMAP_BUILD_TESTS OR PHMAP_BUILD_EXAMPLES)
endif() endif()
if (PHMAP_BUILD_TESTS) if (PHMAP_BUILD_TESTS)
if (NOT PHMAP_GTEST_LIBS) if (NOT PHMAP_GTEST_LIBS)
find_package(GTest CONFIG) if (NOT PHMAP_DOWNLOAD_GTEST)
if (GTest_FOUND) find_package(GTest CONFIG)
set(PHMAP_GTEST_LIBS GTest::gmock_main) if (GTest_FOUND)
else() set(PHMAP_GTEST_LIBS GTest::gmock_main)
else()
set(PHMAP_DOWNLOAD_GTEST ON)
endif()
endif()
if (PHMAP_DOWNLOAD_GTEST)
include(cmake/DownloadGTest.cmake) include(cmake/DownloadGTest.cmake)
check_target(gtest) check_target(gtest)
@@ -211,8 +216,11 @@ if (PHMAP_BUILD_EXAMPLES)
# llil4map.cc - see https://www.perlmonks.com/?node_id=11149643 # llil4map.cc - see https://www.perlmonks.com/?node_id=11149643
# ------------------------------------------------------------- # -------------------------------------------------------------
find_package(OpenMP) if(POLICY CMP0167)
find_package(Boost 1.70.0) cmake_policy(SET CMP0167 NEW)
endif()
find_package(OpenMP QUIET)
find_package(Boost 1.70.0 QUIET)
if (OpenMP_FOUND AND Boost_FOUND AND "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) if (OpenMP_FOUND AND Boost_FOUND AND "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
add_executable(ex_llil4map examples/llil4map.cc phmap.natvis) add_executable(ex_llil4map examples/llil4map.cc phmap.natvis)
target_include_directories(ex_llil4map PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(ex_llil4map PRIVATE ${Boost_INCLUDE_DIRS})