threadless.io/CMakeLists.txt

41 lines
1.4 KiB
CMake
Raw Permalink Normal View History

cmake_minimum_required(VERSION 3.5)
2016-04-04 02:56:52 +00:00
include(CheckFunctionExists)
include(CheckSymbolExists)
2016-04-04 02:54:57 +00:00
check_function_exists(mmap HAVE_MMAP)
if(HAVE_MMAP)
check_symbol_exists(MAP_ANONYMOUS sys/mman.h HAVE_MAP_ANONYMOUS)
if(NOT HAVE_MAP_ANONYMOUS)
check_symbol_exists(MAP_ANON sys/mman.h HAVE_MAP_ANON)
endif()
check_function_exists(mremap HAVE_MREMAP)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Werror -std=c99")
2016-04-04 02:54:57 +00:00
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
2016-04-04 02:56:52 +00:00
add_library(allocation src/allocation.c)
2016-04-04 02:56:52 +00:00
add_library(coroutine src/coroutine.c)
target_link_libraries(coroutine LINK_PUBLIC allocation)
2016-04-04 02:56:52 +00:00
add_library(default_allocator src/default_allocator.c)
2016-04-04 02:54:57 +00:00
set(ALLOCATORS default_allocator)
add_library(heap src/heap.c)
target_link_libraries(heap LINK_PUBLIC allocation)
2016-04-04 02:54:57 +00:00
if(HAVE_MMAP)
2016-04-04 02:56:52 +00:00
add_library(mmap_allocator src/mmap_allocator.c)
2016-04-04 02:54:57 +00:00
set(ALLOCATORS ${ALLOCATORS} mmap_allocator)
endif()
2016-04-04 00:54:59 +00:00
2016-04-06 06:08:25 +00:00
add_executable(test-allocation test/allocation.c)
target_link_libraries(test-allocation LINK_PUBLIC allocation ${ALLOCATORS})
2016-04-04 02:56:52 +00:00
add_executable(test-coroutine test/coroutine.c)
target_link_libraries(test-coroutine LINK_PUBLIC coroutine ${ALLOCATORS})
add_executable(test-heap test/heap.c)
target_link_libraries(test-heap LINK_PUBLIC heap ${ALLOCATORS})