blob: bac4027a480edfd4b75c80bb5f989bcb16b69645 [file] [log] [blame]
Michal Vasko5aa44c02020-06-29 11:47:02 +02001cmake_minimum_required(VERSION 2.8.12)
2
3include(CheckSymbolExists)
4include(TestBigEndian)
5
6macro(USE_COMPAT)
7 # compatibility checks
8 set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L)
9 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
10 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1)
11 check_symbol_exists(vdprintf "stdio.h;stdarg.h" HAVE_VDPRINTF)
12 check_symbol_exists(asprintf "stdio.h" HAVE_ASPRINTF)
13 check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF)
14
15 check_symbol_exists(strndup "string.h" HAVE_STRNDUP)
16 check_symbol_exists(strnstr "string.h" HAVE_STRNSTR)
17 check_symbol_exists(getline "stdio.h" HAVE_GETLINE)
18
19 check_symbol_exists(get_current_dir_name "unistd.h" HAVE_GET_CURRENT_DIR_NAME)
20
21 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
22
23 # header and object file
24 configure_file(${PROJECT_SOURCE_DIR}/compat/compat.h.in ${PROJECT_BINARY_DIR}/compat.h @ONLY)
25 include_directories(${PROJECT_BINARY_DIR})
26 add_library(compat OBJECT ${PROJECT_SOURCE_DIR}/compat/compat.c)
27 set_property(TARGET compat PROPERTY POSITION_INDEPENDENT_CODE ON)
28endmacro()