summaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake')
-rw-r--r--CMake/AbseilDll.cmake9
-rw-r--r--CMake/AbseilHelpers.cmake22
-rw-r--r--CMake/AbseilInstallDirs.cmake20
-rwxr-xr-xCMake/install_test_project/test.sh138
4 files changed, 53 insertions, 136 deletions
diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake
index 39f85f2f..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"
@@ -500,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(
@@ -518,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 1541435d..4f6394ab 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
@@ -151,6 +150,10 @@ function(absl_cc_library)
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()
@@ -167,14 +170,14 @@ function(absl_cc_library)
FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc" CONTENT "\
prefix=${CMAKE_INSTALL_PREFIX}\n\
exec_prefix=\${prefix}\n\
-libdir=\${prefix}/lib\n\
-includedir=\${prefix}/include\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.private:${PC_DEPS}\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"
@@ -235,7 +238,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
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})
@@ -260,7 +263,6 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
if(ABSL_ENABLE_INSTALL)
set_target_properties(${_NAME} PROPERTIES
OUTPUT_NAME "absl_${_NAME}"
- # TODO(b/173696973): Figure out how to set SOVERSION for LTS releases.
SOVERSION 0
)
endif()
@@ -270,7 +272,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
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")
@@ -290,9 +292,9 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
# 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()
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/install_test_project/test.sh b/CMake/install_test_project/test.sh
index ddc7726b..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,32 +62,8 @@ 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
@@ -129,34 +79,18 @@ int main(int argc, char **argv) {
return EXIT_SUCCESS;
}
EOF
-export PKG_CONFIG_PATH="${install_dir}/${libdir}/pkgconfig"
-pc_args=($(pkg-config --cflags --libs --static absl_str_format))
-g++ -static -o hello-abseil hello-abseil.cc "${pc_args[@]}"
+
+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
-uninstall_absl
popd
-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
-fi
-
echo "Install test complete!"
exit 0