Add option to use an externally provided GoogleTest target (for usage of abseil as add_subdirectory target) (#647)
This commit is contained in:
		
							parent
							
								
									d43b7997c0
								
							
						
					
					
						commit
						c01b9916e7
					
				
					 1 changed files with 11 additions and 7 deletions
				
			
		|  | @ -81,6 +81,9 @@ endif() | ||||||
| ## pthread | ## pthread | ||||||
| find_package(Threads REQUIRED) | find_package(Threads REQUIRED) | ||||||
| 
 | 
 | ||||||
|  | option(ABSL_USE_EXTERNAL_GOOGLETEST | ||||||
|  |   "If ON, abseil will assume that the targets for googletest are already provided by the including project folder. This makes sense when abseil is used with add_subproject." OFF) | ||||||
|  | 
 | ||||||
| option(ABSL_USE_GOOGLETEST_HEAD | option(ABSL_USE_GOOGLETEST_HEAD | ||||||
|   "If ON, abseil will download HEAD from googletest at config time." OFF) |   "If ON, abseil will download HEAD from googletest at config time." OFF) | ||||||
| 
 | 
 | ||||||
|  | @ -99,14 +102,15 @@ endif() | ||||||
| 
 | 
 | ||||||
| ## check targets | ## check targets | ||||||
| if(BUILD_TESTING) | if(BUILD_TESTING) | ||||||
| 
 |   if (NOT ABSL_USE_EXTERNAL_GOOGLETEST) | ||||||
|   set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) |     set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) | ||||||
|   if(${ABSL_USE_GOOGLETEST_HEAD}) |     if(${ABSL_USE_GOOGLETEST_HEAD}) | ||||||
|     set(absl_gtest_src_dir ${CMAKE_BINARY_DIR}/googletest-src) |       set(absl_gtest_src_dir ${CMAKE_BINARY_DIR}/googletest-src) | ||||||
|   else() |     else() | ||||||
|     set(absl_gtest_src_dir ${ABSL_LOCAL_GOOGLETEST_DIR}) |       set(absl_gtest_src_dir ${ABSL_LOCAL_GOOGLETEST_DIR}) | ||||||
|  |     endif() | ||||||
|  |     include(CMake/Googletest/DownloadGTest.cmake) | ||||||
|   endif() |   endif() | ||||||
|   include(CMake/Googletest/DownloadGTest.cmake) |  | ||||||
| 
 | 
 | ||||||
|   check_target(gtest) |   check_target(gtest) | ||||||
|   check_target(gtest_main) |   check_target(gtest_main) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue