From a91123b71a37caf2ba6e68df1d23006a78b8900a Mon Sep 17 00:00:00 2001 From: laentropia Date: Wed, 20 May 2026 17:00:02 -0600 Subject: [PATCH] Fix for test construction --- CMakeLists.txt | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22947bf..8fdfffa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,34 +1,38 @@ cmake_minimum_required(VERSION 3.20) -project(arena VERSION 1.0 LANGUAGES C) +project( + arena + VERSION 1.0 + LANGUAGES C) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) +# ------------------------------------------------ +# Detectar si este proyecto es el principal +# ------------------------------------------------ +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + set(ARENA_IS_TOP_LEVEL ON) +else() + set(ARENA_IS_TOP_LEVEL OFF) +endif() + # Opciones -option(ARENA_BUILD_TESTS "Build arena tests" OFF) -option(ARENA_ENABLE_SANITIZERS "Enable sanitizers for tests" ON) +option(ARRAYLIST_BUILD_TESTS "Build arena tests" ${ARENA_IS_TOP_LEVEL}) +option(ARRAYLIST_ENABLE_SANITIZERS "Enable sanitizers for tests" ON) # Librería -add_library(arena - src/arena.c -) +add_library(arena src/arena.c) -target_include_directories(arena - PUBLIC - $ - $ -) +target_include_directories( + arena PUBLIC $ + $) -target_compile_options(arena PRIVATE - -Wall - -Wextra - -Wpedantic -) +target_compile_options(arena PRIVATE -Wall -Wextra -Wpedantic) # ------------------------ # Testing # ------------------------ if(ARENA_BUILD_TESTS) - enable_testing() - add_subdirectory(test) -endif() \ No newline at end of file + enable_testing() + add_subdirectory(test) +endif()