mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-24 10:42:31 +03:00
C++11 checks in CMakeLists.txt, added atomic.hpp
Check if the superproject has already enabled C++11 before enabling it in CMakeLists.txt. Added utility file atomic.hpp to select the correct atomics header to work around issues with ancient GCC 4.4.
This commit is contained in:
@ -28,7 +28,23 @@ option(WSREP_LIB_STRICT_BUILD_FLAGS "Compile with strict build flags" OFF)
|
||||
option(WSREP_LIB_MAINTAINER_MODE "Fail compilation on any warnings" OFF)
|
||||
|
||||
# Compiler options
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
# Set std to C++0x/C++11 if superproject has not set standard yet
|
||||
if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 11)
|
||||
string(FIND "${CMAKE_CXX_FLAGS}" "-std=" HAVE_STD)
|
||||
if (HAVE_STD EQUAL -1)
|
||||
if (CMAKE_VERSION VERSION_LESS "3.1")
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
|
||||
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# CXX flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Woverloaded-virtual -g")
|
||||
@ -40,10 +56,9 @@ if (WSREP_LIB_MAINTAINER_MODE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
endif()
|
||||
|
||||
check_include_file("${CMAKE_CURRENT_SOURCE_DIR}/wsrep/wsrep_api.h" HAVE_WSREP_API_HPP)
|
||||
# Set up include directories
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/wsrep-API/v26")
|
||||
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/wsrep")
|
||||
|
||||
if (WSREP_LIB_WITH_UNIT_TESTS)
|
||||
find_package(Boost 1.54.0 REQUIRED
|
||||
|
29
include/wsrep/atomic.hpp
Normal file
29
include/wsrep/atomic.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Codership Oy <info@codership.com>
|
||||
*
|
||||
* This file is part of wsrep-lib.
|
||||
*
|
||||
* Wsrep-lib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Wsrep-lib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with wsrep-lib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WSREP_ATOMIC_HPP
|
||||
#define WSREP_ATOMIC_HPP
|
||||
|
||||
#if defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
|
||||
#include <cstdatomic>
|
||||
#else
|
||||
#include <atomic>
|
||||
#endif // defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
|
||||
|
||||
#endif // WSREP_ATOMIC_HPP
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
* Copyright (C) 2018-2019 Codership Oy <info@codership.com>
|
||||
*
|
||||
* This file is part of wsrep-lib.
|
||||
*
|
||||
@ -22,10 +22,10 @@
|
||||
|
||||
#include "mutex.hpp"
|
||||
#include "lock.hpp"
|
||||
#include "atomic.hpp"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
#include <atomic>
|
||||
|
||||
#define WSREP_LOG_DEBUG(debug_level_fn, debug_level, msg) \
|
||||
do { \
|
||||
|
Reference in New Issue
Block a user