[abseil] Initial commit. Highly experimental.

This commit is contained in:
Robert Schumacher 2017-09-28 11:38:37 -07:00
parent 0ccea4f367
commit c957331251
4 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,77 @@
cmake_minimum_required(VERSION 3.8)
project(abseil CXX)
add_definitions(-DNOMINMAX)
set(CMAKE_DEBUG_POSTFIX d)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
option(INSTALL_HEADERS "Install header files" ON)
function(add_sublibrary LIB)
file(GLOB_RECURSE SOURCES "absl/${LIB}/*.cc")
list(FILTER SOURCES EXCLUDE REGEX "_test")
file(GLOB HEADERS "absl/${LIB}/*.h")
file(GLOB INTERNAL_HEADERS "absl/${LIB}/internal/*.h")
if(SOURCES)
add_library(${LIB} ${SOURCES})
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)
install(FILES ${HEADERS} DESTINATION "include/absl/${LIB}")
endif()
if(INTERNAL_HEADERS)
install(FILES ${INTERNAL_HEADERS} DESTINATION "include/absl/${LIB}/internal")
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(base)
add_sublibrary(meta)
add_sublibrary(algorithm)
add_sublibrary(container)
add_sublibrary(memory)
add_sublibrary(strings)
add_sublibrary(debugging)
add_sublibrary(numeric)
add_sublibrary(types)
add_sublibrary(utility)
target_link_public_libraries(algorithm base meta)
target_link_public_libraries(container algorithm base memory)
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)
install(
EXPORT unofficial-abseil-targets
FILE unofficial-abseil-config.cmake
NAMESPACE unofficial::abseil::
DESTINATION share/unofficial-abseil
)

6
ports/abseil/CONTROL Normal file
View File

@ -0,0 +1,6 @@
Source: abseil
Version: 2017-09-28
Description: an open-source collection designed to augment the C++ standard library.
Abseil is an open-source collection of C++ library code designed to augment the C++ standard library. The Abseil library code is collected from Google's own C++ code base, has been extensively tested and used in production, and is the same code we depend on in our daily coding lives.
In some cases, Abseil provides pieces missing from the C++ standard; in others, Abseil provides alternatives to the standard for special needs we've found through usage in the Google code base. We denote those cases clearly within the library code we provide you.
Abseil is not meant to be a competitor to the standard library; we've just found that many of these utilities serve a purpose within our code base, and we now want to provide those resources to the C++ community as a whole.

View File

@ -0,0 +1,12 @@
diff --git a/absl/base/optimization.h b/absl/base/optimization.h
index db8beaf..aaaffa4 100644
--- a/absl/base/optimization.h
+++ b/absl/base/optimization.h
@@ -46,6 +46,7 @@
// GCC will not tail call given inline volatile assembly.
#define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("")
#elif defined(_MSC_VER)
+#include <intrin.h>
// The __nop() intrinsic blocks the optimisation.
#define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __nop()
#else

View File

@ -0,0 +1,37 @@
include(vcpkg_common_functions)
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message(FATAL_ERROR "Abseil currently only supports being built for desktop")
endif()
message("NOTE: THIS PORT IS USING AN UNOFFICIAL BUILDSYSTEM AND THE EXACT BINARY LAYOUT WILL CHANGE IN THE FUTURE.")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO abseil/abseil-cpp
REF cdf20caa491f59c0a35a8d8fbec0d948e4bc7e4c
SHA512 04889e7804b644821d0bf5d1b13f15a072e748bf0465442c64528e014c71f415544e9146c9518f9fe7bb14a295b18f293c3f7b672f6a51dba9909f3b74667fae
HEAD_REF master
)
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-intrin.patch"
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS_DEBUG -DINSTALL_HEADERS=OFF
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-abseil)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/abseil ${CURRENT_PACKAGES_DIR}/share/unofficial-abseil)
vcpkg_copy_pdbs()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/abseil RENAME copyright)