You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2023/08/13 05:48:27 UTC

[logging-log4cxx] branch conditionally_find_boost created (now 3ff8b3c3)

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

swebb2066 pushed a change to branch conditionally_find_boost
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


      at 3ff8b3c3 Simplify CMake build configuration

This branch includes the following new commits:

     new 3ff8b3c3 Simplify CMake build configuration

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[logging-log4cxx] 01/01: Simplify CMake build configuration

Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3ff8b3c3e1bde361b54d71af7f97251490c21c41
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Sun Aug 13 15:48:09 2023 +1000

    Simplify CMake build configuration
---
 CMakeLists.txt                                     |  10 --
 src/cmake/boost-fallback/boost-fallback.cmake      | 136 +--------------------
 .../boost-fallback/boost-std-configuration.h.cmake |  18 ---
 3 files changed, 6 insertions(+), 158 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7fce97b3..a3036489 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,11 +230,6 @@ endif(LOG4CXX_QT_SUPPORT)
 #
 get_directory_property( HAS_LIBESMTP DIRECTORY src/main/include DEFINITION HAS_LIBESMTP )
 get_directory_property( HAS_SYSLOG DIRECTORY src/main/include DEFINITION HAS_SYSLOG )
-get_directory_property( THREAD_IMPL DIRECTORY src DEFINITION THREAD_IMPL )
-get_directory_property( SMART_PTR_IMPL DIRECTORY src DEFINITION SMART_PTR_IMPL )
-get_directory_property( MUTEX_IMPL DIRECTORY src DEFINITION MUTEX_IMPL )
-get_directory_property( SHARED_MUTEX_IMPL DIRECTORY src DEFINITION SHARED_MUTEX_IMPL )
-get_directory_property( ATOMIC_IMPL DIRECTORY src DEFINITION ATOMIC_IMPL )
 get_directory_property( FILESYSTEM_IMPL DIRECTORY src DEFINITION FILESYSTEM_IMPL )
 get_directory_property( STD_MAKE_UNIQUE_IMPL DIRECTORY src DEFINITION STD_MAKE_UNIQUE_IMPL )
 get_directory_property( STD_LIB_HAS_UNICODE_STRING DIRECTORY src DEFINITION STD_LIB_HAS_UNICODE_STRING )
@@ -310,12 +305,7 @@ message(STATUS "  Qt support ...................... : ${LOG4CXX_QT_SUPPORT}")
 message(STATUS "C++ version and Boost settings:")
 message(STATUS "  Prefer boost: ................... : ${PREFER_BOOST}")
 message(STATUS "  make_unique implementation :..... : ${STD_MAKE_UNIQUE_IMPL}")
-message(STATUS "  thread implementation ........... : ${THREAD_IMPL}")
 message(STATUS "  thread_local support? ........... : ${HAS_THREAD_LOCAL}")
-message(STATUS "  mutex implementation ............ : ${MUTEX_IMPL}")
-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}")
 
 if(BUILD_TESTING)
diff --git a/src/cmake/boost-fallback/boost-fallback.cmake b/src/cmake/boost-fallback/boost-fallback.cmake
index 1a0a8493..93952a92 100644
--- a/src/cmake/boost-fallback/boost-fallback.cmake
+++ b/src/cmake/boost-fallback/boost-fallback.cmake
@@ -1,48 +1,4 @@
-#include(${CMAKE_MODULE_PATH}/FindPackageHandleStandardArgs.cmake)
-
-# Checks for classes in std::, falling back to boost if the requested
-# classes are not available
-#
-# Available classes to check for:
-# thread
-# mutex
-# shared_mutex
-# filesystem
-#
-# Variables set:
-# ${prefix}_
-
-#function(_boost_fallback_thread)
-#    try_compile(HAS_STD_THREAD "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-#	"${CMAKE_CURRENT_LIST_DIR}/test-stdthread.cpp")
-
-
-#    find_package(boost_thread COMPONENTS thread)
-#endfunction()
-
-## check for boost fallback instead of std:: classes
-## arg1: prefix for variables to set
-## arg2: list of classes to check for
-#function(boost_fallback prefix classes)
-#endfunction()
-
-#
 # This module checks for C++ standard classes and their boost counterparts
-#
-# Thread variables set:
-# STD_THREAD_FOUND - if std::thread is found
-# Boost_THREAD_FOUND - if boost::thread is found
-#
-# Mutex variables set:
-# STD_MUTEX_FOUND - if std::mutex is found
-# STD_SHARED_MUTEX_FOUND - if std::shared_mutex is found
-# Boost_MUTEX_FOUND - if boost::mutex is found
-# Boost_SHARED_MUTEX_FOUND - if boost::shared_mutex is found
-#
-# Smart pointer variables set:
-# STD_SHARED_PTR_FOUND - if std::shared_ptr is found
-# Boost_SHARED_PTR_FOUND - if boost::shared_ptr is found
-#
 # Filesystem variables set:
 # STD_FILESYSTEM_FOUND - if std::filesystem is found
 # STD_EXPERIMENTAL_FILESYSTEM_FOUND - if std::experimental::filesystem is found
@@ -50,101 +6,21 @@
 
 include(FindThreads)
 
-try_compile(STD_THREAD_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-    "${CMAKE_CURRENT_LIST_DIR}/test-stdthread.cpp")
-try_compile(STD_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-    "${CMAKE_CURRENT_LIST_DIR}/test-stdmutex.cpp")
-try_compile(STD_SHARED_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-    "${CMAKE_CURRENT_LIST_DIR}/test-stdsharedmutex.cpp")
-try_compile(STD_SHARED_PTR_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-    "${CMAKE_CURRENT_LIST_DIR}/test-stdsharedptr.cpp")
-try_compile(STD_ATOMIC_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-    "${CMAKE_CURRENT_LIST_DIR}/test-stdatomic.cpp")
 try_compile(STD_FILESYSTEM_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
     "${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")
 
-# We need to have all three boost components in order to run our tests
-# Boost thread requires chrono and atomic to work
-find_package(Boost COMPONENTS thread chrono atomic)
-if( ${Boost_FOUND} )
-    try_compile(Boost_SHARED_PTR_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-        "${CMAKE_CURRENT_LIST_DIR}/test-boostsharedptr.cpp")
-    try_compile(Boost_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-        "${CMAKE_CURRENT_LIST_DIR}/test-boostmutex.cpp")
-    try_compile(Boost_SHARED_MUTEX_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-        "${CMAKE_CURRENT_LIST_DIR}/test-boostsharedmutex.cpp"
-        LINK_LIBRARIES Threads::Threads Boost::thread)
-    try_compile(Boost_ATOMIC_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-        "${CMAKE_CURRENT_LIST_DIR}/test-boostatomic.cpp")
-endif( ${Boost_FOUND} )
-
-find_package(Boost COMPONENTS filesystem)
-if( ${Boost_FOUND} )
-    try_compile(Boost_FILESYSTEM_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
-        "${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})
-        if(${Boost_THREAD_FOUND})
-           find_package(Boost COMPONENTS thread)
-           target_link_libraries( ${target} PUBLIC Boost::thread)
-        endif()
-    endif()
-    if(NOT ${STD_SHARED_MUTEX_FOUND})
-        if(${Boost_SHARED_MUTEX_FOUND})
-           find_package(Boost COMPONENTS thread)
-           target_link_libraries( ${target} PUBLIC Boost::thread)
-        endif()
-    endif()
-endfunction()
-
 # Check for standard headers that we need, fall back to boost if they're not found
 set(NAMESPACE_ALIAS log4cxx)
 option(PREFER_BOOST "Prefer Boost over std:: equivalents" OFF)
 
-if( ${STD_THREAD_FOUND} AND NOT ${PREFER_BOOST} )
-    set( THREAD_IMPL "std::thread" )
-elseif( ${Boost_THREAD_FOUND} )
-    set( THREAD_IMPL "boost::thread" )
-else()
-    set( THREAD_IMPL "NONE" )
-endif()
-
-if( ${STD_MUTEX_FOUND} AND NOT ${PREFER_BOOST} )
-    set( MUTEX_IMPL "std::mutex" )
-elseif( ${Boost_MUTEX_FOUND} )
-    set( MUTEX_IMPL "boost::mutex" )
-else()
-    set( MUTEX_IMPL "NONE" )
-endif()
-
-if( ${STD_SHARED_PTR_FOUND} AND NOT ${PREFER_BOOST} )
-    set( SMART_PTR_IMPL "std::shared_ptr" )
-elseif( ${Boost_SHARED_PTR_FOUND} )
-    set( SMART_PTR_IMPL "boost::shared_ptr" )
-else()
-    set( SMART_PTR_IMPL "NONE" )
-endif()
-
-if( ${STD_SHARED_MUTEX_FOUND} AND NOT ${PREFER_BOOST} )
-    set( SHARED_MUTEX_IMPL "std::shared_mutex" )
-elseif( ${Boost_SHARED_MUTEX_FOUND} )
-    set( SHARED_MUTEX_IMPL "boost::shared_mutex" )
-else()
-    set( SHARED_MUTEX_IMPL "NONE" )
-endif()
-
-if( ${STD_ATOMIC_FOUND} AND NOT ${PREFER_BOOST} )
-    set( ATOMIC_IMPL "std::atomic" )
-elseif( ${Boost_ATOMIC_FOUND} )
-    set( ATOMIC_IMPL "boost::atomic" )
-else()
-    set( ATOMIC_IMPL "NONE" )
+if( ${PREFER_BOOST} OR NOT ( ${STD_FILESYSTEM_FOUND} OR ${STD_EXPERIMENTAL_FILESYSTEM_FOUND} ) )
+    find_package(Boost COMPONENTS filesystem)
+    if( ${Boost_FOUND} )
+        try_compile(Boost_FILESYSTEM_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
+            "${CMAKE_CURRENT_LIST_DIR}/test-boostfilesystem.cpp")
+    endif( ${Boost_FOUND} )
 endif()
 
 if( ${STD_FILESYSTEM_FOUND} AND NOT ${PREFER_BOOST} )
diff --git a/src/cmake/boost-fallback/boost-std-configuration.h.cmake b/src/cmake/boost-fallback/boost-std-configuration.h.cmake
index 9ccf8fd9..a56b21ff 100644
--- a/src/cmake/boost-fallback/boost-std-configuration.h.cmake
+++ b/src/cmake/boost-fallback/boost-std-configuration.h.cmake
@@ -1,28 +1,10 @@
 #ifndef BOOST_STD_CONFIGURATION_H
 #define BOOST_STD_CONFIGURATION_H
 
-#cmakedefine01 STD_SHARED_MUTEX_FOUND
-#cmakedefine01 Boost_SHARED_MUTEX_FOUND
 #cmakedefine01 STD_FILESYSTEM_FOUND
 #cmakedefine01 Boost_FILESYSTEM_FOUND
 #cmakedefine01 STD_EXPERIMENTAL_FILESYSTEM_FOUND
 
-#if STD_SHARED_MUTEX_FOUND
-#include <shared_mutex>
-namespace ${NAMESPACE_ALIAS} {
-    typedef std::shared_mutex shared_mutex;
-    template <typename T>
-    using shared_lock = std::shared_lock<T>;
-}
-#elif Boost_SHARED_MUTEX_FOUND
-#include <boost/thread/shared_mutex.hpp>
-namespace ${NAMESPACE_ALIAS} {
-    typedef boost::shared_mutex shared_mutex;
-    template <typename T>
-    using shared_lock = boost::shared_lock<T>;
-}
-#endif
-
 #if STD_FILESYSTEM_FOUND
 #include <filesystem>
 namespace ${NAMESPACE_ALIAS} {