blob: 1e92bb71d137046370e886b6bd6652d5b7cc0618 [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
Michal Vaskoc5a22832020-08-20 13:21:33 +020024 configure_file(${PROJECT_SOURCE_DIR}/compat/compat.h.in ${PROJECT_BINARY_DIR}/compat/compat.h @ONLY)
25 include_directories(${PROJECT_BINARY_DIR}/compat)
Michal Vasko5aa44c02020-06-29 11:47:02 +020026 add_library(compat OBJECT ${PROJECT_SOURCE_DIR}/compat/compat.c)
27 set_property(TARGET compat PROPERTY POSITION_INDEPENDENT_CODE ON)
28endmacro()