61 lines
1.2 KiB
CMake
61 lines
1.2 KiB
CMake
|
|
cmake_minimum_required(VERSION 3.20)
|
||
|
|
project(avl 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(AVL_BUILD_TESTS "Build avl tests" OFF)
|
||
|
|
option(AVL_ENABLE_SANITIZERS "Enable sanitizers" ON)
|
||
|
|
|
||
|
|
# ------------------------
|
||
|
|
# Library
|
||
|
|
# ------------------------
|
||
|
|
add_library(avl
|
||
|
|
src/avl.c
|
||
|
|
)
|
||
|
|
|
||
|
|
target_include_directories(avl
|
||
|
|
PUBLIC
|
||
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||
|
|
$<INSTALL_INTERFACE:include>
|
||
|
|
)
|
||
|
|
|
||
|
|
target_compile_options(avl PRIVATE
|
||
|
|
-Wall
|
||
|
|
-Wextra
|
||
|
|
-Wpedantic
|
||
|
|
)
|
||
|
|
|
||
|
|
# ------------------------
|
||
|
|
# Example
|
||
|
|
# ------------------------
|
||
|
|
add_executable(avl_example src/main.c)
|
||
|
|
|
||
|
|
target_link_libraries(avl_example
|
||
|
|
avl
|
||
|
|
)
|
||
|
|
|
||
|
|
# ------------------------
|
||
|
|
# Sanitizers (debug only)
|
||
|
|
# ------------------------
|
||
|
|
if(AVL_ENABLE_SANITIZERS)
|
||
|
|
target_compile_options(avl_example PRIVATE
|
||
|
|
-fsanitize=address,undefined
|
||
|
|
)
|
||
|
|
target_link_options(avl_example PRIVATE
|
||
|
|
-fsanitize=address,undefined
|
||
|
|
)
|
||
|
|
endif()
|
||
|
|
|
||
|
|
# ------------------------
|
||
|
|
# Testing
|
||
|
|
# ------------------------
|
||
|
|
if(AVL_BUILD_TESTS)
|
||
|
|
enable_testing()
|
||
|
|
add_subdirectory(test)
|
||
|
|
endif()
|