Files
abseil-cpp/CMake
Abseil Team fcb104594b Creation of LTS branch "lts_2018_12_18"
- 44b0fafc62 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 926bfeb9ff Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 13327debeb Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 3088e76c59 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f6ae816808 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a06c4a1d90 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 7b46e1d31a Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 070f6e47b3 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 7990fd459e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f95179062e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - cc8dcd307b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a705aa78dc Merge pull request #194 from Mizux/windows by Xiaoyi Zhang <zhangxy988@gmail.com>
  - a4c3ffff11 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 0117457865 Merge pull request #201 from ccawley2011/fix-byteswap by Matt Calabrese <38107210+mattcalabrese-google@users.noreply.github.com>
  - f86f941385 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 94c298e2a0 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 0884a6a04e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - c16d5557cd Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 45221ccc4e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 2019e17a52 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 5b70a8910b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a00bdd176d Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f340f773ed Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 445998d7ac Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - e821380d69 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f21d187b80 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 5441bbe1db Fix code snippet in comment (#174) by Loo Rong Jie <loorongjie@gmail.com>
  - 5aae0cffae Fix CMake build (#173) by Stephan Dollberg <stephan.dollberg@gmail.com>
  - 48cd2c3f35 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - e291c279e4 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - e01d95528e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 8ff1374008 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 02451914b9 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 921fd5cf02 Merge pull request #166 from rongjiecomputer/cmake-test by Gennadiy Civil <gennadiycivil@users.noreply.github.com>
  - fb462224c0 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - c075ad3216 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 0f4bc96675 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 6c7e5ffc43 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - d6df769173 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 28080f5f05 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 9c987f429b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 5e7d459eec Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - bed5bd6e18 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - fefc83638f Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - d8cfe9f2a7 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - ad5c960b2e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 86f0fe93ad Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f0f15c2778 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 29ff6d4860 Removed "warning treated as error" flag from MSVC (#153) by vocaviking <vocaviking@users.noreply.github.com>
  - 083d04dd4a Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - bea85b5273 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 8f96be6ca6 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 92e07e5590 Merge pull request #152 from clnperez/fix-multi-defines-p... by Derek Mauro <761129+derekmauro@users.noreply.github.com>
  - 2125e6444a Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 9acad869d2 Merge pull request #150 from OlafvdSpek/patch-2 by Jonathan Cohen <cohenjon@google.com>
  - c2e00d3419 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 9e060686d1 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 7aa411ceaf Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 2c5af55ed3 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 44aa275286 Merge pull request #143 from rongjiecomputer/kernel by Xiaoyi Zhang <zhangxy988@gmail.com>
  - 42f22a2840 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - b973bc53ef Merge pull request #139 from siepkes/smartos-support by ahedberg <ahedberg@google.com>
  - e0def7473e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f826f1d489 Merge pull request #138 from edbaunton/remove-deprecated-... by ahedberg <ahedberg@google.com>
  - 7b50a4a94b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a5030ca512 Merge pull request #144 from rongjiecomputer/winsock2 by Xiaoyi Zhang <zhangxy988@gmail.com>
  - 02687955b7 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 8f612ebb15 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 134496a31d Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - ba8d6cf077 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - be1e84b988 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 16ac2ec2e3 Merge pull request #134 from rongjiecomputer/cmake by Alex Strelnikov <strel@google.com>
  - 7efd8dc0f1 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 87a4c07856 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 4491d606df Export of internal Abseil changes. by Abseil Team <absl-team@google.com>

GitOrigin-RevId: 44b0fafc62
Change-Id: I2c427b5b41b2d34101922048b00f3d9dafcb498d
2018-12-04 16:54:40 -05:00
..

Abseil CMake Build Instructions

Abseil comes with a CMake build script (CMakeLists.txt) that can be used on a wide range of platforms ("C" stands for cross-platform.). If you don't have CMake installed already, you can download it for free from http://www.cmake.org/.

CMake works by generating native makefiles or build projects that can be used in the compiler environment of your choice.

For API/ABI compatibility reasons, we strongly recommend building Abseil in a subdirectory of your project or as an embedded dependency.

Incorporating Abseil Into a CMake Project

The recommendations below are similar to those for using CMake within the googletest framework (https://github.com/google/googletest/blob/master/googletest/README.md#incorporating-into-an-existing-cmake-project)

Step-by-Step Instructions

  1. If you want to build the Abseil tests, integrate the Abseil dependency Google Test into your CMake project. To disable Abseil tests, you have to pass -DBUILD_TESTING=OFF when configuring your project with CMake.

  2. Download Abseil and copy it into a subdirectory in your CMake project or add Abseil as a git submodule in your CMake project.

  3. You can then use the CMake command add_subdirectory() to include Abseil directly in your CMake project.

  4. Add the absl:: target you wish to use to the target_link_libraries() section of your executable or of your library.
    Here is a short CMakeLists.txt example of a project file using Abseil.

cmake_minimum_required(VERSION 2.8.12)
project(my_project)

set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")

if(MSVC)
  # /wd4005  macro-redefinition
  # /wd4068  unknown pragma
  # /wd4244  conversion from 'type1' to 'type2'
  # /wd4267  conversion from 'size_t' to 'type2'
  # /wd4800  force value to bool 'true' or 'false' (performance warning)
  add_compile_options(/wd4005 /wd4068 /wd4244 /wd4267 /wd4800)
  add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS)
endif()

add_subdirectory(abseil-cpp)

add_executable(my_exe source.cpp)
target_link_libraries(my_exe absl::base absl::synchronization absl::strings)

Running Abseil Tests with CMake

Use the -DABSL_RUN_TESTS=ON flag to run Abseil tests. Note that if the -DBUILD_TESTING=OFF flag is passed then Abseil tests will not be run.

You will need to provide Abseil with a Googletest dependency. There are two options for how to do this:

For example, to run just the Abseil tests, you could use this script:

cd path/to/abseil-cpp
mkdir build
cd build
cmake -DABSL_USE_GOOGLETEST_HEAD=ON -DABSL_RUN_TESTS=ON ..
make -j
ctest

Currently, we only run our tests with CMake in a Linux environment, but we are working on the rest of our supported platforms. See https://github.com/abseil/abseil-cpp/projects/1 and https://github.com/abseil/abseil-cpp/issues/109 for more information.

Available Abseil CMake Public Targets

Here's a non-exhaustive list of Abseil CMake public targets:

absl::base
absl::algorithm
absl::container
absl::debugging
absl::memory
absl::meta
absl::numeric
absl::strings
absl::synchronization
absl::time
absl::utility