2019-04-30 10:36:29 +00:00
cmake_minimum_required ( VERSION 2.8.12 )
project ( googletest-download NONE )
# Enable ExternalProject CMake module
include ( ExternalProject )
option ( ALLOW_DOWNLOADING_GOOGLETEST "If googletest src tree is not found in location specified by GOOGLETEST_PATH, do fetch the archive from internet" OFF )
set ( GOOGLETEST_PATH "/usr/src/googletest" CACHE PATH
" P a t h t o t h e g o o g l e t e s t r o o t t r e e . S h o u l d c o n t a i n g o o g l e t e s t a n d g o o g l e m o c k s u b d i r s . A n d C M a k e L i s t s . t x t i n r o o t , a n d i n b o t h o f t h e s e s u b d i r s " )
# Download and install GoogleTest
message ( STATUS "Looking for Google Test sources" )
message ( STATUS "Looking for Google Test sources in ${GOOGLETEST_PATH}" )
if ( EXISTS "${GOOGLETEST_PATH}" AND IS_DIRECTORY "${GOOGLETEST_PATH}" AND EXISTS "${GOOGLETEST_PATH}/CMakeLists.txt" AND
E X I S T S " $ { G O O G L E T E S T _ P A T H } / g o o g l e t e s t " A N D I S _ D I R E C T O R Y " $ { G O O G L E T E S T _ P A T H } / g o o g l e t e s t " A N D E X I S T S " $ { G O O G L E T E S T _ P A T H } / g o o g l e t e s t / C M a k e L i s t s . t x t " A N D
E X I S T S " $ { G O O G L E T E S T _ P A T H } / g o o g l e m o c k " A N D I S _ D I R E C T O R Y " $ { G O O G L E T E S T _ P A T H } / g o o g l e m o c k " A N D E X I S T S " $ { G O O G L E T E S T _ P A T H } / g o o g l e m o c k / C M a k e L i s t s . t x t " )
message ( STATUS "Found Google Test in ${GOOGLETEST_PATH}" )
ExternalProject_Add (
g o o g l e t e s t
P R E F I X " $ { C M A K E _ B I N A R Y _ D I R } "
D O W N L O A D _ D I R " $ { C M A K E _ B I N A R Y _ D I R } / d o w n l o a d "
S O U R C E _ D I R " $ { G O O G L E T E S T _ P A T H } " # use existing src dir.
B I N A R Y _ D I R " $ { C M A K E _ B I N A R Y _ D I R } / b u i l d "
C O N F I G U R E _ C O M M A N D " "
B U I L D _ C O M M A N D " "
I N S T A L L _ C O M M A N D " "
T E S T _ C O M M A N D " "
)
else ( )
if ( NOT ALLOW_DOWNLOADING_GOOGLETEST )
2020-08-21 15:25:56 +00:00
message ( SEND_ERROR "Did not find Google Test sources! Either pass correct path in GOOGLETEST_PATH, or enable BENCHMARK_DOWNLOAD_DEPENDENCIES, or disable BENCHMARK_ENABLE_GTEST_TESTS / BENCHMARK_ENABLE_TESTING." )
2021-10-19 08:31:32 +00:00
return ( )
2019-04-30 10:36:29 +00:00
else ( )
message ( WARNING "Did not find Google Test sources! Fetching from web..." )
ExternalProject_Add (
g o o g l e t e s t
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / g o o g l e / g o o g l e t e s t . g i t
G I T _ T A G m a s t e r
P R E F I X " $ { C M A K E _ B I N A R Y _ D I R } "
S T A M P _ D I R " $ { C M A K E _ B I N A R Y _ D I R } / s t a m p "
D O W N L O A D _ D I R " $ { C M A K E _ B I N A R Y _ D I R } / d o w n l o a d "
S O U R C E _ D I R " $ { C M A K E _ B I N A R Y _ D I R } / s r c "
B I N A R Y _ D I R " $ { C M A K E _ B I N A R Y _ D I R } / b u i l d "
C O N F I G U R E _ C O M M A N D " "
B U I L D _ C O M M A N D " "
I N S T A L L _ C O M M A N D " "
T E S T _ C O M M A N D " "
)
endif ( )
endif ( )
ExternalProject_Get_Property ( googletest SOURCE_DIR BINARY_DIR )
file ( WRITE googletest-paths.cmake
" set ( GOOGLETEST_SOURCE_DIR \"${SOURCE_DIR}\")
set ( GOOGLETEST_BINARY_DIR \"${BINARY_DIR}\")
" )