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