2017-09-29 02:38:37 +08:00
|
|
|
cmake_minimum_required(VERSION 3.8)
|
|
|
|
project(abseil CXX)
|
|
|
|
|
2017-10-14 20:38:43 +08:00
|
|
|
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
|
2017-09-29 02:38:37 +08:00
|
|
|
|
2018-03-22 19:38:03 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
|
2017-09-29 02:38:37 +08:00
|
|
|
set(CMAKE_DEBUG_POSTFIX d)
|
|
|
|
|
2017-10-14 20:38:43 +08:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
option(INSTALL_HEADERS "Install header files" ON)
|
|
|
|
else()
|
|
|
|
option(INSTALL_HEADERS "Install header files" OFF)
|
|
|
|
endif()
|
2017-09-29 02:38:37 +08:00
|
|
|
|
|
|
|
function(add_sublibrary LIB)
|
|
|
|
file(GLOB_RECURSE SOURCES "absl/${LIB}/*.cc")
|
2018-06-13 01:32:58 +08:00
|
|
|
list(FILTER SOURCES EXCLUDE REGEX "_test(ing)?(_.+)?.cc$|_nonprod.cc$|test_util.cc$|_benchmark.cc$")
|
2018-10-12 12:10:13 +08:00
|
|
|
file(GLOB_RECURSE HEADERS "absl/${LIB}/*.h" "absl/${LIB}/*.inc")
|
2017-09-29 02:38:37 +08:00
|
|
|
|
|
|
|
if(SOURCES)
|
2017-10-14 20:38:43 +08:00
|
|
|
if("STATIC" IN_LIST ARGN)
|
|
|
|
add_library(${LIB} STATIC ${SOURCES})
|
|
|
|
else()
|
|
|
|
add_library(${LIB} ${SOURCES})
|
|
|
|
endif()
|
2017-09-29 02:38:37 +08:00
|
|
|
set_target_properties(${LIB} PROPERTIES OUTPUT_NAME "absl_${LIB}")
|
|
|
|
target_include_directories(${LIB} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
|
|
|
|
else()
|
|
|
|
add_library(${LIB} INTERFACE)
|
|
|
|
target_include_directories(${LIB} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(TARGETS ${LIB} EXPORT unofficial-abseil-targets
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
|
|
|
|
|
|
|
if(INSTALL_HEADERS)
|
|
|
|
if(HEADERS)
|
2018-10-12 12:10:13 +08:00
|
|
|
foreach(file IN LISTS HEADERS)
|
|
|
|
get_filename_component(dir ${file} DIRECTORY)
|
|
|
|
file(RELATIVE_PATH rel_dir ${CMAKE_SOURCE_DIR}/absl/${LIB} ${dir})
|
|
|
|
install(FILES ${file} DESTINATION "include/absl/${LIB}/${rel_dir}")
|
|
|
|
endforeach()
|
2017-09-29 02:38:37 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(target_link_public_libraries A)
|
|
|
|
get_target_property(A_TYPE ${A} TYPE)
|
|
|
|
if(A_TYPE STREQUAL INTERFACE_LIBRARY)
|
|
|
|
target_link_libraries(${A} INTERFACE ${ARGN})
|
|
|
|
else()
|
|
|
|
target_link_libraries(${A} PUBLIC ${ARGN})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
add_sublibrary(algorithm)
|
2017-10-14 20:38:43 +08:00
|
|
|
add_sublibrary(base)
|
2019-01-10 04:31:28 +08:00
|
|
|
add_sublibrary(container STATIC)
|
2017-09-29 02:38:37 +08:00
|
|
|
add_sublibrary(debugging)
|
2018-12-01 02:25:05 +08:00
|
|
|
add_sublibrary(hash)
|
2017-10-14 20:38:43 +08:00
|
|
|
add_sublibrary(memory)
|
|
|
|
add_sublibrary(meta)
|
2017-09-29 02:38:37 +08:00
|
|
|
add_sublibrary(numeric)
|
2017-10-14 20:38:43 +08:00
|
|
|
add_sublibrary(strings)
|
|
|
|
add_sublibrary(synchronization STATIC)
|
|
|
|
# Time must be static because there are global variables intended for export
|
|
|
|
add_sublibrary(time STATIC)
|
2017-09-29 02:38:37 +08:00
|
|
|
add_sublibrary(types)
|
|
|
|
add_sublibrary(utility)
|
|
|
|
|
|
|
|
target_link_public_libraries(algorithm base meta)
|
2019-01-10 04:31:28 +08:00
|
|
|
target_link_public_libraries(container algorithm base memory time)
|
2018-05-02 06:49:11 +08:00
|
|
|
target_link_public_libraries(debugging base)
|
2018-12-01 02:25:05 +08:00
|
|
|
target_link_public_libraries(hash base)
|
2017-09-29 02:38:37 +08:00
|
|
|
target_link_public_libraries(memory meta)
|
|
|
|
target_link_public_libraries(meta base)
|
|
|
|
target_link_public_libraries(numeric base)
|
|
|
|
target_link_public_libraries(strings base memory meta numeric)
|
|
|
|
target_link_public_libraries(types base utility meta algorithm strings)
|
|
|
|
target_link_public_libraries(utility base meta)
|
2017-10-14 20:38:43 +08:00
|
|
|
target_link_public_libraries(time base numeric)
|
|
|
|
target_link_public_libraries(synchronization base time)
|
|
|
|
|
2017-09-29 02:38:37 +08:00
|
|
|
install(
|
|
|
|
EXPORT unofficial-abseil-targets
|
|
|
|
FILE unofficial-abseil-config.cmake
|
|
|
|
NAMESPACE unofficial::abseil::
|
|
|
|
DESTINATION share/unofficial-abseil
|
2018-03-22 19:38:03 +08:00
|
|
|
)
|