From 494567cff8b574b56d35978f7dcf262d9fc25f7a Mon Sep 17 00:00:00 2001 From: Sean Burford Date: Tue, 19 Jul 2016 10:27:20 +1000 Subject: [PATCH 1/2] 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. Closes #XXXX --- CMake/CurlTests.c | 16 ++++++++++++++++ CMakeLists.txt | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index ceff39151c77be..bc36c8ef7ddb93 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -533,3 +533,19 @@ main () { return 0; } #endif +#ifdef HAVE_FSETXATTR_6 +#include /* header from libc, not from libattr */ +int +main() { + fsetxattr(0, 0, 0, 0, 0, 0); + return 0; +} +#endif +#ifdef HAVE_FSETXATTR_5 +#include /* 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 a6a73689d39bc6..33d36685806d9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -571,6 +571,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) @@ -609,6 +613,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) @@ -820,6 +825,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) From 9c05a8b0b32442aea96c9ca4c4166687e5875b27 Mon Sep 17 00:00:00 2001 From: Sean Burford Date: Wed, 11 Jan 2017 21:35:39 -0500 Subject: [PATCH 2/2] cmake: Support extended attributes when built with cmake. draft2 Squash me into previous draft. - Changes to address Peter's review of draft1. --- CMakeLists.txt | 27 ++++++--------------------- lib/curl_config.h.cmake | 9 +++++++++ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33d36685806d9a..34129c928f4199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -571,10 +571,6 @@ 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) @@ -825,23 +821,12 @@ 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() +check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR) +if(HAVE_FSETXATTR) + foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6) + curl_internal_test_run(${CURL_TEST}) + endforeach(CURL_TEST) +endif(HAVE_FSETXATTR) # sigaction and sigsetjmp are special. Use special mechanism for # detecting those, but only if previous attempt failed. diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 33c15cb6fd389f..49c1b8a2d03e6b 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -518,6 +518,15 @@ /* Define to 1 if you have the send function. */ #cmakedefine HAVE_SEND 1 +/* Define to 1 if you have the 'fsetxattr' function. */ +#cmakedefine HAVE_FSETXATTR 1 + +/* fsetxattr() takes 5 args */ +#cmakedefine HAVE_FSETXATTR_5 1 + +/* fsetxattr() takes 6 args */ +#cmakedefine HAVE_FSETXATTR_6 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SETJMP_H 1