Initial commit
This commit is contained in:
56
.gitignore
vendored
Normal file
56
.gitignore
vendored
Normal file
@@ -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
|
||||||
48
CMakeLists.txt
Normal file
48
CMakeLists.txt
Normal file
@@ -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
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
|
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()
|
||||||
6
include/graph.h
Normal file
6
include/graph.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef GRAPH_H
|
||||||
|
#define GRAPH_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
1
src/graph.c
Normal file
1
src/graph.c
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "graph.h"
|
||||||
6
src/main.c
Normal file
6
src/main.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
23
test/CMakeLists.txt
Normal file
23
test/CMakeLists.txt
Normal file
@@ -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)
|
||||||
0
test/test_graph.c
Normal file
0
test/test_graph.c
Normal file
Reference in New Issue
Block a user