Michal Vasko | 5aa44c0 | 2020-06-29 11:47:02 +0200 | [diff] [blame] | 1 | include(CheckSymbolExists) |
| 2 | include(TestBigEndian) |
| 3 | |
| 4 | macro(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 Vasko | c5a2283 | 2020-08-20 13:21:33 +0200 | [diff] [blame] | 22 | configure_file(${PROJECT_SOURCE_DIR}/compat/compat.h.in ${PROJECT_BINARY_DIR}/compat/compat.h @ONLY) |
| 23 | include_directories(${PROJECT_BINARY_DIR}/compat) |
Michal Vasko | 5aa44c0 | 2020-06-29 11:47:02 +0200 | [diff] [blame] | 24 | add_library(compat OBJECT ${PROJECT_SOURCE_DIR}/compat/compat.c) |
| 25 | set_property(TARGET compat PROPERTY POSITION_INDEPENDENT_CODE ON) |
| 26 | endmacro() |