Fix for test construction
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(arraylist VERSION 1.0 LANGUAGES C)
|
project(
|
||||||
|
arraylist
|
||||||
|
VERSION 1.0
|
||||||
|
LANGUAGES C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
@@ -7,37 +10,36 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
|
|||||||
# clangd
|
# clangd
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
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
|
# Opciones
|
||||||
option(ARRAYLIST_BUILD_TESTS "Build arraylist tests" ON)
|
option(ARRAYLIST_BUILD_TESTS "Build arraylist tests" ${ARRAYLIST_IS_TOP_LEVEL})
|
||||||
option(ARRAYLIST_ENABLE_SANITIZERS "Enable sanitizers for tests" ON)
|
option(ARRAYLIST_ENABLE_SANITIZERS "Enable sanitizers for tests" ON)
|
||||||
|
|
||||||
# ------------------------
|
# ------------------------
|
||||||
# Library
|
# Library
|
||||||
# ------------------------
|
# ------------------------
|
||||||
add_library(arraylist
|
add_library(arraylist src/arraylist.c)
|
||||||
src/arraylist.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(arraylist
|
target_include_directories(
|
||||||
PUBLIC
|
arraylist PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<INSTALL_INTERFACE:include>)
|
||||||
$<INSTALL_INTERFACE:include>
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_options(arraylist PRIVATE
|
target_compile_options(arraylist PRIVATE -Wall -Wextra -Wpedantic)
|
||||||
-Wall
|
|
||||||
-Wextra
|
|
||||||
-Wpedantic
|
|
||||||
)
|
|
||||||
|
|
||||||
# ------------------------
|
# ------------------------
|
||||||
# Example (opcional)
|
# Example (opcional)
|
||||||
# ------------------------
|
# ------------------------
|
||||||
add_executable(arraylist_example src/main.c)
|
add_executable(arraylist_example src/main.c)
|
||||||
|
|
||||||
target_link_libraries(arraylist_example
|
target_link_libraries(arraylist_example arraylist)
|
||||||
arraylist
|
|
||||||
)
|
|
||||||
|
|
||||||
# ------------------------
|
# ------------------------
|
||||||
# Testing
|
# Testing
|
||||||
|
|||||||
Reference in New Issue
Block a user