Skip to content

Commit

Permalink
[abseil] Initial commit. Highly experimental.
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Sep 28, 2017
1 parent 0ccea4f commit c957331
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
77 changes: 77 additions & 0 deletions ports/abseil/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions ports/abseil/CONTROL
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions ports/abseil/fix-intrin.patch
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions ports/abseil/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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)

2 comments on commit c957331

@solvingj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you've got a lot of cmake here for Abseil, perhaps consider contributing some pieces to this effort: abseil/abseil-cpp#8

@ras0219-msft
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely considered it, however they are restricting it to cmake 2.8, which invalidates this approach. ☹

Please sign in to comment.