From 574bd1bc1314597c40e4972fccc32868faa8eff1 Mon Sep 17 00:00:00 2001 From: laentropia Date: Wed, 6 May 2026 09:45:22 -0600 Subject: [PATCH] Initial commit --- .gitignore | 56 +++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 48 ++++++++++++++++++++++++++++++++++++++ include/graph.h | 6 +++++ src/graph.c | 1 + src/main.c | 6 +++++ test/CMakeLists.txt | 23 +++++++++++++++++++ test/test_graph.c | 0 7 files changed, 140 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 include/graph.h create mode 100644 src/graph.c create mode 100644 src/main.c create mode 100644 test/CMakeLists.txt create mode 100644 test/test_graph.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bd57ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# Directories +build/ +build-*/ +cmake-build-*/ +.cache/ +out/ +out/Debug/ +out/Release/ + +# Cmake files +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +CTestTestfile.cmake +Testing/ +compile_commands.json +../compile_commands.json +build/compile_commands.json + +# Make / Ninja +Makefile +*.ninja +*.ninja_deps +*.ninja_log +rules.ninja + +# Object files +*.o +*.obj +*.lo +*.la + +# Binaries +*.out +*.exe +*.dll +*.so +*.so.* +*.dylib +*.a + +# Debug / Sanitizer +*.dSYM/ +*.gcno +*.gcda +*.gcov + +# Editors +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Git +COMMIT_MESSAGE diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5f85221 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.20) +project(graph VERSION 1.0 LANGUAGES C) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) + +# clangd +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Opciones +option(GRAPH_BUILD_TESTS "Build arraylist tests" OFF) +option(GRAPH_ENABLE_SANITIZERS "Enable sanitizers for tests" ON) + +# ------------------------ +# Library +# ------------------------ +add_library(graph + src/graph.c +) + +target_include_directories(graph + PUBLIC + $ + $ +) + +target_compile_options(graph PRIVATE + -Wall + -Wextra + -Wpedantic +) + +# ------------------------ +# Example (opcional) +# ------------------------ +add_executable(graph_example src/main.c) + +target_link_libraries(graph_example + graph +) + +# ------------------------ +# Testing +# ------------------------ +if(ARRAYLIST_BUILD_TESTS) + enable_testing() + add_subdirectory(test) +endif() diff --git a/include/graph.h b/include/graph.h new file mode 100644 index 0000000..abd2930 --- /dev/null +++ b/include/graph.h @@ -0,0 +1,6 @@ +#ifndef GRAPH_H +#define GRAPH_H + + + +#endif diff --git a/src/graph.c b/src/graph.c new file mode 100644 index 0000000..e8b6b5e --- /dev/null +++ b/src/graph.c @@ -0,0 +1 @@ +#include "graph.h" diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..1de0591 --- /dev/null +++ b/src/main.c @@ -0,0 +1,6 @@ +#include +#include + +int main(void) { + return EXIT_SUCCESS; +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..3d5817c --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,23 @@ +find_package(cmocka REQUIRED) + +add_executable(test_graph test_graph.c) + +target_link_libraries(test_graph + graph + cmocka::cmocka +) + +# Sanitizers (portables) +if(ARRAYLIST_ENABLE_SANITIZERS) + if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(test_graph PRIVATE + -fsanitize=address + -fno-omit-frame-pointer + ) + target_link_options(test_graph PRIVATE + -fsanitize=address + ) + endif() +endif() + +add_test(NAME graph_tests COMMAND test_graph) diff --git a/test/test_graph.c b/test/test_graph.c new file mode 100644 index 0000000..e69de29