Hi, Extended attribute support (--xattr) was omitted when curl was built with cmake since cmake does not test for and set the HAVE_FSETXATTR defines. I've attached a patch that addresses this issue.
The configure.ac, configure, make build system is not affected by this issue. I realize that cmake is the poorly maintained build option for curl, however it is an option so it's worth fixing known issues. $ ./src/curl --xattr -O http://www.google.com/robots.txt % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6350 0 6350 0 0 22173 0 --:--:-- --:--:-- --:--:-- 45035 $ getfattr -d robots.txt # file: robots.txt user.mime_type="text/plain" user.xdg.origin.url="http://www.google.com/robots.txt" -- Sean Burford <[email protected]>
From 17fc5b3e1e911ee238098322abc4ce84648988c4 Mon Sep 17 00:00:00 2001 From: Sean Burford <[email protected]> Date: Tue, 19 Jul 2016 10:27:20 +1000 Subject: [PATCH] cmake: Support extended attributes when built with cmake. Extended attribute support (--xattr) was omitted when curl was built with cmake since cmake does not test for and set the HAVE_FSETXATTR defines. The configure.ac, configure, make build system is not affected by this issue. --- CMake/CurlTests.c | 16 ++++++++++++++++ CMakeLists.txt | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index ceff391..bc36c8e 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -533,3 +533,19 @@ main () { return 0; } #endif +#ifdef HAVE_FSETXATTR_6 +#include <sys/xattr.h> /* header from libc, not from libattr */ +int +main() { + fsetxattr(0, 0, 0, 0, 0, 0); + return 0; +} +#endif +#ifdef HAVE_FSETXATTR_5 +#include <sys/xattr.h> /* header from libc, not from libattr */ +int +main() { + fsetxattr(0, 0, 0, 0, 0); + return 0; +} +#endif diff --git a/CMakeLists.txt b/CMakeLists.txt index 58b1451..5198711 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -554,6 +554,10 @@ else() unset(USE_UNIX_SOCKETS CACHE) endif() +option(CURL_XATTR "Set to ON to enable building cURL with xattr support." ON) +mark_as_advanced(CURL_XATTR) +set(HAVE_FSETXATTR_5 OFF) +set(HAVE_FSETXATTR_6 OFF) # Check for header files if(NOT UNIX) @@ -592,6 +596,7 @@ check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H) check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H) check_include_file_concat("sys/un.h" HAVE_SYS_UN_H) check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H) +check_include_file_concat("sys/xattr.h" HAVE_SYS_XATTR_H) check_include_file_concat("alloca.h" HAVE_ALLOCA_H) check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H) check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H) @@ -807,6 +812,24 @@ check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT) # symbol exists in win32, but function does not. check_function_exists(inet_pton HAVE_INET_PTON) +if(CURL_XATTR) + check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR) + if(HAVE_FSETXATTR) + add_definitions(-DHAVE_FSETXATTR) + foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6) + curl_internal_test_run(${CURL_TEST}) + endforeach(CURL_TEST) + if(HAVE_FSETXATTR_5) + set_source_files_properties(tool_xattr.c PROPERTIES + COMPILE_FLAGS "-DHAVE_FSETXATTR_5") + endif() + if(HAVE_FSETXATTR_6) + set_source_files_properties(tool_xattr.c PROPERTIES + COMPILE_FLAGS "-DHAVE_FSETXATTR_6") + endif() + endif() +endif() + # sigaction and sigsetjmp are special. Use special mechanism for # detecting those, but only if previous attempt failed. if(HAVE_SIGNAL_H) -- 2.8.0.rc3.226.g39d4020
------------------------------------------------------------------- List admin: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html
