-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d823897
commit 67c377c
Showing
42 changed files
with
5,840 additions
and
1,714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,70 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
|
||
project(bunny VERSION 3.7.1 LANGUAGES CXX) | ||
project(bunny VERSION 1.0.0 | ||
DESCRIPTION "A header-only backward compatible C++ serialization library." | ||
LANGUAGES CXX) | ||
|
||
SET(WARNING_FLAGS "-Wno-unused-variable -Wno-unused-parameter") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -std=c++17") | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
set(CMAKE_INSTALL_PREFIX "/usr/local/lib/") | ||
|
||
# This is a local setting and needs to be removed. | ||
list(APPEND CMAKE_PREFIX_PATH "/usr/local/lib/boost/lib/cmake/" "/usr/local/lib/protobuf/lib/cmake/") | ||
|
||
find_package(GTest REQUIRED) | ||
option(ENABLE_BUNNY_TEST "Enables the bunny test cases." OFF) | ||
option(ENABLE_BUNNY_BENCHMARKING "Enables the benchmarking test cases." OFF) | ||
|
||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
|
||
file(GLOB SRC_FILES | ||
"src/*.cpp" | ||
"include/*.hpp" | ||
) | ||
|
||
include(GNUInstallDirs) | ||
|
||
include_directories(include) | ||
|
||
add_subdirectory(test) | ||
if(${ENABLE_BUNNY_TEST}) | ||
add_subdirectory(test) | ||
endif() | ||
|
||
if(${ENABLE_BUNNY_BENCHMARKING}) | ||
add_subdirectory(benchmarking) | ||
endif() | ||
|
||
add_library(${PROJECT_NAME} INTERFACE ${SRC_FILES}) | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
||
|
||
install(TARGETS ${PROJECT_NAME} | ||
EXPORT ${PROJECT_NAME}_Targets | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
|
||
include(CMakePackageConfigHelpers) | ||
write_basic_package_version_file("bunnyConfigVersion.cmake" | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY SameMajorVersion) | ||
|
||
configure_package_config_file( | ||
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in" | ||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
INSTALL_DESTINATION | ||
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
|
||
install(EXPORT ${PROJECT_NAME}_Targets | ||
FILE ${PROJECT_NAME}Targets.cmake | ||
NAMESPACE ${PROJECT_NAME}:: | ||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
|
||
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" | ||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
|
||
add_executable(${PROJECT_NAME} ${SRC_FILES}) | ||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION bunny) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
|
||
project(bunny-benchmark VERSION 3.7.1 LANGUAGES CXX) | ||
|
||
set(benchmark_DIR "${CMAKE_CURRENT_SOURCE_DIR}/benchmark") | ||
set(BENCHMARK_ENABLE_GTEST_TESTS OFF) | ||
|
||
find_package(Boost REQUIRED COMPONENTS serialization) | ||
find_package(absl REQUIRED) | ||
find_package(utf8_range REQUIRED) | ||
find_package(protobuf REQUIRED) | ||
|
||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
|
||
file(GLOB SRC_FILES | ||
"src/*.cpp" | ||
"src/*.cc" | ||
) | ||
|
||
add_subdirectory(benchmark) | ||
|
||
link_directories(/usr/local/lib/abseil/lib ${Protobuf_LIBRARIES}) | ||
|
||
add_executable(${PROJECT_NAME} ${SRC_FILES}) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE | ||
include | ||
${CMAKE_CURRENT_SOURCE_DIR}/include | ||
${Boost_INCLUDE_DIRS} | ||
benchmark/include | ||
${Protobuf_INCLUDE_DIR}) | ||
|
||
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBRARIES} | ||
pthread | ||
gtest_main | ||
Boost::serialization | ||
benchmark::benchmark | ||
protobuf::libprotobuf | ||
protobuf::libprotoc | ||
) |
Submodule benchmark
updated
from 000000 to 93a96a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#pragma once | ||
|
||
#include "ComposerPaper.hpp" | ||
#include "DecomposerPaper.hpp" | ||
#include <string> | ||
#include <unordered_map> | ||
#include <boost/serialization/unordered_map.hpp> | ||
#include <UnorderedMap.hpp> | ||
|
||
namespace boosttest | ||
{ | ||
struct PlainClass | ||
{ | ||
std::string m_name; | ||
std::unordered_map<int, std::string> m_map; | ||
|
||
template <typename Archive> | ||
void serialize(Archive &arc, unsigned int) | ||
{ | ||
arc & m_name; | ||
arc & m_map; | ||
} | ||
}; | ||
|
||
struct ComplexTestClass | ||
{ | ||
unsigned int m_id{}; | ||
int m_count{}; | ||
std::string m_name; | ||
std::unordered_map<int, std::unordered_map<int, int>> m_int_map; | ||
std::unordered_map<int, std::unordered_map<int, PlainClass>> m_plain_map[3]; | ||
|
||
template <typename Archive> | ||
void serialize(Archive &arc, unsigned int) | ||
{ | ||
arc & m_id; | ||
arc & m_name; | ||
arc & m_count; | ||
arc & m_int_map; | ||
arc & m_plain_map; | ||
} | ||
}; | ||
} | ||
|
||
namespace bunnytest | ||
{ | ||
using bunny::FieldTag; | ||
|
||
struct PlainClass | ||
{ | ||
std::string m_name; | ||
std::unordered_map<int, std::string> m_map; | ||
|
||
template <typename Paper> | ||
void serialize(Paper &paper) | ||
{ | ||
paper(m_name, FieldTag{1}); | ||
paper(m_map, FieldTag{2}); | ||
} | ||
|
||
template <typename Paper> | ||
void deserialize(Paper &paper) | ||
{ | ||
paper(m_name, FieldTag{1}); | ||
paper(m_map, FieldTag{2}); | ||
} | ||
}; | ||
|
||
struct ComplexTestClass | ||
{ | ||
unsigned int m_id{}; | ||
int m_count{}; | ||
std::string m_name; | ||
std::unordered_map<int, std::unordered_map<int, int>> m_int_map; | ||
std::unordered_map<int, std::unordered_map<int, PlainClass>> m_plain_map[3]; | ||
|
||
template <typename Paper> | ||
void serialize(Paper &paper) | ||
{ | ||
paper(m_id, FieldTag{1}); | ||
paper(m_name, FieldTag{2}); | ||
paper(m_count, FieldTag{3}); | ||
paper(m_int_map, FieldTag{4}); | ||
paper(m_plain_map, FieldTag{5}); | ||
} | ||
|
||
template <typename Paper> | ||
void deserialize(Paper &paper) | ||
{ | ||
paper(m_id, FieldTag{1}); | ||
paper(m_name, FieldTag{2}); | ||
paper(m_count, FieldTag{3}); | ||
paper(m_int_map, FieldTag{4}); | ||
paper(m_plain_map, FieldTag{5}); | ||
} | ||
}; | ||
|
||
} |
Oops, something went wrong.