Skip to content

Commit 8d29d95

Browse files
committed
Download gtest unless PHMAP_DOWNLOAD_GTEST is turned off.
1 parent 8bd66dc commit 8d29d95

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

CMakeLists.txt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ endif()
8484
## ------------------------- building tests and examples -------------
8585
option(PHMAP_BUILD_TESTS "Whether or not to build the tests" ${PHMAP_MASTER_PROJECT})
8686
option(PHMAP_BUILD_EXAMPLES "Whether or not to build the examples" ${PHMAP_MASTER_PROJECT})
87+
option(PHMAP_DOWNLOAD_GTEST "Whether to download gtest or use installed version" ON)
8788

8889
if(MSVC)
8990
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>")
@@ -94,12 +95,16 @@ if (PHMAP_BUILD_TESTS OR PHMAP_BUILD_EXAMPLES)
9495
endif()
9596

9697
if (PHMAP_BUILD_TESTS)
97-
9898
if (NOT PHMAP_GTEST_LIBS)
99-
find_package(GTest CONFIG)
100-
if (GTest_FOUND)
101-
set(PHMAP_GTEST_LIBS GTest::gmock_main)
102-
else()
99+
if (NOT PHMAP_DOWNLOAD_GTEST)
100+
find_package(GTest CONFIG)
101+
if (GTest_FOUND)
102+
set(PHMAP_GTEST_LIBS GTest::gmock_main)
103+
else()
104+
set(PHMAP_DOWNLOAD_GTEST ON)
105+
endif()
106+
endif()
107+
if (PHMAP_DOWNLOAD_GTEST)
103108
include(cmake/DownloadGTest.cmake)
104109

105110
check_target(gtest)
@@ -211,8 +216,11 @@ if (PHMAP_BUILD_EXAMPLES)
211216

212217
# llil4map.cc - see https://www.perlmonks.com/?node_id=11149643
213218
# -------------------------------------------------------------
214-
find_package(OpenMP)
215-
find_package(Boost 1.70.0)
219+
if(POLICY CMP0167)
220+
cmake_policy(SET CMP0167 NEW)
221+
endif()
222+
find_package(OpenMP QUIET)
223+
find_package(Boost 1.70.0 QUIET)
216224
if (OpenMP_FOUND AND Boost_FOUND AND "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
217225
add_executable(ex_llil4map examples/llil4map.cc phmap.natvis)
218226
target_include_directories(ex_llil4map PRIVATE ${Boost_INCLUDE_DIRS})

0 commit comments

Comments
 (0)