summaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake')
-rw-r--r--CMake/AbseilDll.cmake24
-rw-r--r--CMake/AbseilHelpers.cmake77
-rw-r--r--CMake/AbseilInstallDirs.cmake20
-rw-r--r--CMake/Googletest/CMakeLists.txt.in30
-rw-r--r--CMake/README.md4
-rwxr-xr-xCMake/install_test_project/test.sh146
6 files changed, 142 insertions, 159 deletions
diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake
index cf6a8c9a..253c73ff 100644
--- a/CMake/AbseilDll.cmake
+++ b/CMake/AbseilDll.cmake
@@ -1,4 +1,5 @@
include(CMakeParseArguments)
+include(GNUInstallDirs)
set(ABSL_INTERNAL_DLL_FILES
"algorithm/algorithm.h"
@@ -10,7 +11,6 @@ set(ABSL_INTERNAL_DLL_FILES
"base/const_init.h"
"base/dynamic_annotations.h"
"base/internal/atomic_hook.h"
- "base/internal/bits.h"
"base/internal/cycleclock.cc"
"base/internal/cycleclock.h"
"base/internal/direct_mmap.h"
@@ -61,6 +61,8 @@ set(ABSL_INTERNAL_DLL_FILES
"base/policy_checks.h"
"base/port.h"
"base/thread_annotations.h"
+ "cleanup/cleanup.h"
+ "cleanup/internal/cleanup.h"
"container/btree_map.h"
"container/btree_set.h"
"container/fixed_array.h"
@@ -122,10 +124,15 @@ set(ABSL_INTERNAL_DLL_FILES
"hash/internal/hash.h"
"hash/internal/hash.cc"
"hash/internal/spy_hash_state.h"
+ "hash/internal/wyhash.h"
+ "hash/internal/wyhash.cc"
"memory/memory.h"
"meta/type_traits.h"
+ "numeric/bits.h"
"numeric/int128.cc"
"numeric/int128.h"
+ "numeric/internal/bits.h"
+ "numeric/internal/representation.h"
"random/bernoulli_distribution.h"
"random/beta_distribution.h"
"random/bit_gen_ref.h"
@@ -190,12 +197,18 @@ set(ABSL_INTERNAL_DLL_FILES
"strings/cord.h"
"strings/escaping.cc"
"strings/escaping.h"
+ "strings/internal/cord_internal.cc"
"strings/internal/cord_internal.h"
+ "strings/internal/cord_rep_flat.h"
+ "strings/internal/cord_rep_ring.cc"
+ "strings/internal/cord_rep_ring.h"
+ "strings/internal/cord_rep_ring_reader.h"
"strings/internal/charconv_bigint.cc"
"strings/internal/charconv_bigint.h"
"strings/internal/charconv_parse.cc"
"strings/internal/charconv_parse.h"
"strings/internal/stl_type_traits.h"
+ "strings/internal/string_constant.h"
"strings/match.cc"
"strings/match.h"
"strings/numbers.cc"
@@ -250,6 +263,7 @@ set(ABSL_INTERNAL_DLL_FILES
"synchronization/notification.h"
"synchronization/internal/create_thread_identity.cc"
"synchronization/internal/create_thread_identity.h"
+ "synchronization/internal/futex.h"
"synchronization/internal/graphcycles.cc"
"synchronization/internal/graphcycles.h"
"synchronization/internal/kernel_timeout.h"
@@ -487,7 +501,7 @@ function(absl_make_dll)
abseil_dll
PUBLIC
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
- $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_options(
@@ -505,8 +519,8 @@ function(absl_make_dll)
${ABSL_CC_LIB_DEFINES}
)
install(TARGETS abseil_dll EXPORT ${PROJECT_NAME}Targets
- RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR}
- LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endfunction()
diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake
index 8b2925c5..70eaa4ca 100644
--- a/CMake/AbseilHelpers.cmake
+++ b/CMake/AbseilHelpers.cmake
@@ -17,7 +17,6 @@
include(CMakeParseArguments)
include(AbseilConfigureCopts)
include(AbseilDll)
-include(AbseilInstallDirs)
# The IDE folder for Abseil that will be used if Abseil is included in a CMake
# project that sets
@@ -41,7 +40,7 @@ endif()
# LINKOPTS: List of link options
# PUBLIC: Add this so that this library will be exported under absl::
# Also in IDE, target will appear in Abseil folder while non PUBLIC will be in Abseil/internal.
-# TESTONLY: When added, this target will only be built if user passes -DABSL_RUN_TESTS=ON to CMake.
+# TESTONLY: When added, this target will only be built if BUILD_TESTING=ON.
#
# Note:
# By default, absl_cc_library will always create a library named absl_${NAME},
@@ -83,7 +82,7 @@ function(absl_cc_library)
${ARGN}
)
- if(ABSL_CC_LIB_TESTONLY AND NOT ABSL_RUN_TESTS)
+ if(ABSL_CC_LIB_TESTONLY AND NOT BUILD_TESTING)
return()
endif()
@@ -104,7 +103,7 @@ function(absl_cc_library)
endif()
endforeach()
- if("${ABSL_CC_SRCS}" STREQUAL "")
+ if(ABSL_CC_SRCS STREQUAL "")
set(ABSL_CC_LIB_IS_INTERFACE 1)
else()
set(ABSL_CC_LIB_IS_INTERFACE 0)
@@ -122,7 +121,11 @@ function(absl_cc_library)
# 4. "static" -- This target does not depend on the DLL and should be built
# statically.
if (${ABSL_BUILD_DLL})
- absl_internal_dll_contains(TARGET ${_NAME} OUTPUT _in_dll)
+ if(ABSL_ENABLE_INSTALL)
+ absl_internal_dll_contains(TARGET ${_NAME} OUTPUT _in_dll)
+ else()
+ absl_internal_dll_contains(TARGET ${ABSL_CC_LIB_NAME} OUTPUT _in_dll)
+ endif()
if (${_in_dll})
# This target should be replaced by the DLL
set(_build_type "dll")
@@ -137,8 +140,53 @@ function(absl_cc_library)
set(_build_type "static")
endif()
+ # Generate a pkg-config file for every library:
+ if(_build_type STREQUAL "static" OR _build_type STREQUAL "shared")
+ if(NOT ABSL_CC_LIB_TESTONLY)
+ if(absl_VERSION)
+ set(PC_VERSION "${absl_VERSION}")
+ else()
+ set(PC_VERSION "head")
+ endif()
+ foreach(dep ${ABSL_CC_LIB_DEPS})
+ if(${dep} MATCHES "^absl::(.*)")
+ # Join deps with commas.
+ if(PC_DEPS)
+ set(PC_DEPS "${PC_DEPS},")
+ endif()
+ set(PC_DEPS "${PC_DEPS} absl_${CMAKE_MATCH_1} = ${PC_VERSION}")
+ endif()
+ endforeach()
+ foreach(cflag ${ABSL_CC_LIB_COPTS})
+ if(${cflag} MATCHES "^(-Wno|/wd)")
+ # These flags are needed to suppress warnings that might fire in our headers.
+ set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
+ elseif(${cflag} MATCHES "^(-W|/w[1234eo])")
+ # Don't impose our warnings on others.
+ else()
+ set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
+ endif()
+ endforeach()
+ FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc" CONTENT "\
+prefix=${CMAKE_INSTALL_PREFIX}\n\
+exec_prefix=\${prefix}\n\
+libdir=\${prefix}/${CMAKE_INSTALL_LIBDIR}\n\
+includedir=\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}\n\
+\n\
+Name: absl_${_NAME}\n\
+Description: Abseil ${_NAME} library\n\
+URL: https://abseil.io/\n\
+Version: ${PC_VERSION}\n\
+Requires:${PC_DEPS}\n\
+Libs: -L\${libdir} $<JOIN:${ABSL_CC_LIB_LINKOPTS}, > $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-labsl_${_NAME}>\n\
+Cflags: -I\${includedir}${PC_CFLAGS}\n")
+ INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc"
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
+ endif()
+ endif()
+
if(NOT ABSL_CC_LIB_IS_INTERFACE)
- if(${_build_type} STREQUAL "dll_dep")
+ if(_build_type STREQUAL "dll_dep")
# This target depends on the DLL. When adding dependencies to this target,
# any depended-on-target which is contained inside the DLL is replaced
# with a dependency on the DLL.
@@ -167,7 +215,7 @@ function(absl_cc_library)
"${_gtest_link_define}"
)
- elseif(${_build_type} STREQUAL "static" OR ${_build_type} STREQUAL "shared")
+ elseif(_build_type STREQUAL "static" OR _build_type STREQUAL "shared")
add_library(${_NAME} "")
target_sources(${_NAME} PRIVATE ${ABSL_CC_LIB_SRCS} ${ABSL_CC_LIB_HDRS})
target_link_libraries(${_NAME}
@@ -190,7 +238,7 @@ function(absl_cc_library)
target_include_directories(${_NAME}
PUBLIC
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
- $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_options(${_NAME}
PRIVATE ${ABSL_CC_LIB_COPTS})
@@ -215,6 +263,7 @@ function(absl_cc_library)
if(ABSL_ENABLE_INSTALL)
set_target_properties(${_NAME} PROPERTIES
OUTPUT_NAME "absl_${_NAME}"
+ SOVERSION "2103.0.0"
)
endif()
else()
@@ -223,10 +272,10 @@ function(absl_cc_library)
target_include_directories(${_NAME}
INTERFACE
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
- $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
- if (${_build_type} STREQUAL "dll")
+ if (_build_type STREQUAL "dll")
set(ABSL_CC_LIB_DEPS abseil_dll)
endif()
@@ -243,9 +292,9 @@ function(absl_cc_library)
# installed abseil can't be tested.
if(NOT ABSL_CC_LIB_TESTONLY AND ABSL_ENABLE_INSTALL)
install(TARGETS ${_NAME} EXPORT ${PROJECT_NAME}Targets
- RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR}
- LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
@@ -290,7 +339,7 @@ endfunction()
# gtest_main
# )
function(absl_cc_test)
- if(NOT ABSL_RUN_TESTS)
+ if(NOT BUILD_TESTING)
return()
endif()
diff --git a/CMake/AbseilInstallDirs.cmake b/CMake/AbseilInstallDirs.cmake
deleted file mode 100644
index 6fc914b6..00000000
--- a/CMake/AbseilInstallDirs.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-include(GNUInstallDirs)
-
-# absl_VERSION is only set if we are an LTS release being installed, in which
-# case it may be into a system directory and so we need to make subdirectories
-# for each installed version of Abseil. This mechanism is implemented in
-# Abseil's internal Copybara (https://github.com/google/copybara) workflows and
-# isn't visible in the CMake buildsystem itself.
-
-if(absl_VERSION)
- set(ABSL_SUBDIR "${PROJECT_NAME}_${PROJECT_VERSION}")
- set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}/${ABSL_SUBDIR}")
- set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${ABSL_SUBDIR}")
- set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${ABSL_SUBDIR}")
- set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${ABSL_SUBDIR}")
-else()
- set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
- set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
- set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
- set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
-endif()
diff --git a/CMake/Googletest/CMakeLists.txt.in b/CMake/Googletest/CMakeLists.txt.in
index 994dac0b..5769e3a9 100644
--- a/CMake/Googletest/CMakeLists.txt.in
+++ b/CMake/Googletest/CMakeLists.txt.in
@@ -3,24 +3,12 @@ cmake_minimum_required(VERSION 2.8.2)
project(googletest-external NONE)
include(ExternalProject)
-if(${ABSL_USE_GOOGLETEST_HEAD})
- ExternalProject_Add(googletest
- GIT_REPOSITORY https://github.com/google/googletest.git
- GIT_TAG master
- SOURCE_DIR "${absl_gtest_src_dir}"
- BINARY_DIR "${absl_gtest_build_dir}"
- CONFIGURE_COMMAND ""
- BUILD_COMMAND ""
- INSTALL_COMMAND ""
- TEST_COMMAND ""
- )
-else()
- ExternalProject_Add(googletest
- SOURCE_DIR "${absl_gtest_src_dir}"
- BINARY_DIR "${absl_gtest_build_dir}"
- CONFIGURE_COMMAND ""
- BUILD_COMMAND ""
- INSTALL_COMMAND ""
- TEST_COMMAND ""
- )
-endif() \ No newline at end of file
+ExternalProject_Add(googletest
+ URL "${absl_gtest_download_url}" # May be empty
+ SOURCE_DIR "${absl_gtest_src_dir}"
+ BINARY_DIR "${absl_gtest_build_dir}"
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ TEST_COMMAND ""
+)
diff --git a/CMake/README.md b/CMake/README.md
index 8f73475a..5eee8171 100644
--- a/CMake/README.md
+++ b/CMake/README.md
@@ -52,7 +52,7 @@ 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.
+Use the `-DBUILD_TESTING=ON` flag to run Abseil tests.
You will need to provide Abseil with a Googletest dependency. There are two
options for how to do this:
@@ -70,7 +70,7 @@ 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 ..
+cmake -DBUILD_TESTING=ON -DABSL_USE_GOOGLETEST_HEAD=ON ..
make -j
ctest
```
diff --git a/CMake/install_test_project/test.sh b/CMake/install_test_project/test.sh
index 99989b03..a3d39773 100755
--- a/CMake/install_test_project/test.sh
+++ b/CMake/install_test_project/test.sh
@@ -13,70 +13,44 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-# "Unit" and integration tests for Absl CMake installation
-
-# TODO(absl-team): This script isn't fully hermetic because
-# -DABSL_USE_GOOGLETEST_HEAD=ON means that this script isn't pinned to a fixed
-# version of GoogleTest. This means that an upstream change to GoogleTest could
-# break this test. Fix this by allowing this script to pin to a known-good
-# version of GoogleTest.
+#
+# Unit and integration tests for Abseil LTS CMake installation
# Fail on any error. Treat unset variables an error. Print commands as executed.
set -euox pipefail
-install_absl() {
- pushd "${absl_build_dir}"
- if [[ "${#}" -eq 1 ]]; then
- cmake -DCMAKE_INSTALL_PREFIX="${1}" "${absl_dir}"
- else
- cmake "${absl_dir}"
- fi
- cmake --build . --target install -- -j
- popd
-}
-
-uninstall_absl() {
- xargs rm < "${absl_build_dir}"/install_manifest.txt
- rm -rf "${absl_build_dir}"
- mkdir -p "${absl_build_dir}"
-}
-
-lts_install=""
-
-while getopts ":l" lts; do
- case "${lts}" in
- l )
- lts_install="true"
- ;;
- esac
-done
+source ci/cmake_common.sh
absl_dir=/abseil-cpp
-absl_build_dir=/buildfs/absl-build
+absl_build_dir=/buildfs
project_dir="${absl_dir}"/CMake/install_test_project
project_build_dir=/buildfs/project-build
-mkdir -p "${absl_build_dir}"
-mkdir -p "${project_build_dir}"
-
-if [[ "${lts_install}" ]]; then
- install_dir="/usr/local"
-else
- install_dir="${project_build_dir}"/install
+build_shared_libs="OFF"
+if [ "${LINK_TYPE:-}" = "DYNAMIC" ]; then
+ build_shared_libs="ON"
fi
-mkdir -p "${install_dir}"
-# Test build, install, and link against installed abseil
-pushd "${project_build_dir}"
-if [[ "${lts_install}" ]]; then
- install_absl
- cmake "${project_dir}"
-else
- install_absl "${install_dir}"
- cmake "${project_dir}" -DCMAKE_PREFIX_PATH="${install_dir}"
-fi
+# Run the LTS transformations
+./create_lts.py 99998877
+
+# Install Abseil
+pushd "${absl_build_dir}"
+cmake "${absl_dir}" \
+ -DABSL_GOOGLETEST_DOWNLOAD_URL="${ABSL_GOOGLETEST_DOWNLOAD_URL}" \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DBUILD_TESTING=ON \
+ -DBUILD_SHARED_LIBS="${build_shared_libs}"
+make -j $(nproc)
+ctest -j $(nproc)
+make install
+ldconfig
+popd
+# Test the project against the installed Abseil
+mkdir -p "${project_build_dir}"
+pushd "${project_build_dir}"
+cmake "${project_dir}"
cmake --build . --target simple
output="$(${project_build_dir}/simple "printme" 2>&1)"
@@ -88,57 +62,35 @@ fi
popd
-# Test that we haven't accidentally made absl::abslblah
-pushd "${install_dir}"
-
-# Starting in CMake 3.12 the default install dir is lib$bit_width
-if [[ -d lib64 ]]; then
- libdir="lib64"
-elif [[ -d lib ]]; then
- libdir="lib"
-else
- echo "ls *, */*, */*/*:"
- ls *
- ls */*
- ls */*/*
- echo "unknown lib dir"
-fi
-
-if [[ "${lts_install}" ]]; then
- # LTS versions append the date of the release to the subdir.
- # 9999/99/99 is the dummy date used in the local_lts workflow.
- absl_subdir="absl_99999999"
-else
- absl_subdir="absl"
-fi
-
-if ! grep absl::strings "${libdir}/cmake/${absl_subdir}/abslTargets.cmake"; then
- cat "${libdir}"/cmake/absl/abslTargets.cmake
+if ! grep absl::strings "/usr/local/lib/cmake/absl/abslTargets.cmake"; then
+ cat "/usr/local/lib/cmake/absl/abslTargets.cmake"
echo "CMake targets named incorrectly"
exit 1
fi
-uninstall_absl
-popd
+pushd "${HOME}"
+cat > hello-abseil.cc << EOF
+#include <cstdlib>
+
+#include "absl/strings/str_format.h"
+
+int main(int argc, char **argv) {
+ absl::PrintF("Hello Abseil!\n");
+ return EXIT_SUCCESS;
+}
+EOF
-if [[ ! "${lts_install}" ]]; then
- # Test that we warn if installed without a prefix or a system prefix
- output="$(install_absl 2>&1)"
- if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
- echo "Install without prefix didn't warn as expected. Output:"
- echo "${output}"
- exit 1
- fi
- uninstall_absl
-
- output="$(install_absl /usr 2>&1)"
- if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
- echo "Install with /usr didn't warn as expected. Output:"
- echo "${output}"
- exit 1
- fi
- uninstall_absl
+if [ "${LINK_TYPE:-}" != "DYNAMIC" ]; then
+ pc_args=($(pkg-config --cflags --libs --static absl_str_format))
+ g++ -static -o hello-abseil hello-abseil.cc "${pc_args[@]}"
+else
+ pc_args=($(pkg-config --cflags --libs absl_str_format))
+ g++ -o hello-abseil hello-abseil.cc "${pc_args[@]}"
fi
+hello="$(./hello-abseil)"
+[[ "${hello}" == "Hello Abseil!" ]]
+
+popd
echo "Install test complete!"
exit 0