blob: 7e624d985b82c719846ad1041fdcba509e8d41a5 [file] [log] [blame]
Michal Vasko5aa44c02020-06-29 11:47:02 +02001include(CheckSymbolExists)
2include(TestBigEndian)
3
Michal Vasko1b0b9a12021-05-06 08:38:34 +02004# defines "compatsrc" with source(s) of this small library
Michal Vasko5aa44c02020-06-29 11:47:02 +02005macro(USE_COMPAT)
6 # compatibility checks
7 set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L)
8 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
9 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1)
10 check_symbol_exists(vdprintf "stdio.h;stdarg.h" HAVE_VDPRINTF)
11 check_symbol_exists(asprintf "stdio.h" HAVE_ASPRINTF)
12 check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF)
13
14 check_symbol_exists(strndup "string.h" HAVE_STRNDUP)
15 check_symbol_exists(strnstr "string.h" HAVE_STRNSTR)
16 check_symbol_exists(getline "stdio.h" HAVE_GETLINE)
17
18 check_symbol_exists(get_current_dir_name "unistd.h" HAVE_GET_CURRENT_DIR_NAME)
19
20 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
21
Michal Vasko1b0b9a12021-05-06 08:38:34 +020022 # header and source file (adding the source directly allows for hiding its symbols)
Michal Vaskoc5a22832020-08-20 13:21:33 +020023 configure_file(${PROJECT_SOURCE_DIR}/compat/compat.h.in ${PROJECT_BINARY_DIR}/compat/compat.h @ONLY)
24 include_directories(${PROJECT_BINARY_DIR}/compat)
Michal Vasko1b0b9a12021-05-06 08:38:34 +020025 set(compatsrc ${PROJECT_SOURCE_DIR}/compat/compat.c)
Michal Vasko5aa44c02020-06-29 11:47:02 +020026endmacro()