Skip to content

Commit

Permalink
use ABSL_PROPAGATE_CXX_STD=ON and set C++17 also on windows
Browse files Browse the repository at this point in the history
switches to the non-deprecated option, but also needs to patch
upstream to actually propagate C++17 instead of C++11, compare:
https://github.com/abseil/abseil-cpp/blob/20211102.0/CMake/AbseilHelpers.cmake#L257-L273
  • Loading branch information
h-vetinari committed Mar 2, 2022
1 parent 2f99657 commit adeffe5
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 8 deletions.
11 changes: 9 additions & 2 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

mkdir build
cd build

REM regarding ABSL_PROPAGATE_CXX_STD:
REM enforce consuming libraries to compile using at least the same C++ standard, see
REM patches/0006-propagate-requirement-of-C-17-to-consumers.patch as well as
REM https://github.com/abseil/abseil-cpp/blob/20211102.0/CMake/AbseilHelpers.cmake#L257-L273
cmake -GNinja ^
-DABSL_PROPAGATE_CXX_STD=ON ^
-DBUILD_SHARED_LIBS=ON ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
-DCMAKE_BUILD_TYPE=Release ^
-DBUILD_SHARED_LIBS=ON ^
..
if %ERRORLEVEL% neq 0 exit 1

Expand Down
5 changes: 5 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set -exuo pipefail
mkdir -p build
cd build

# regarding ABSL_PROPAGATE_CXX_STD:
# enforce consuming libraries to compile using at least the same C++ standard, see
# patches/0006-propagate-requirement-of-C-17-to-consumers.patch as well as
# https://github.com/abseil/abseil-cpp/blob/20211102.0/CMake/AbseilHelpers.cmake#L257-L273
cmake ${CMAKE_ARGS} \
-DABSL_PROPAGATE_CXX_STD=ON \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
Expand Down
4 changes: 3 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ source:
# experimental
- patches/0004-alphabetize-ABSL_INTERNAL_DLL_TARGETS.patch
- patches/0005-expand-ABSL_INTERNAL_DLL_TARGETS.patch
- patches/0006-propagate-requirement-of-C-17-to-consumers.patch
- patches/0007-also-set-target_compile_features-for-abseil_dll.patch

build:
number: 2
number: 3
run_exports:
- {{ pin_subpackage("abseil-cpp", max_pin="x.x") }}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 50b8f574cfc8a6868f9fc74741c384f50e3ef540 Mon Sep 17 00:00:00 2001
From: Francesco Biscani <bluescarni@gmail.com>
Date: Sat, 21 Sep 2019 15:05:46 +0200
Subject: [PATCH 1/5] patch out the build issue on clang4 osx
Subject: [PATCH 1/7] patch out the build issue on clang4 osx

---
absl/time/internal/cctz/include/cctz/civil_time_detail.h | 4 ++++
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 341b5875ad617a45600d19ac03d78e68ef8a39b0 Mon Sep 17 00:00:00 2001
From: Francesco Biscani <bluescarni@gmail.com>
Date: Sat, 21 Sep 2019 21:39:26 +0200
Subject: [PATCH 2/5] fix for linking to the CoreFoundation framework on OSX
Subject: [PATCH 2/7] fix for linking to the CoreFoundation framework on OSX

---
absl/time/CMakeLists.txt | 6 ++++--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 958c72f3853ff0c7ab1d9718aedd3ec34b7e5c45 Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <uwe.korn@quantco.com>
Date: Thu, 30 Jul 2020 13:01:32 +0200
Subject: [PATCH 3/5] remove "-ignore:4221" from ABSL_MSVC_LINKOPTS
Subject: [PATCH 3/7] remove "-ignore:4221" from ABSL_MSVC_LINKOPTS

see also https://github.com/microsoft/vcpkg/issues/13945
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 48bfdfc5de1b6be894a72a09e7c30e9afd173fbc Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Wed, 2 Mar 2022 08:07:20 +1100
Subject: [PATCH 4/5] alphabetize ABSL_INTERNAL_DLL_TARGETS
Subject: [PATCH 4/7] alphabetize ABSL_INTERNAL_DLL_TARGETS

---
CMake/AbseilDll.cmake | 174 +++++++++++++++++++++---------------------
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0005-expand-ABSL_INTERNAL_DLL_TARGETS.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3f1a7ba1cffb66ec5ba6bc2c2dff5ae5988bcc94 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Wed, 2 Mar 2022 13:43:37 +1100
Subject: [PATCH 5/5] expand ABSL_INTERNAL_DLL_TARGETS
Subject: [PATCH 5/7] expand ABSL_INTERNAL_DLL_TARGETS

This is due to how the logic of absl_internal_dll_contains checks
whether additional static libraries should be built, compare
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 3b748914f9a91b1796f15b8a531c2b41033a602d Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Wed, 2 Mar 2022 12:34:33 +1100
Subject: [PATCH 6/7] propagate requirement of C++17 to consumers

---
CMake/AbseilHelpers.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake
index f2ce567..6758890 100644
--- a/CMake/AbseilHelpers.cmake
+++ b/CMake/AbseilHelpers.cmake
@@ -258,7 +258,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
# Abseil libraries require C++11 as the current minimum standard.
# Top-level application CMake projects should ensure a consistent C++
# standard for all compiled sources by setting CMAKE_CXX_STANDARD.
- target_compile_features(${_NAME} PUBLIC cxx_std_11)
+ target_compile_features(${_NAME} PUBLIC cxx_std_17)
else()
# Note: This is legacy (before CMake 3.8) behavior. Setting the
# target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is
--
2.35.1.windows.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From f60a3404b0e21b56220ecef491db76bbddf32639 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Wed, 2 Mar 2022 13:10:15 +1100
Subject: [PATCH 7/7] also set target_compile_features for abseil_dll

---
CMake/AbseilDll.cmake | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake
index aec198e..5cbf5d0 100644
--- a/CMake/AbseilDll.cmake
+++ b/CMake/AbseilDll.cmake
@@ -538,6 +538,25 @@ function(absl_make_dll)
PRIVATE
${ABSL_DEFAULT_LINKOPTS}
)
+
+ if(ABSL_PROPAGATE_CXX_STD)
+ # Abseil libraries require C++11 as the current minimum standard.
+ # Top-level application CMake projects should ensure a consistent C++
+ # standard for all compiled sources by setting CMAKE_CXX_STANDARD.
+ target_compile_features(abseil_dll PUBLIC cxx_std_17)
+ else()
+ # Note: This is legacy (before CMake 3.8) behavior. Setting the
+ # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is
+ # initialized by CMAKE_CXX_STANDARD) should have no real effect, since
+ # that is the default value anyway.
+ #
+ # CXX_STANDARD_REQUIRED does guard against the top-level CMake project
+ # not having enabled CMAKE_CXX_STANDARD_REQUIRED (which prevents
+ # "decaying" to an older standard if the requested one isn't available).
+ set_property(TARGET abseil_dll PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
+ set_property(TARGET abseil_dll PROPERTY CXX_STANDARD_REQUIRED ON)
+ endif()
+
set_property(TARGET abseil_dll PROPERTY LINKER_LANGUAGE "CXX")
target_include_directories(
abseil_dll
--
2.35.1.windows.2

0 comments on commit adeffe5

Please sign in to comment.