]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
update C++11 detection
authorAndrei Pavel <andrei@isc.org>
Sat, 21 Aug 2021 02:16:01 +0000 (05:16 +0300)
committerAndrei Pavel <andrei@isc.org>
Sat, 21 Aug 2021 02:16:01 +0000 (05:16 +0300)
m4macros/ax_cpp11.m4
m4macros/ax_gtest.m4

index 61767280163c3a80e9cf6cc6ada58c2127e3671b..99457f9491df253e2b5a74822f030bc923110e7c 100644 (file)
@@ -3,235 +3,236 @@ AC_DEFUN([AX_ISC_CPP11], [
 CXX_SAVED=$CXX
 feature=
 for retry in "none" "--std=c++11" "--std=c++0x" "--std=c++1x" "fail"; do
-       if test "$retry" = "fail"; then
-               AC_MSG_ERROR([$feature (a C++11 feature) is not supported])
-       fi
-       if test "$retry" != "none"; then
-               AC_MSG_WARN([unsupported C++11 feature])
-               AC_MSG_NOTICE([retrying by adding $retry to $CXX])
-               CXX="$CXX_SAVED $retry"
-               AC_MSG_CHECKING($retry support)
-               AC_COMPILE_IFELSE(
-                       [AC_LANG_PROGRAM(
-                               [],
-                               [int myincr = 1;])],
-                       [AC_MSG_RESULT([yes])],
-                       [AC_MSG_RESULT([no])
-                        continue])
-       fi
-
-       AC_MSG_CHECKING(std::unique_ptr support)
-       feature="std::unique_ptr"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <memory>],
-                       [std::unique_ptr<int> a;])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(cbegin/cend support)
-       feature="cbegin/cend"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <string>],
-                       [const std::string& s = "abcd";
-                        unsigned count = 0;
-                        for (std::string::const_iterator i = s.cbegin();
-                             i != s.cend(); ++i)
-                               if (*i == 'b')
-                                       ++count;])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(final method support)
-       feature="final method"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [class Foo {
-                        public:
-                               virtual ~Foo() {};
-                               virtual void bar() final;
-                        };],[])],
-                [AC_MSG_RESULT([yes])],
-                [AC_MSG_RESULT([no])
-                 continue])
-
-       AC_MSG_CHECKING(override method support)
-       feature="override method"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [class Foo {
-                        public:
-                               virtual ~Foo() {};
-                               virtual void foobar();
-                        };
-                        class Bar : public Foo {
-                        public:
-                               virtual ~Bar() {};
-                               virtual void foobar() override;
-                        };],[])],
-                [AC_MSG_RESULT([yes])],
-                [AC_MSG_RESULT([no])
-                 continue])
-
-       AC_MSG_CHECKING(aggregate initialization support)
-       feature="aggregate initialization"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <vector>],
-                       [std::vector<int> foo = { 1, 2, 3};])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(variadic template support)
-       feature="variadic template"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [template<typename ... Args>
-                        struct A {
-                        void foo(Args... myargs) { return; };
-                        };],
-                        [A<> a;
-                         a.foo();])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(static_assert support)
-       feature="static_assert"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [static_assert(1 + 1 == 2, "");],
-                       [])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(template alias)
-       feature="template alias"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [template<int i>
-                        class I {
-                        public: int get() { return i; };
-                        };
-                        using Zero = I<0>;],
-                       [Zero Z;
-                        return Z.get();])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(constexpr support)
-       feature="constexpr"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <string>
-                        typedef char const* const Tag;
-                        constexpr Tag FOOBAR = "FOOBAR";],
-                       [const std::string foobar(FOOBAR);
-                        return static_cast<int>(foobar.length());])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(enum class support)
-       feature="enum class"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [enum class FooBar {
-                            FOO = 1,
-                            BAR = 2
-                        };],
-                       [FooBar f = FooBar::FOO;
-                        return (f == FooBar::FOO ? 1 : 2);])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(range-for support)
-       feature="range-for support"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <vector>
-                        std::vector<int> v = { 1, 2, 3, 4 };],
-                       [int sum = 0;
-                        for (auto i : v) {
-                            sum += i;
-                        }
-                        return sum;])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(lambda support)
-       feature="lambda"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [],
-                       [auto myincr = [[]](int x) { return x + 1; };])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(thread support)
-       feature="thread"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <thread>
-                        std::shared_ptr<std::thread> th;],
-                       [th.reset(new std::thread([[]]() { return; }));
-                        th->join();])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(mutex support)
-       feature="mutex"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <mutex>
-                        std::mutex mtx;],
-                       [std::lock_guard<std::mutex> lock(mtx);])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-                        
-       AC_MSG_CHECKING(condition variable support)
-       feature="condition variable"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <condition_variable>
-                        std::mutex mtx;
-                        std::condition_variable cv;],
-                       [std::lock_guard<std::mutex> lock(mtx);
-                        cv.notify_one();])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-                        
-       AC_MSG_CHECKING(atomic support)
-       feature="atomic"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <atomic>
-                        std::atomic_flag flag;],
-                       [])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-        AC_MSG_CHECKING(chrono support)
-        feature="chrono"
-        AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <chrono>
-                        using namespace std::chrono;],
-                       [auto now = high_resolution_clock::now();])],
-               [AC_MSG_RESULT([yes])
+        if test "$retry" = "fail"; then
+                AC_MSG_ERROR([$feature (a C++11 feature) is not supported])
+        fi
+        if test "$retry" != "none"; then
+                AC_MSG_WARN([unsupported C++11 feature])
+                AC_MSG_NOTICE([retrying by adding $retry to $CXX])
+                CXX="$CXX_SAVED $retry"
+                AC_MSG_CHECKING($retry support)
+                AC_COMPILE_IFELSE(
+                        [AC_LANG_PROGRAM(
+                                [],
+                                [int myincr = 1;])],
+                        [AC_MSG_RESULT([yes])],
+                        [AC_MSG_RESULT([no])
+                         continue])
+        fi
+
+        AC_MSG_CHECKING(std::unique_ptr support)
+        feature="std::unique_ptr"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <memory>],
+                        [std::unique_ptr<int> a;])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(cbegin/cend support)
+        feature="cbegin/cend"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <string>],
+                        [const std::string& s = "abcd";
+                         unsigned count = 0;
+                         for (std::string::const_iterator i = s.cbegin();
+                              i != s.cend(); ++i)
+                                if (*i == 'b')
+                                        ++count;])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(final method support)
+        feature="final method"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [class Foo {
+                         public:
+                                virtual ~Foo() {};
+                                virtual void bar() final;
+                         };],[])],
+                 [AC_MSG_RESULT([yes])],
+                 [AC_MSG_RESULT([no])
+                  continue])
+
+        AC_MSG_CHECKING(override method support)
+        feature="override method"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [class Foo {
+                         public:
+                                virtual ~Foo() {};
+                                virtual void foobar();
+                         };
+                         class Bar : public Foo {
+                         public:
+                                virtual ~Bar() {};
+                                virtual void foobar() override;
+                         };],[])],
+                 [AC_MSG_RESULT([yes])],
+                 [AC_MSG_RESULT([no])
+                  continue])
+
+        AC_MSG_CHECKING(aggregate initialization support)
+        feature="aggregate initialization"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <vector>],
+                        [std::vector<int> foo = { 1, 2, 3};])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(variadic template support)
+        feature="variadic template"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [template<typename ... Args>
+                         struct A {
+                         void foo(Args... myargs) { return; };
+                         };],
+                         [A<> a;
+                          a.foo();])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(static_assert support)
+        feature="static_assert"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [static_assert(1 + 1 == 2, "");],
+                        [])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(template alias)
+        feature="template alias"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [template<int i>
+                         class I {
+                         public: int get() { return i; };
+                         };
+                         using Zero = I<0>;],
+                        [Zero Z;
+                         return Z.get();])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(constexpr support)
+        feature="constexpr"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <string>
+                         typedef char const* const Tag;
+                         constexpr Tag FOOBAR = "FOOBAR";],
+                        [const std::string foobar(FOOBAR);
+                         return static_cast<int>(foobar.length());])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(enum class support)
+        feature="enum class"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [enum class FooBar {
+                             FOO = 1,
+                             BAR = 2
+                         };],
+                        [FooBar f = FooBar::FOO;
+                         return (f == FooBar::FOO ? 1 : 2);])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(range-for support)
+        feature="range-for support"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <vector>
+                         std::vector<int> v = { 1, 2, 3, 4 };],
+                        [int sum = 0;
+                         for (auto i : v) {
+                             sum += i;
+                         }
+                         return sum;])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(lambda support)
+        feature="lambda"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [],
+                        [auto myincr = [[]](int x) { return x + 1; };])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(thread support)
+        feature="thread"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <thread>
+                         #include <memory>
+                         std::shared_ptr<std::thread> th;],
+                        [th.reset(new std::thread([[]]() { return; }));
+                         th->join();])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(mutex support)
+        feature="mutex"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <mutex>
+                         std::mutex mtx;],
+                        [std::lock_guard<std::mutex> lock(mtx);])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(condition variable support)
+        feature="condition variable"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <condition_variable>
+                         std::mutex mtx;
+                         std::condition_variable cv;],
+                        [std::lock_guard<std::mutex> lock(mtx);
+                         cv.notify_one();])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+        AC_MSG_CHECKING(atomic support)
+        feature="atomic"
+        AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <atomic>
+                         std::atomic_flag flag;],
+                        [])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+         AC_MSG_CHECKING(chrono support)
+         feature="chrono"
+         AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                        [#include <chrono>
+                         using namespace std::chrono;],
+                        [auto now = high_resolution_clock::now();])],
+                [AC_MSG_RESULT([yes])
                  break],
                 [AC_MSG_RESULT([no])
                  continue])
index edd729dd90af5a0766be2ce51b84dba3dc92da20..06403ba857f55daff8061cad63f9fa5170e285af 100644 (file)
@@ -100,7 +100,7 @@ if test "x$enable_gtest" = "xyes" ; then
 
 # Versions starting from 1.8.0 are put in the googletest directory. If the basename
 # returns googletest string, we need to cut it off and try baseline again.
-        if test "$GTEST_VERSION" == "googletest"; then
+        if test "$GTEST_VERSION" = "googletest"; then
             GTEST_VERSION=${GTEST_SOURCE%"/googletest"}
             GTEST_VERSION=`basename $GTEST_VERSION`
         fi
@@ -135,15 +135,16 @@ if test "x$enable_gtest" = "xyes" ; then
             GTEST_FOUND="false"
             for dir in $GTEST_PATHS; do
                 if test -f "$dir/include/gtest/gtest.h"; then
-                    if ! test -f "$dir/lib/libgtest.a"; then
+                    if test -f "$dir/lib/libgtest.a" || \
+                       test -f "$dir/lib/libgtest.so"; then
+                        GTEST_INCLUDES="-I$dir/include"
+                        GTEST_LDFLAGS="-L$dir/lib"
+                        GTEST_LDADD="-lgtest"
+                        GTEST_FOUND="true"
+                        break
+                    else
                         AC_MSG_WARN([Found Google Test include but not the library in $dir.])
-                        continue
                     fi
-                    GTEST_INCLUDES="-I$dir/include"
-                    GTEST_LDFLAGS="-L$dir/lib"
-                    GTEST_LDADD="-lgtest"
-                    GTEST_FOUND="true"
-                    break
                 fi
             done
         fi