Files
refcount/CMakeLists.txt

48 lines
1.2 KiB
CMake

cmake_minimum_required(VERSION 3.11)
set(REFCOUNT_USE_THREADS
ON
CACHE BOOL "Weather or not RefCount should be thread aware.")
if(REFCOUNT_USE_THREADS)
set(CMAKE_C_STANDARD 11)
else()
set(CMAKE_C_STANDARD 99)
endif()
project(
refcount
VERSION 1.0
LANGUAGES C)
# For configuring config.h (I like this name better)
set(REFCOUNT_HAS_THREADS "${REFCOUNT_USE_THREADS}")
include(FetchContent)
FetchContent_Declare(
ht
GIT_REPOSITORY https://git.zander.im/Zander671/ht.git
GIT_TAG 9a1b271cfdc8ab203f9d6aa6a83cc4523de422be)
FetchContent_MakeAvailable(ht)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()
# add_compile_options(-fsanitize=address,leak,undefined)
# add_link_options(-fsanitize=address,leak,undefined)
configure_file(include/refcount/config.h.in include/refcount/config.h @ONLY)
add_library(refcount src/allocator.c src/list.c src/refcount.c)
target_link_libraries(refcount PUBLIC ht)
target_include_directories(refcount PUBLIC include/)
target_compile_options(refcount PRIVATE -Wall -Wpedantic)
target_include_directories(refcount
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(test/)
endif()