Michal Vasko | 5aa44c0 | 2020-06-29 11:47:02 +0200 | [diff] [blame] | 1 | include(CheckSymbolExists) |
| 2 | include(TestBigEndian) |
| 3 | |
Michal Vasko | 1b0b9a1 | 2021-05-06 08:38:34 +0200 | [diff] [blame^] | 4 | # defines "compatsrc" with source(s) of this small library |
Michal Vasko | 5aa44c0 | 2020-06-29 11:47:02 +0200 | [diff] [blame] | 5 | macro(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 Vasko | 1b0b9a1 | 2021-05-06 08:38:34 +0200 | [diff] [blame^] | 22 | # header and source file (adding the source directly allows for hiding its symbols) |
Michal Vasko | c5a2283 | 2020-08-20 13:21:33 +0200 | [diff] [blame] | 23 | configure_file(${PROJECT_SOURCE_DIR}/compat/compat.h.in ${PROJECT_BINARY_DIR}/compat/compat.h @ONLY) |
| 24 | include_directories(${PROJECT_BINARY_DIR}/compat) |
Michal Vasko | 1b0b9a1 | 2021-05-06 08:38:34 +0200 | [diff] [blame^] | 25 | set(compatsrc ${PROJECT_SOURCE_DIR}/compat/compat.c) |
Michal Vasko | 5aa44c0 | 2020-06-29 11:47:02 +0200 | [diff] [blame] | 26 | endmacro() |