Skip to content

cmake: Support extended attributes when built with cmake - #1176

Closed
jay wants to merge 2 commits into
curl:masterfrom
jay:cmake_support_xattr
Closed

jay wants to merge 2 commits into
curl:masterfrom
jay:cmake_support_xattr

Conversation

@jay

@jay jay commented Dec 27, 2016

Copy link
Copy Markdown
Member

Several months ago a patch was proposed on the mailing list to support xattr in cmake builds, but it appears to have slipped through the cracks. It is now the commit in this PR. Can a dev familiar with cmake please review?

/cc @sburford @Lekensteyn @snikulov @jzakrzewski

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
@jay jay added the cmake label Dec 27, 2016
@mention-bot

Copy link
Copy Markdown

@jay, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Sukender, @billhoffman and @Lekensteyn to be potential reviewers.

@Lekensteyn Lekensteyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, but see some inline stylistic comments.

Comment thread CMakeLists.txt Outdated
if(CURL_XATTR)
check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR)
if(HAVE_FSETXATTR)
add_definitions(-DHAVE_FSETXATTR)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds an option to the compile command. An alternative is to define macros in a config.h file (lib/curl_config.h.cmake):

#cmakedefine HAVE_FSETXATTR 1

I think this is closer to what autotools does via AC_DEFINE (but I did not check the output).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a great suggestion.

Comment thread CMakeLists.txt Outdated
endforeach(CURL_TEST)
if(HAVE_FSETXATTR_5)
set_source_files_properties(tool_xattr.c PROPERTIES
COMPILE_FLAGS "-DHAVE_FSETXATTR_5")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can possibly override other compile flags, so try appending properties and use the special property COMPILE_DEFINITIONS:

set_property(SOURCE tool_xattr.c APPEND PROPERTY
  COMPILE_DEFINITIONS HAVE_FSETXATTR_5)

Same comment for the next line. Alternatively, try adding a #cmakedefine as before, autotools uses an AC_DEFINE for these ..._5 and ..._6 options too.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the curl_config.h.cmake #cmakedefine suggestion this block becomes much simpler:
+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)

@SeanBurford

Copy link
Copy Markdown

Thanks for the feedback, I'll prepare an updated patch.

@SeanBurford

Copy link
Copy Markdown

Thanks again for the feedback. I have attached a shorter patch based on this one that enables xattr support when built using cmake.

cmake-xattr.patch.txt

@jay

jay commented Jan 12, 2017

Copy link
Copy Markdown
Member Author

cmake-xattr.patch.txt

I've added this patch to the branch as draft2 to make it easier to review

Comment thread CMake/CurlTests.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any difference between the two main functions below and up?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 vs 6 arguments in the fsetxattr() call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is for _5 vs _6, but if my diff tool is not broken, the same test programs are duplicated. I think lines 552-568 can be deleted

Comment thread CMake/CurlTests.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is for _5 vs _6, but if my diff tool is not broken, the same test programs are duplicated. I think lines 552-568 can be deleted

@snikulov

Copy link
Copy Markdown
Contributor

@Lekensteyn You tool is not broken. It is duplicated block at the end of this file.

Squash me into previous draft.

- Changes to address Peter's review of draft1.
@jay
jay force-pushed the cmake_support_xattr branch from fc60641 to 9c05a8b Compare January 12, 2017 16:59
@jay

jay commented Jan 12, 2017

Copy link
Copy Markdown
Member Author

It is duplicated block at the end of this file.

my fault, patch applied it even though there was no change from the first draft. fixed, please check again

@Lekensteyn

Copy link
Copy Markdown
Contributor

LGTM, let's see what the buildbots say

@jay jay closed this in 1c877a0 Feb 1, 2017
@jay
jay deleted the cmake_support_xattr branch February 1, 2017 06:16
@jay

jay commented Feb 1, 2017

Copy link
Copy Markdown
Member Author

Just landed, thanks guys

@lock lock Bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

7 participants