Skip to content

Commit

Permalink
LOGCXX-528 (#66)
Browse files Browse the repository at this point in the history
Fixes for checking that C++11 is available.  Fix for older compilers.
  • Loading branch information
rm5248 committed Jul 22, 2021
1 parent 1649f33 commit 249dd85
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 13 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Expand Up @@ -41,6 +41,9 @@ if( NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 17)
endif()

# Don't allow for compiler-specific extensions
set(CMAKE_CXX_EXTENSIONS OFF)

# Building
add_subdirectory(src)

Expand Down Expand Up @@ -185,6 +188,13 @@ if(APACHE_MAINTAINER)
)
endif()

#
# Check for any fatal configuration errors
#
if( "${SHARED_MUTEX_IMPL}" STREQUAL "NONE" )
message( FATAL_ERROR "No shared_mutex implementation found. Requires Boost or C++17" )
endif()

#
# Output configuration information
# Similar to APR CMake configuration
Expand Down
21 changes: 11 additions & 10 deletions src/cmake/boost-fallback/boost-fallback.cmake
Expand Up @@ -56,16 +56,17 @@ try_compile(STD_ATOMIC_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
"${CMAKE_CURRENT_LIST_DIR}/test-stdatomic.cpp")

find_package(Boost COMPONENTS thread)
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
)
try_compile(Boost_ATOMIC_FOUND "${CMAKE_BINARY_DIR}/boost-fallback-compile-tests"
"${CMAKE_CURRENT_LIST_DIR}/test-boostatomic.cpp")
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} )

# Link the target with the appropriate boost libraries(if required)
function(boostfallback_link target)
Expand Down
4 changes: 2 additions & 2 deletions src/main/cpp/hierarchy.cpp
Expand Up @@ -223,7 +223,7 @@ LoggerPtr Hierarchy::getLogger(const LogString& name,
else
{
LoggerPtr logger(factory->makeNewLoggerInstance(pool, name));
logger->setHierarchy(weak_from_this());
logger->setHierarchy(shared_from_this());
loggers->insert(LoggerMap::value_type(name, logger));

ProvisionNodeMap::iterator it2 = provisionNodes->find(name);
Expand Down Expand Up @@ -423,6 +423,6 @@ void Hierarchy::configureRoot(){
// LOGCXX-322 we need to turn the repositroy into a weak_ptr, and we
// can't use weak_from_this() in the constructor.
if( !root->getLoggerRepository().lock() ){
root->setHierarchy(weak_from_this());
root->setHierarchy(shared_from_this());
}
}
2 changes: 1 addition & 1 deletion src/main/include/CMakeLists.txt
Expand Up @@ -133,7 +133,7 @@ if( ${STD_SHARED_MUTEX_FOUND} )
elseif( ${Boost_SHARED_MUTEX_FOUND} )
set( SHARED_MUTEX_IMPL "boost::shared_mutex" )
else()
set( SMART_PTR_IMPL "NONE" )
set( SHARED_MUTEX_IMPL "NONE" )
endif()

if( ${STD_ATOMIC_FOUND} )
Expand Down
1 change: 1 addition & 0 deletions src/main/include/log4cxx/helpers/appenderattachableimpl.h
Expand Up @@ -28,6 +28,7 @@
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/log4cxx.h>
#include <mutex>

namespace log4cxx
{
Expand Down
1 change: 1 addition & 0 deletions src/main/include/log4cxx/helpers/aprinitializer.h
Expand Up @@ -30,6 +30,7 @@ extern "C" {
}

#include <apr_time.h>
#include <mutex>

namespace log4cxx
{
Expand Down
1 change: 1 addition & 0 deletions src/main/include/log4cxx/helpers/loglog.h
Expand Up @@ -20,6 +20,7 @@

#include <log4cxx/logstring.h>
#include <exception>
#include <mutex>

namespace log4cxx
{
Expand Down
1 change: 1 addition & 0 deletions src/main/include/log4cxx/helpers/serversocket.h
Expand Up @@ -19,6 +19,7 @@
#define _LOG4CXX_HELPERS_SERVER_SOCKET_H

#include <log4cxx/helpers/socket.h>
#include <mutex>

namespace log4cxx
{
Expand Down
1 change: 1 addition & 0 deletions src/main/include/log4cxx/level.h
Expand Up @@ -22,6 +22,7 @@
#include <log4cxx/logstring.h>
#include <limits.h>
#include <log4cxx/helpers/object.h>
#include <mutex>

#if defined(_MSC_VER)
#pragma warning ( push )
Expand Down
1 change: 1 addition & 0 deletions src/main/include/log4cxx/rolling/action.h
Expand Up @@ -21,6 +21,7 @@
#include <log4cxx/portability.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/pool.h>
#include <mutex>

namespace log4cxx
{
Expand Down

0 comments on commit 249dd85

Please sign in to comment.