Skip to content

Commit

Permalink
feat: cmake support
Browse files Browse the repository at this point in the history
  • Loading branch information
igormcoelho committed Feb 28, 2023
1 parent d93d758 commit f99b7a4
Show file tree
Hide file tree
Showing 32 changed files with 145 additions and 341 deletions.
16 changes: 13 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
FROM mcr.microsoft.com/devcontainers/cpp:0-ubuntu-22.04
# LIST: https://mcr.microsoft.com/v2/vscode/devcontainers/cpp/tags/list

# command 'add-apt-repository'
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends software-properties-common

# see: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
# RUN sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test

# ===========

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/

RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh

# [Optional] Uncomment this section to install additional vcpkg ports.
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"
Expand Down
Empty file modified .devcontainer/reinstall-cmake.sh
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ app_*
a.out
build/*
compile_commands.*
tmp*
.vscode/
### Automatically added by Hedron's Bazel Compile Commands Extractor: https://github.com/hedronvision/bazel-compile-commands-extractor
# Ignore the `external` link (that is added by `bazel-compile-commands-extractor`). The link differs between macOS/Linux and Windows, so it shouldn't be checked in. The pattern must not end with a trailing `/` because it's a symlink on macOS/Linux.
/external
Expand Down
17 changes: 0 additions & 17 deletions .vscode/c_cpp_properties.json

This file was deleted.

28 changes: 0 additions & 28 deletions .vscode/launch.json

This file was deleted.

9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
"-log=verbose",
"-pretty",
"--background-index",
"--compile-commands-dir=/workspaces/cycles/",
"--compile-commands-dir=/workspaces/cycles/build/",
// "--compile-commands-dir=/workspaces/cycles/",
],
"C_Cpp.intelliSenseEngine": "Disabled",
"testMate.cpp.test.advancedExecutables": [
{
"pattern": "{bazel-bin}/**/*{test}*"
//"pattern": "{bazel-bin}/**/*{test}*"
"pattern": "{build}/**/*{test}*"
}
],
"C_Cpp.codeAnalysis.clangTidy.useBuildPath": true,
Expand Down Expand Up @@ -70,5 +72,6 @@
"iterator": "cpp",
"queue": "cpp",
"random": "cpp"
}
},
"cmake.sourceDirectory": "${workspaceFolder}/."
}
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.22)
project(cycles-project LANGUAGES CXX VERSION 0.0.1)
#
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
Include(FetchContent)

# ===================
# header only library
# -------------------
add_library(cycles INTERFACE)
target_include_directories(cycles INTERFACE include/)
#
add_subdirectory(examples)
#
add_subdirectory(tests)
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: test demo

demo:
cd src/demo_cptr && make
cd examples/demo_cptr && make

test:
cd tests && make
Expand All @@ -12,5 +12,5 @@ bench:
clean:
rm -f vgcore.*
rm -f tests/vgcore.*
rm -f src/demo_cptr/vgcore.*
rm -f src/examples/vgcore.*
rm -f examples/demo_cptr/vgcore.*
rm -f examples/examples/vgcore.*
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ This project can be used to manage cyclic data structures with memory safe.

See https://github.com/hsutter/gcpp and its video from cppcon 2016 [Leak Freedom in C++... by Default](https://www.youtube.com/watch?v=JfmTagWcqoE).

Other related project is sgcl/tracked_ptr: https://github.com/pebal/sgcl

## Acknowledgements

We appreciate the interest of all involved in this project.
Expand Down
1 change: 0 additions & 1 deletion build/.gitignore

This file was deleted.

17 changes: 17 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#
add_executable(example1 basic_examples/app_example1.cpp)
target_link_libraries(example1 PRIVATE cycles)

add_executable(example2 basic_examples/app_example2.cpp)
target_link_libraries(example2 PRIVATE cycles)

add_executable(example3 basic_examples/app_example3.cpp)
target_link_libraries(example3 PRIVATE cycles)

add_executable(demo demo_cptr/demo.cpp)
target_link_libraries(demo PRIVATE cycles)

add_executable(demo0_cycles_test_graph demo_cptr/demo0_cycles_test_graph.cpp)
target_link_libraries(demo0_cycles_test_graph PRIVATE cycles)

File renamed without changes.
6 changes: 3 additions & 3 deletions src/examples/makefile → examples/basic_examples/makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
all: app_example1 app_example2 app_example3

app_example1: app_example1.cpp
g++ app_example1.cpp -I../../include/ -I../../src/ -Wfatal-errors -g -std=c++17 -o ../../build/app_example1
g++ app_example1.cpp -I../../include/ -I../../examples/ -Wfatal-errors -g -std=c++17 -o ../../build/app_example1

app_example2: app_example2.cpp
g++ app_example2.cpp -I../../include/ -I../../src/ -Wfatal-errors -g -std=c++17 -o ../../build/app_example2
g++ app_example2.cpp -I../../include/ -I../../examples/ -Wfatal-errors -g -std=c++17 -o ../../build/app_example2

app_example3: app_example3.cpp
g++ app_example3.cpp -I../../include/ -I../../src/ -Wfatal-errors -g -std=c++17 -o ../../build/app_example3
g++ app_example3.cpp -I../../include/ -I../../examples/ -Wfatal-errors -g -std=c++17 -o ../../build/app_example3



Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ child that was never added"); children.erase(it);
//--- Solution 2 (deferred_ptr) -----------------------------------------------
/*/

static relation_pool<> pool;
static relation_pool<> pool; // NOLINT

class MyGraph {
public:
class Node : public Counter {
private:
vector<relation_ptr<Node>> children;

public:
Expand Down Expand Up @@ -99,7 +100,8 @@ class MyGraph {
void ShrinkToFit() { pool.getContext()->collect(); }

static auto MakeNode() {
return relation_ptr<Node>::make(::pool.getContext());
// return relation_ptr<Node>::make(::pool.getContext());
return pool.make<Node>();
}

private:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
74 changes: 0 additions & 74 deletions src/examples/app_example1.cpp

This file was deleted.

89 changes: 0 additions & 89 deletions src/examples/app_example2.cpp

This file was deleted.

Loading

0 comments on commit f99b7a4

Please sign in to comment.