This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch next_stable
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/next_stable by this push:
     new 918a7f58 Compile log4cxx in C++11 mode (#149)
918a7f58 is described below

commit 918a7f58512de913f60a7cbbe51b0b27e80bf0b1
Author: Robert Middleton <[email protected]>
AuthorDate: Wed Nov 16 19:53:26 2022 -0500

    Compile log4cxx in C++11 mode (#149)
    
    * Compile log4cxx in C++11 mode
---
 CMakeLists.txt                                           |  2 ++
 src/cmake/boost-fallback/boost-fallback.cmake            |  3 +++
 src/cmake/boost-fallback/boost-std-configuration.h.cmake | 11 +++++++++++
 src/cmake/boost-fallback/test-make-unique.cpp            |  6 ++++++
 src/main/include/CMakeLists.txt                          |  8 ++++++++
 5 files changed, 30 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 891c6784..74d38ab1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -189,6 +189,7 @@ get_directory_property( MUTEX_IMPL DIRECTORY 
src/main/include DEFINITION MUTEX_I
 get_directory_property( SHARED_MUTEX_IMPL DIRECTORY src/main/include 
DEFINITION SHARED_MUTEX_IMPL )
 get_directory_property( ATOMIC_IMPL DIRECTORY src/main/include DEFINITION 
ATOMIC_IMPL )
 get_directory_property( FILESYSTEM_IMPL DIRECTORY src/main/include DEFINITION 
FILESYSTEM_IMPL )
+get_directory_property( STD_MAKE_UNIQUE_IMPL DIRECTORY src/main/include 
DEFINITION STD_MAKE_UNIQUE_IMPL )
 
 foreach(varName HAS_STD_LOCALE  HAS_ODBC  HAS_MBSRTOWCS  HAS_WCSTOMBS  
HAS_FWIDE  HAS_LIBESMTP  HAS_SYSLOG)
   if(${varName} EQUAL 0)
@@ -269,6 +270,7 @@ message(STATUS "  shared_ptr implementation ....... : 
${SMART_PTR_IMPL}")
 message(STATUS "  shared_mutex implementation ..... : ${SHARED_MUTEX_IMPL}")
 message(STATUS "  atomic implementation ........... : ${ATOMIC_IMPL}")
 message(STATUS "  filesystem implementation ....... : ${FILESYSTEM_IMPL}")
+message(STATUS "  std::make_unique found? ......... : ${STD_MAKE_UNIQUE_IMPL}")
 
 if(BUILD_TESTING)
 message(STATUS "Applications required for tests:")
diff --git a/src/cmake/boost-fallback/boost-fallback.cmake 
b/src/cmake/boost-fallback/boost-fallback.cmake
index 8de5f314..8473721f 100644
--- a/src/cmake/boost-fallback/boost-fallback.cmake
+++ b/src/cmake/boost-fallback/boost-fallback.cmake
@@ -64,6 +64,8 @@ try_compile(STD_FILESYSTEM_FOUND 
"${CMAKE_BINARY_DIR}/boost-fallback-compile-tes
     "${CMAKE_CURRENT_LIST_DIR}/test-stdfilesystem.cpp")
 try_compile(STD_EXPERIMENTAL_FILESYSTEM_FOUND 
"${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
     "${CMAKE_CURRENT_LIST_DIR}/test-stdexpfilesystem.cpp")
+try_compile(STD_MAKE_UNIQUE_FOUND 
"${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+    "${CMAKE_CURRENT_LIST_DIR}/test-make-unique.cpp")
 
 # We need to have all three boost components in order to run our tests
 # Boost thread requires chrono and atomic to work
@@ -86,6 +88,7 @@ if( ${Boost_FOUND} )
         "${CMAKE_CURRENT_LIST_DIR}/test-boostfilesystem.cpp")
 endif( ${Boost_FOUND} )
 
+
 # Link the target with the appropriate boost libraries(if required)
 function(boostfallback_link target)
     if(NOT ${STD_THREAD_FOUND})
diff --git a/src/cmake/boost-fallback/boost-std-configuration.h.cmake 
b/src/cmake/boost-fallback/boost-std-configuration.h.cmake
index 9ccf8fd9..f319bcb6 100644
--- a/src/cmake/boost-fallback/boost-std-configuration.h.cmake
+++ b/src/cmake/boost-fallback/boost-std-configuration.h.cmake
@@ -6,6 +6,7 @@
 #cmakedefine01 STD_FILESYSTEM_FOUND
 #cmakedefine01 Boost_FILESYSTEM_FOUND
 #cmakedefine01 STD_EXPERIMENTAL_FILESYSTEM_FOUND
+#cmakedefine01 STD_MAKE_UNIQUE_FOUND
 
 #if STD_SHARED_MUTEX_FOUND
 #include <shared_mutex>
@@ -46,4 +47,14 @@ namespace filesystem {
 }
 #endif
 
+#if !STD_MAKE_UNIQUE_FOUND
+namespace std{
+template<typename T, typename ...Args>
+std::unique_ptr<T> make_unique( Args&& ...args )
+{
+    return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
+}
+}
+#endif
+
 #endif /* BOOST_STD_CONFIGURATION_H */
diff --git a/src/cmake/boost-fallback/test-make-unique.cpp 
b/src/cmake/boost-fallback/test-make-unique.cpp
new file mode 100644
index 00000000..380cfdad
--- /dev/null
+++ b/src/cmake/boost-fallback/test-make-unique.cpp
@@ -0,0 +1,6 @@
+#include <memory>
+
+int main(int argc, char** argv){
+       std::make_unique<int>(5);
+       return 0;
+}
diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt
index 8b7a3af9..3b235249 100644
--- a/src/main/include/CMakeLists.txt
+++ b/src/main/include/CMakeLists.txt
@@ -232,6 +232,14 @@ else()
        set( FILESYSTEM_IMPL "NONE" )
 endif()
 
+if( ${STD_MAKE_UNIQUE_FOUND} )
+    set(STD_MAKE_UNIQUE_IMPL "std::make_unique")
+    set(STD_MAKE_UNIQUE_FOUND 1)
+else()
+    set(STD_MAKE_UNIQUE_IMPL "log4cxx std::make_unique")
+    set(STD_MAKE_UNIQUE_FOUND 0)
+endif()
+
 # Configure both our private header and our public header
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.h.in
                ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/private/log4cxx_private.h

Reply via email to