]> git.meshlink.io Git - meshlink/blob - CMakeLists.txt
Improve CMake build system.
[meshlink] / CMakeLists.txt
1 project(meshlink)
2 cmake_minimum_required(VERSION 3.12)
3
4 set(THREADS_PREFER_PTHREAD_FLAG ON)
5 find_package(Threads REQUIRED)
6
7 include(CheckSymbolExists)
8 include(CheckIncludeFile)
9 include(CTest)
10
11 #add_definitions(-D_GNU_SOURCE)
12 #add_definitions(-D_POSIX_C_SOURCE=200112L)
13 set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
14 #list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
15 #add_compile_definitions(_GNU_SOURCE)
16 #string(APPEND CMAKE_C_FLAGS "-D_GNU_SOURCE")
17
18 check_symbol_exists(setns "sched.h" HAVE_SETNS)
19 check_symbol_exists(strsignal "string.h" HAVE_STRSIGNAL)
20 check_symbol_exists(asprintf "stdio.h" HAVE_ASPRINTF)
21 check_symbol_exists(pselect "sys/select.h" HAVE_PSELECT)
22 check_include_file(stdatomic.h HAVE_STDATOMIC_H)
23 configure_file(cmake_config.h.in config.h)
24 include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
25
26 add_subdirectory(src)
27
28 if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
29         enable_testing()
30         add_subdirectory(test)
31 endif()