Skip to content

[CMake] ntlmclient. Headers for common crypto are excluded in Xcode target. #5969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lolgear opened this issue Aug 3, 2021 · 9 comments
Closed

Comments

@lolgear
Copy link
Contributor

lolgear commented Aug 3, 2021

Too many words for simple

IF(USE_HTTPS STREQUAL "SecureTransport")

You may see that there is no clue of included headers at this common crypto condition branch.
Even more, there is no clue whether unicode is handled via _builtin or _iconv.

I don't understand what is going on (which headers are included or not), because target in Xcode doesn't contain any header but it works, because HEADERS_SEARCH_PATH flag is pointing to deps/ntlmclient.

@ethomson
Copy link
Member

ethomson commented Aug 3, 2021

If I understand your question correctly: since ntlmclient is piggybacking on the https configuration for libgit2 itself, we don't need any additional headers or libraries-libgit2's cmake rules pulled them in already

@ethomson
Copy link
Member

ethomson commented Aug 3, 2021

In particular, they're getting defined in https://github.com/libgit2/libgit2/blob/main/cmake/SelectHTTPSBackend.cmake - the ntlmclient project is a bit odd. I wrote it, basically for libgit2's use, but I wanted to make it able to standalone as well. That's why it's in deps/ but also just uses our configuration.

@lolgear
Copy link
Contributor Author

lolgear commented Aug 3, 2021

But I still don't understand which headers it uses.
I see a lot of includes in ntlm.c ( in Xcode project navigator ).
However, headers are missing.
I'm a bit confused why it doesn't contain headers in target. ( They are visible, of course, via HEADERS_SEARCH_PATH flag ), but they are not listed as headers in target.

For example, http-parser contains both http_parser.c and http_parser.h.
I expect the same for ntlmclient. ( All mandatory headers are included ).

Also I don't see a flag which switches unicode_builtin and unicode_iconv implementations in ntlmclient.

@lolgear
Copy link
Contributor Author

lolgear commented Aug 3, 2021

ntlm.c includes

#include "ntlm.h"
#include "unicode.h"
#include "utf8.h"
#include "crypt.h"
#include "compat.h"
#include "util.h"

so these headers should be added to a Xcode target.

This change is a try to understand which headers are required by ntlmclient since it contains different implementations of crypto-backends. ( and different implementations for unicode-backend? )
Also this change will not affect ( should not affect ) a build and only a cosmetic change ( add proper headers to a target in CMakeLists.txt )

@ethomson
Copy link
Member

ethomson commented Aug 3, 2021

If I'm understanding what you're saying, the lack of .h files in ntlmclient's cmake definition is probably an oversight. If we're not listing the .h files in ADD_LIBRARY or TARGET_SOURCES, then that should still compile properly, but it may not list the files properly in the IDE definitions. From this helpful blog post:

In the above example, note that .h header files were specified as sources too, not just the .cpp implementation files. Headers listed as sources don’t get compiled directly on their own, but the effect of adding them is for the benefit of IDE generators like Visual Studio, Xcode, Qt Creator, etc. This causes those headers to be listed in the project’s file list within the IDE, even if no source file refers to it via #include. This can make those headers easier to find during development and potentially aid things like refactoring functionality, etc.


I was typing at the same time you were. 😁 Yes, I agree that these should probably be included in the Xcode target.

@lolgear
Copy link
Contributor Author

lolgear commented Aug 3, 2021

Interesting, I've found another part of deprecated source?

FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "unicode_builtin.c" "util.c")

No chance that unicode_iconv.c will be chosen.

@ethomson
Copy link
Member

ethomson commented Aug 3, 2021

No chance that unicode_iconv.c will be chosen.

Ah, interesting. If I were to do it over again, I would probably look at the GIT_USE_ICONV flag that we use elsewhere. iconv is basically a requirement on macOS to deal with Unicode path canonicalization (core.precomposeunicode). But that's probably not a huge deal. 🤔

@lolgear
Copy link
Contributor Author

lolgear commented Aug 3, 2021

Maybe it is better to separate parameters and pass them from libgit2 CMakeLists.txt to internal ntlmclient CMakeLists.txt? ( If CMake supports parameters for CMakeLists-intercommunication ).

@lolgear
Copy link
Contributor Author

lolgear commented Sep 4, 2021

Changes are merged in #5974.
Closing issue.

@lolgear lolgear closed this as completed Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants