cmake_minimum_required(VERSION 3.20) project( arraylist VERSION 1.0 LANGUAGES C) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) # clangd set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # ------------------------------------------------ # 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() # Opciones option(ARRAYLIST_BUILD_TESTS "Build arraylist tests" ${ARRAYLIST_IS_TOP_LEVEL}) option(ARRAYLIST_ENABLE_SANITIZERS "Enable sanitizers for tests" ON) # ------------------------ # Library # ------------------------ add_library(arraylist src/arraylist.c) target_include_directories( arraylist PUBLIC $ $) target_compile_options(arraylist PRIVATE -Wall -Wextra -Wpedantic) # ------------------------ # Example (opcional) # ------------------------ add_executable(arraylist_example src/main.c) target_link_libraries(arraylist_example arraylist) # ------------------------ # Testing # ------------------------ if(ARRAYLIST_BUILD_TESTS) enable_testing() add_subdirectory(test) endif()