Files
ArrayList/CMakeLists.txt

51 lines
1.2 KiB
CMake
Raw Normal View History

2026-04-13 11:16:58 -06:00
cmake_minimum_required(VERSION 3.20)
2026-05-20 16:46:50 -06:00
project(
arraylist
VERSION 1.0
LANGUAGES C)
2026-04-13 11:16:58 -06:00
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
2026-04-23 12:23:52 -06:00
# clangd
2026-04-13 11:16:58 -06:00
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2026-05-20 16:46:50 -06:00
# ------------------------------------------------
# Detectar si este proyecto es el principal
# ------------------------------------------------
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(ARRAYLIST_IS_TOP_LEVEL ON)
else()
set(ARRAYLIST_IS_TOP_LEVEL OFF)
endif()
2026-04-23 12:23:52 -06:00
# Opciones
2026-05-20 16:46:50 -06:00
option(ARRAYLIST_BUILD_TESTS "Build arraylist tests" ${ARRAYLIST_IS_TOP_LEVEL})
2026-04-23 12:23:52 -06:00
option(ARRAYLIST_ENABLE_SANITIZERS "Enable sanitizers for tests" ON)
2026-04-13 11:16:58 -06:00
2026-04-23 12:23:52 -06:00
# ------------------------
# Library
# ------------------------
2026-05-20 16:46:50 -06:00
add_library(arraylist src/arraylist.c)
target_include_directories(
arraylist PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_options(arraylist PRIVATE -Wall -Wextra -Wpedantic)
2026-04-13 11:16:58 -06:00
2026-04-23 12:23:52 -06:00
# ------------------------
# Example (opcional)
# ------------------------
add_executable(arraylist_example src/main.c)
2026-04-13 11:16:58 -06:00
2026-05-20 16:46:50 -06:00
target_link_libraries(arraylist_example arraylist)
2026-04-13 11:16:58 -06:00
# ------------------------
# Testing
# ------------------------
2026-04-23 12:23:52 -06:00
if(ARRAYLIST_BUILD_TESTS)
2026-05-20 16:46:50 -06:00
enable_testing()
add_subdirectory(test)
2026-04-23 12:23:52 -06:00
endif()