diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b4488e..379e3c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/include/wsrep/atomic.hpp b/include/wsrep/atomic.hpp new file mode 100644 index 0000000..6d92c16 --- /dev/null +++ b/include/wsrep/atomic.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 Codership Oy + * + * 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 . + */ + +#ifndef WSREP_ATOMIC_HPP +#define WSREP_ATOMIC_HPP + +#if defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4) +#include +#else +#include +#endif // defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4) + +#endif // WSREP_ATOMIC_HPP diff --git a/include/wsrep/logger.hpp b/include/wsrep/logger.hpp index 7b82ccb..c9317fd 100644 --- a/include/wsrep/logger.hpp +++ b/include/wsrep/logger.hpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Codership Oy + * Copyright (C) 2018-2019 Codership Oy * * This file is part of wsrep-lib. * @@ -22,10 +22,10 @@ #include "mutex.hpp" #include "lock.hpp" +#include "atomic.hpp" #include #include -#include #define WSREP_LOG_DEBUG(debug_level_fn, debug_level, msg) \ do { \