Files
sem2Graph/CMakeLists.txt
2026-05-07 11:04:51 -06:00

92 lines
1.8 KiB
CMake

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)
# --------------------------------------------------
# CPM.cmake bootstrap
# --------------------------------------------------
set(CPM_DOWNLOAD_VERSION 0.40.2)
set(CPM_DOWNLOAD_LOCATION
"${CMAKE_BINARY_DIR}/cmake/CPM.cmake"
)
if(NOT EXISTS ${CPM_DOWNLOAD_LOCATION})
message(STATUS "Downloading CPM.cmake...")
file(
DOWNLOAD
"https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake"
"${CPM_DOWNLOAD_LOCATION}"
STATUS download_status
)
list(GET download_status 0 status_code)
if(NOT status_code EQUAL 0)
message(FATAL_ERROR
"Failed to download CPM.cmake"
)
endif()
endif()
include("${CPM_DOWNLOAD_LOCATION}")
CPMAddPackage(
NAME arraylist
GIT_REPOSITORY https://laentropia-homelab.tail7368da.ts.net/laentropia/ArrayList.git
GIT_TAG main
)
# ------------------------
# 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
)
target_link_libraries(graph
PUBLIC arraylist
)
# ------------------------
# Testing
# ------------------------
if(ARRAYLIST_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()