Merge pull request #69 from romange/master
Relax dependency requirements for google test library and allow customization of cctz target
This commit is contained in:
		
						commit
						e5c6ee2d00
					
				
					 3 changed files with 24 additions and 16 deletions
				
			
		| 
						 | 
					@ -28,8 +28,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Note: Abseil requires CCTZ and the googletest framework. Consequently,
 | 
					    Note: Abseil requires CCTZ and the googletest framework. Consequently,
 | 
				
			||||||
    the targets  `gtest`, `gtest_main`, `gmock` and `cctz` need
 | 
					    the targets  `gtest`, `gtest_main`, `gmock` and `cctz` need
 | 
				
			||||||
    to be declared in your project before including abseil with `add_subdirectory`.
 | 
					    to be declared in your project before including abseil with
 | 
				
			||||||
 | 
					    `add_subdirectory`. However, if abseil is compiled with
 | 
				
			||||||
 | 
					    `-DBUILD_TESTING=OFF`, then `gtest`, `gmock` and `gtest_main` are not
 | 
				
			||||||
 | 
					    required. In addition, it's possible to override the name of the `cctz`
 | 
				
			||||||
 | 
					    target to a custom one with option `-DABSL_CCTZ_TARGET=*my_cctz*`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  4- Add the absl:: target you wish to use to the `target_link_libraries()`
 | 
					  4- Add the absl:: target you wish to use to the `target_link_libraries()`
 | 
				
			||||||
    section of your executable or of your library
 | 
					    section of your executable or of your library
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,29 +58,34 @@ list(APPEND ABSL_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
 | 
				
			||||||
set(CMAKE_CXX_FLAGS "${ABSL_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}")
 | 
					set(CMAKE_CXX_FLAGS "${ABSL_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}")
 | 
				
			||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_WARNING_VLA} ${CMAKE_CXX_FLAGS} ")
 | 
					set(CMAKE_CXX_FLAGS "${CMAKE_CXX_WARNING_VLA} ${CMAKE_CXX_FLAGS} ")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# -fexceptions
 | 
				
			||||||
 | 
					set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# find dependencies
 | 
					# find dependencies
 | 
				
			||||||
## pthread
 | 
					## pthread
 | 
				
			||||||
find_package(Threads REQUIRED)
 | 
					find_package(Threads REQUIRED)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(NOT ABSL_CCTZ_TARGET)
 | 
				
			||||||
 | 
					  set(ABSL_CCTZ_TARGET cctz)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# commented: used only for standalone test
 | 
					# commented: used only for standalone test
 | 
				
			||||||
#add_subdirectory(cctz)
 | 
					#add_subdirectory(cctz)
 | 
				
			||||||
#add_subdirectory(googletest)
 | 
					#add_subdirectory(googletest)
 | 
				
			||||||
 | 
					check_target(${ABSL_CCTZ_TARGET})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## check targets
 | 
					## check targets
 | 
				
			||||||
check_target(cctz)
 | 
					if(BUILD_TESTING)
 | 
				
			||||||
check_target(gtest)
 | 
					  check_target(gtest)
 | 
				
			||||||
check_target(gtest_main)
 | 
					  check_target(gtest_main)
 | 
				
			||||||
check_target(gmock)
 | 
					  check_target(gmock)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# -fexceptions
 | 
					  list(APPEND ABSL_TEST_COMMON_LIBRARIES
 | 
				
			||||||
set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")
 | 
					    gtest_main
 | 
				
			||||||
 | 
					    gtest
 | 
				
			||||||
list(APPEND ABSL_TEST_COMMON_LIBRARIES
 | 
					    gmock
 | 
				
			||||||
  gtest_main
 | 
					    ${CMAKE_THREAD_LIBS_INIT}
 | 
				
			||||||
  gtest
 | 
					  )
 | 
				
			||||||
  gmock
 | 
					endif()
 | 
				
			||||||
  ${CMAKE_THREAD_LIBS_INIT}
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_subdirectory(absl)
 | 
					add_subdirectory(absl)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ list(APPEND TIME_SRC
 | 
				
			||||||
  ${TIME_PUBLIC_HEADERS}
 | 
					  ${TIME_PUBLIC_HEADERS}
 | 
				
			||||||
  ${TIME_INTERNAL_HEADERS}
 | 
					  ${TIME_INTERNAL_HEADERS}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
set(TIME_PUBLIC_LIBRARIES absl::base absl::stacktrace absl::int128 cctz)
 | 
					set(TIME_PUBLIC_LIBRARIES absl::base absl::stacktrace absl::int128 ${ABSL_CCTZ_TARGET})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
absl_library(
 | 
					absl_library(
 | 
				
			||||||
  TARGET
 | 
					  TARGET
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue