Initial simple version of project using conan, dev container and cmake.
This commit is contained in:
commit
f843ea2c13
|
|
@ -0,0 +1,20 @@
|
|||
FROM alpine:3.21.3
|
||||
|
||||
# Install tools required for building.
|
||||
RUN apk update && \
|
||||
apk add --no-cache \
|
||||
autoconf \
|
||||
bash \
|
||||
build-base \
|
||||
cmake \
|
||||
gdb \
|
||||
git \
|
||||
libstdc++ \
|
||||
libtool \
|
||||
linux-headers \
|
||||
m4 \
|
||||
perl \
|
||||
python3 \
|
||||
py3-pip && \
|
||||
pip install --break-system-packages conan && \
|
||||
conan profile detect
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "C++",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {},
|
||||
"extensions": [
|
||||
"ms-vscode.cpptools",
|
||||
"twxs.cmake",
|
||||
"ms-vscode.cmake-tools",
|
||||
"konicy.conan-extension"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
build/
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"conan-extension.installArgs": [
|
||||
|
||||
"-of build",
|
||||
"--build=*",
|
||||
"--settings=build_type=Debug"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(all)
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[requires]
|
||||
boost/1.88.0
|
||||
gtest/1.14.0
|
||||
[generators]
|
||||
CMakeDeps
|
||||
CMakeToolchain
|
||||
[layout]
|
||||
cmake_layout
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
add_subdirectory(example_boost)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
find_package(Boost 1.88.0 REQUIRED COMPONENTS serialization)
|
||||
|
||||
project(hello_world_boost)
|
||||
|
||||
add_executable(
|
||||
${PROJECT_NAME}
|
||||
./src/main.cpp
|
||||
)
|
||||
|
||||
set_property(
|
||||
TARGET ${PROJECT_NAME}
|
||||
PROPERTY CXX_STANDARD 20
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
Boost::serialization
|
||||
)
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
|
||||
struct position
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /*version*/)
|
||||
{
|
||||
ar & x;
|
||||
ar & y;
|
||||
}
|
||||
|
||||
bool operator==(const position& rhs) const
|
||||
{
|
||||
return x == rhs.x
|
||||
&& y == rhs.y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
position myposition{.x=123.0, .y=456.0};
|
||||
|
||||
std::stringstream ss;
|
||||
{
|
||||
boost::archive::text_oarchive oa(ss);
|
||||
oa << myposition;
|
||||
}
|
||||
|
||||
position anotherposition;
|
||||
std::cout << "serialized: " << ss.str() << std::endl;
|
||||
{
|
||||
boost::archive::text_iarchive ia(ss);
|
||||
ia >> anotherposition;
|
||||
}
|
||||
|
||||
if (myposition == anotherposition)
|
||||
{
|
||||
std::cout << "positions are the same" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue