diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -6,6 +6,7 @@ include(CheckIncludeFiles) include(CheckSymbolExists) include(CheckCXXSourceCompiles) +include(SanitizeHelper) # Version set(CLIENT_VERSION_MAJOR ${bitcoin-abc_VERSION_MAJOR}) @@ -17,9 +18,25 @@ # Generate the version.h file configure_file(version.h.cmake.in version.h ESCAPE_QUOTES) +# Wrapper for the check_include_files() macro. +# The find_path() function honors the sysroot variables, and will help +# us adding the correct include path for check_include_files(). +# The most obvious use case is to help finding header files located in +# an Apple Framework. +function(check_include_files_with_sysroot INCLUDES) + foreach(INCLUDE ${INCLUDES}) + sanitize_variable("HEADER_" "${INCLUDE}_PATH" HEADER_PATH) + find_path(${HEADER_PATH} "${INCLUDE}") + if(${HEADER_PATH}) + list(APPEND CMAKE_REQUIRED_INCLUDES "${${HEADER_PATH}}") + endif() + endforeach() + check_include_files("${INCLUDES}" ${ARGN}) +endfunction() + # Endianness -check_include_files("endian.h" HAVE_ENDIAN_H) -check_include_files("sys/endian.h" HAVE_SYS_ENDIAN_H) +check_include_files_with_sysroot("endian.h" HAVE_ENDIAN_H) +check_include_files_with_sysroot("sys/endian.h" HAVE_SYS_ENDIAN_H) if(HAVE_ENDIAN_H) set(ENDIAN_FILE "endian.h") @@ -44,15 +61,15 @@ endif() # Byte swap -check_include_files("byteswap.h" HAVE_BYTESWAP_H) +check_include_files_with_sysroot("byteswap.h" HAVE_BYTESWAP_H) check_symbol_exists(bswap_16 "byteswap.h" HAVE_DECL_BSWAP_16) check_symbol_exists(bswap_32 "byteswap.h" HAVE_DECL_BSWAP_32) check_symbol_exists(bswap_64 "byteswap.h" HAVE_DECL_BSWAP_64) # sys/select.h and sys/prctl.h headers -check_include_files("sys/select.h" HAVE_SYS_SELECT_H) -check_include_files("sys/prctl.h" HAVE_SYS_PRCTL_H) +check_include_files_with_sysroot("sys/select.h" HAVE_SYS_SELECT_H) +check_include_files_with_sysroot("sys/prctl.h" HAVE_SYS_PRCTL_H) # Bitmanip intrinsics function(check_builtin_exist SYMBOL VARIABLE)