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