added SmallVector alias with conditional boost::container version (#3799)
* printInfo.cmake: small cleanup * added SmallVector alias with conditional boost::container version Co-authored-by: Ken-Patrick Lehrmann <kp.lehrmann+github@gmail.com> * smallvector.h: added custom allocator to regular SmallVector version Co-authored-by: Ken-Patrick Lehrmann <kp.lehrmann+github@gmail.com> Co-authored-by: Paul Fultz II <pfultz2@yahoo.com>
This commit is contained in:
parent
469575cb21
commit
9d4fb16d7d
|
@ -23,6 +23,10 @@ if (USE_Z3)
|
|||
add_definitions(-DUSE_Z3)
|
||||
endif()
|
||||
|
||||
if (Boost_FOUND)
|
||||
add_definitions(-DHAVE_BOOST)
|
||||
endif()
|
||||
|
||||
if (ENABLE_CHECK_INTERNAL)
|
||||
add_definitions(-DCHECK_INTERNAL)
|
||||
endif()
|
||||
|
|
|
@ -60,3 +60,7 @@ endif()
|
|||
if (USE_THREADS)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
|
||||
if (USE_BOOST)
|
||||
find_package(Boost COMPONENTS container QUIET)
|
||||
endif()
|
||||
|
|
|
@ -44,6 +44,7 @@ option(USE_Z3 "Usage of z3 library"
|
|||
option(USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON)
|
||||
option(CPPCHK_GLIBCXX_DEBUG "Usage of _GLIBCXX_DEBUG in Debug build" ON)
|
||||
option(USE_THREADS "Usage of threads instead of fork() for -j" OFF)
|
||||
option(USE_BOOST "Usage of Boost" OFF)
|
||||
|
||||
if (CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16")
|
||||
set(CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers")
|
||||
|
|
|
@ -10,6 +10,7 @@ message( STATUS "C++ flags (General) = ${CMAKE_CXX_FLAGS}")
|
|||
message( STATUS "C++ flags (Release) = ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
message( STATUS "C++ flags (RelWithDebInfo) = ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
message( STATUS "C++ flags (Debug) = ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
message( STATUS "CPPCHK_GLIBCXX_DEBUG = ${CPPCHK_GLIBCXX_DEBUG}" )
|
||||
get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
|
||||
foreach( d ${DirDefs} )
|
||||
message( STATUS "Found Define: " ${d} )
|
||||
|
@ -62,11 +63,19 @@ if (USE_Z3)
|
|||
message( STATUS "Z3_LIBRARIES = ${Z3_LIBRARIES}" )
|
||||
message( STATUS "Z3_CXX_INCLUDE_DIRS = ${Z3_CXX_INCLUDE_DIRS}" )
|
||||
endif()
|
||||
message( STATUS )
|
||||
message( STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}" )
|
||||
if (NOT USE_BUNDLED_TINYXML2)
|
||||
message(STATUS "tinyxml2_LIBRARIES = ${tinyxml2_LIBRARIES}")
|
||||
endif()
|
||||
message( STATUS )
|
||||
message( STATUS "USE_BOOST = ${USE_BOOST}" )
|
||||
if (USE_BOOST)
|
||||
message( STATUS "Boost_FOUND = ${Boost_FOUND}")
|
||||
message( STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}")
|
||||
message( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
|
||||
endif()
|
||||
message( STATUS )
|
||||
|
||||
if(${ANALYZE_ADDRESS})
|
||||
message("##########################################################")
|
||||
|
|
|
@ -45,6 +45,9 @@ endif()
|
|||
if (USE_Z3)
|
||||
target_include_directories(lib_objs SYSTEM PRIVATE ${Z3_CXX_INCLUDE_DIRS})
|
||||
endif()
|
||||
if (Boost_FOUND)
|
||||
target_include_directories(lib_objs SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
|
||||
target_precompile_headers(lib_objs PRIVATE precompiled.h)
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Cppcheck - A tool for static C/C++ code analysis
|
||||
* Copyright (C) 2007-2022 Cppcheck team.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef smallvectorH
|
||||
#define smallvectorH
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
static constexpr std::size_t DefaultSmallVectorSize = 0;
|
||||
|
||||
#ifdef HAVE_BOOST
|
||||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
template<typename T, std::size_t N = DefaultSmallVectorSize>
|
||||
using SmallVector = boost::container::small_vector<T, N>;
|
||||
#else
|
||||
#include <vector>
|
||||
|
||||
template<class T, std::size_t N>
|
||||
struct TaggedAllocator : std::allocator<T>
|
||||
{
|
||||
template<class ... Ts>
|
||||
TaggedAllocator(Ts&&... ts)
|
||||
: std::allocator<T>(std::forward<Ts>(ts)...)
|
||||
{}
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N = DefaultSmallVectorSize>
|
||||
using SmallVector = std::vector<T, TaggedAllocator<T, N>>;
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue