Commit Graph

98 Commits

Author SHA1 Message Date
Edward Thomson
3335738579 cmake: refactor check_prototype_definition
Introduce `check_prototype_definition_safe` that is safe for `Werror`
usage.
2023-05-12 21:49:29 +01:00
Edward Thomson
abb0b31317 Merge pull request #6482 from libgit2/ethomson/xdiff
xdiff: move xdiff to 'deps'
2023-04-13 23:08:15 +01:00
Edward Thomson
f15c8ac71a http: add SSPI authentication on Windows
Add support for SSPI on Windows, which offers NTLM and Negotiate
authentication.
2023-03-21 09:15:14 +00:00
Edward Thomson
f68f542eb6 http: introduce schannel streams for windows
Provide a stream interface for Schannel - the native crypto APIs - on
Windows. This allows Windows to use the same HTTP transport that all the
other platforms use, with its own native crypto.

Ultimately this allows us to deprecate WinHTTP and we need not add
support for our socket changes in two places (our HTTP stack and the
WinHTTP stack).
2023-03-21 09:09:48 +00:00
Edward Thomson
462dbe21d0 xdiff: move xdiff to 'deps'
xdiff is a dependency (from git core) and more properly belongs in the
'deps' directory. Move it there, and add a stub for cmake to resolve
xdiff from the system location in the future. (At present, bundled xdiff
remains hardcoded.)
2023-03-03 09:45:12 +00:00
Edward Thomson
d63f1fe245 cmake: support older cmakes 2023-02-13 10:27:10 +00:00
Edward Thomson
c11724686c cmake: provide empty experimental.h for non-cmake users
Not everybody builds libgit2 using cmake; provide an `experimental.h`
with no experiments configured for those that do not. To support this,
we also now create compile definitions for experimental functionality,
to supplant that empty `experimental.h`. cmake will continue to generate
the proper `experimental.h` file for use with `make install`.
2022-09-19 06:34:51 -04:00
Edward Thomson
433a133402 Merge pull request #6191 from libgit2/ethomson/sha256_poc
RFC: SHA256 proof of concept
2022-07-13 21:08:04 -04:00
Jan Palus
636a275218 cmake: drop posix dependency from pcre* detection
since f585b12 neither PCRE nor PCRE2 backends rely on POSIX regex, so
reflect it in library detection logic
2022-07-07 10:50:08 +02:00
Edward Thomson
6c57bac6b1 sha256: make sha256 an experimental optional feature
libgit2 can be built with optional, experimental sha256 support. This
allows consumers to begin testing and providing feedback for our sha256
support while we continue to develop it, and allows us to make API
breaking changes while we iterate on a final sha256 implementation.

The results will be `git2-experimental.dll` and installed as
`git2-experimental.h` to avoid confusion with a production libgit2.
2022-06-20 17:12:49 -04:00
Edward Thomson
3bd9bb8d77 sha256: support dynamically loaded openssl 2022-04-04 13:29:19 -04:00
Edward Thomson
6a7d5d23c7 sha: support Win32 for SHA256
Adding SHA256 support prompted an overdue refactoring of some of the
unnecessary complexity around the CNG/CryptoAPI abstraction.
2022-03-23 08:39:19 -04:00
Edward Thomson
6b4a6faab3 sha: support OpenSSL for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
b3e3fa10ea sha: support mbedTLS for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
83c2778611 sha: support CommonCrypto for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
b900981cf7 sha: add sha256 algorithm
Add support for a SHA256 hash algorithm, and add the "builtin" SHA256
hash engine (from RFC 6234).
2022-03-23 08:39:19 -04:00
Edward Thomson
8bc998f481 sha1: remove generic implementation
Remove the "generic" implementation; it should never be used; it only
existed for a no-dependencies configuration, and our bundled sha1dc
satisfies that requirement _and_ is correct.
2022-03-23 08:39:19 -04:00
Edward Thomson
d02f4f7ad7 cmake: refactor add_clar_test into separate module 2022-02-22 22:07:45 -05:00
Edward Thomson
c3b7ace9cf refactor: make util an object library
Instead of simply including the utility files directly, make them a
cmake object library for easy reusability between other projects within
libgit2.

Now the top-level `src` is responsible for platform selection, while the
next-level `libgit2` and `util` configurations are responsible for
identifying what objects they include.
2022-02-22 22:07:44 -05:00
Michał Górny
8bc9eda779 cmake: Fix package name for system http-parser
Fix building against system http-parser library by fixing
the find_package() argument.  It seems to have been accidentally changed
from HTTPParser to HTTP_Parser in de178d36f, effectively making
the build against system library fail to find it:

```
CMake Warning at cmake/SelectHTTPParser.cmake:3 (find_package):
  By not providing "FindHTTP_Parser.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "HTTP_Parser", but CMake did not find one.

  Could not find a package configuration file provided by "HTTP_Parser" with
  any of the following names:

    HTTP_ParserConfig.cmake
    http_parser-config.cmake

  Add the installation prefix of "HTTP_Parser" to CMAKE_PREFIX_PATH or set
  "HTTP_Parser_DIR" to a directory containing one of the above files.  If
  "HTTP_Parser" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  src/CMakeLists.txt:97 (include)

CMake Error at cmake/SelectHTTPParser.cmake:11 (message):
  http-parser support was requested but not found
Call Stack (most recent call first):
  src/CMakeLists.txt:97 (include)
```
2022-02-13 21:23:56 +01:00
Edward Thomson
46885ac9a4 Merge pull request #6153 from arroz/fix/apple-static-lib
Disabling setting `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple platforms.
2022-01-30 21:20:29 -05:00
Miguel Arroz
be320340ed Introduced LINK_WITH_STATIC_LIBRARIES per PR comments. 2022-01-09 11:59:16 -08:00
Dimitris Apostolou
90df43022a Fix typos 2022-01-05 16:35:52 +02:00
Miguel Arroz
3eb3981978 Disabling setting CMAKE_FIND_LIBRARY_SUFFIXES on Apple platforms.
On macOS, since Big Sur, the libraries were moved to a cache. The SDK comes
with stubs in the SDK (`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/`
or whatever SDK version one has installed) where most have the `.tbd` suffix
(although some still are `.a`). Forcing `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple
platforms broke building, unless one has copies of the libraries installed
elsewhere (like Brew), as many libraries (like `iconv` or `pcre`) are not
found.

This fix disables setting the `CMAKE_FIND_LIBRARY_SUFFIXES` to `.a` if
the platform is `APPLE` when building static libs.
2021-12-29 15:26:33 -08:00
Josh Junon
c5cd71b203 cmake: use PROJECT_SOURCE_DIR of CMAKE_SOURCE_DIR
Also applies to *_BINARY_DIR.

This effectively reverts 84083dcc8b,
which broke all users of libgit2 that use it as a CMake subdirectory
(via `add_subdirectory()`). This is because CMAKE_SOURCE_DIR refers
to the root-most CMake directory, which in the case of
`add_subdirectory()` is a parent project to libgit2 and thus the paths
don't make any sense to the configuration files. Corollary,
CMAKE_SOURCE_DIR only makes sense if the CMake project is always the
root project - which can rarely be guaranteed.

In all honesty, CMake should deprecate and eventually remove
CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. It's been the source of headaches
and confusion for years, they're rarely useful over
CMAKE_CURRENT_(SOURCE|BINARY)_DIR or PROJECT_(SOURCE|BINARY)_DIR,
and they cause a lot of confusing configuration and source
code layouts to boot.

Any time they are used, they break `add_subdirectory()` almost 100% of
the time, cause confusing error messages, and hide subtle bugs.
2021-12-23 18:23:34 +01:00
Edward Thomson
84083dcc8b cmake: use CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR
Instead of using the project-specific `libgit2_SOURCE_DIR` and
`libgit2_BINARY_DIR` variables, use `CMAKE_SOURCE_DIR` and
`CMAKE_BINARY_DIR`.
2021-11-22 09:27:59 -05:00
Edward Thomson
1b8d14ac2a cmake: use WINHTTP when USE_WINHTTP is specified 2021-11-17 08:25:56 -05:00
Edward Thomson
2c154145a8 cmake: move sha1 source selection into CMakeLists.txt
The select hashes module selects the hash; the CMakeLists.txt selects
the files to implement it.
2021-11-14 07:25:41 -05:00
Edward Thomson
395b3dc403 cmake: refactor global variables
Update the global variables `LIBGIT2_OBJECTS` to
`LIBGIT2_DEPENDENCY_OBJECTS` for clarity and consistency.
2021-11-14 07:25:41 -05:00
Edward Thomson
c3fec45645 cmake: reformat modules
Apply the standard project cmake formatting to the modules.
2021-11-14 07:25:41 -05:00
Edward Thomson
4a6ef5a4a6 cmake: move missing-declarations warning to top-level
We should enforce declarations throughout the code-base, including
examples, fuzzers and tests, not just in the `src` tree.
2021-11-11 17:31:43 -05:00
Edward Thomson
4e84ddd5b0 cmake: refactor zlib selection
Move zlib selection into its own cmake module.
2021-11-11 15:56:11 -05:00
Edward Thomson
83fa548078 cmake: refactor WinHTTP selection
Move WinHTTP selection into its own cmake module.
2021-11-11 15:56:11 -05:00
Edward Thomson
e35a22a080 cmake: refactor libssh2 selection
Move SSH selection into its own cmake module.
2021-11-11 15:56:11 -05:00
Edward Thomson
f0cb3788db cmake: refactor regex selection
Move regex selection into its own cmake module.
2021-11-11 15:56:11 -05:00
Edward Thomson
de178d36ff cmake: refactor http_parser selection
Move http_parser selection into its own cmake module.
2021-11-11 15:56:11 -05:00
Edward Thomson
16b6e3a9c9 cmake: HTTP_Parser is now HTTPParser 2021-11-11 15:56:11 -05:00
Edward Thomson
9f37457e17 cmake: move cflag defaults into a separate module 2021-11-11 15:56:10 -05:00
Edward Thomson
789ab91560 cmake: standardize USE_WINHTTP
WinHTTP can now be disabled with `USE_WINHTTP=OFF` instead of
`WINHTTP=OFF` to better support the other cmake semantics.
2021-11-11 15:56:10 -05:00
Edward Thomson
9324d16e73 cmake: standardize USE_THREADS and USE_NSEC
Threading can now be disabled with `USE_THREADS=OFF` instead of
`THREADSAFE=OFF` to better support the other cmake semantics.

Nanosecond support is the default _if_ we can detect it.  This should be
our default always - like threads - and people can opt out explicitly.
2021-11-11 15:56:10 -05:00
Martin Kühl
f66e7f36ff libgit2_clar is now libgit2_tests
in #6083 the test runner was renamed to libgit2_tests,
but not all references to the old name were updated.
this change changes all of them to use the new name.
2021-10-28 10:25:09 +02:00
Laurent Stacul
0a3a220fa9 Discover libssh2 without pkg-config 2021-09-14 09:53:24 +00:00
Dmitry Lobanov
4c0ea9f06d cmake: select hashes umbrella variable has been removed.
Co-authored-by: Edward Thomson <ethomson@github.com>
2021-08-28 20:18:38 +03:00
Dmitry Lobanov
08b3ee2f83 cmake: select hashes missing umbrella header has been added. 2021-08-28 16:17:50 +03:00
Edward Thomson
0903cac1d0 openssl: dynamically load libssl and symbols (optionally)
Provide an interface around OpenSSL to dynamically load the libraries
and symbols, so that users can distribute a libgit2 library that is not
linked directly against OpenSSL.  This enables users to target multiple
distributions with a single binary.

This mechanism is optional and disabled by default.  Configure cmake
with -DUSE_HTTPS=OpenSSL-Dynamic to use it.
2021-08-24 14:09:10 -04:00
Edward Thomson
3062a63364 cmake: extended futimens checking on macOS 2021-07-30 12:03:35 -04:00
Patrick Steinhardt
9bc6e655e1 cmake: remove CheckPrototypeDefinition module
In the past, we've imported the CheckPrototypeDefinition into our own
module directory as it wasn't yet available in all supported CMake
versions. Now that we require at least CMake v3.5, we don't need to
bundle it anymore as it's included with the distribution already.

Let's drop the included modules and always use upstream's version.
2020-07-12 14:45:47 +02:00
Patrick Steinhardt
bc02bcd920 cmake: move modules into the "cmake/" top level dir
Our custom CMake module currently live in "cmake/Modules". As the
"cmake/" directory doesn't contain anything except the "Modules"
directory, it doesn't really make sense to have the additional
intermediate directory. So let's instead move the modules one level up
into the "cmake/" top level directory.
2020-06-01 14:06:20 +02:00
Patrick Steinhardt
b85eefb460 cmake: Sort source files for reproducible builds
We currently use `FILE(GLOB ...)` in most places to find source and
header files. This is problematic in that the order of files returned
depends on the operating system's directory iteration order and may thus
not be deterministic. As a result, we link object files in unspecified
order, which may cause the linker to emit different code across runs.

Fix this issue by sorting all code used as input to the libgit2 library
to improve the reliability of reproducible builds.
2020-05-15 19:57:09 +02:00
Patrick Steinhardt
541de51516 cmake: streamline backend detection
We're currently doing unnecessary work to auto-detect backends even if
the functionality is disabled altogether. Let's fix this by removing the
extraneous FOO_BACKEND variables, instead letting auto-detection modify
the variable itself.
2020-04-01 17:36:13 +02:00