cmake


Log

Author Commit Date CI Message
Michał Górny 8bc9eda7 2022-02-13T21:23:56 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) ```
Edward Thomson 46885ac9 2022-01-30T21:20:29 Merge pull request #6153 from arroz/fix/apple-static-lib Disabling setting `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple platforms.
Miguel Arroz be320340 2022-01-09T11:59:16 Introduced `LINK_WITH_STATIC_LIBRARIES` per PR comments.
Dimitris Apostolou 90df4302 2022-01-05T12:18:05 Fix typos
Miguel Arroz 3eb39819 2021-12-29T15:26:33 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.
Josh Junon c5cd71b2 2021-12-23T18:23:34 cmake: use PROJECT_SOURCE_DIR of CMAKE_SOURCE_DIR Also applies to *_BINARY_DIR. This effectively reverts 84083dcc8bd41332ccac9d7b537f3e254d79011c, 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.
Edward Thomson 84083dcc 2021-11-19T08:48:08 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`.
Edward Thomson 1b8d14ac 2021-11-17T08:25:56 cmake: use WINHTTP when USE_WINHTTP is specified
Edward Thomson 2c154145 2021-11-11T23:09:44 cmake: move sha1 source selection into CMakeLists.txt The select hashes module selects the hash; the CMakeLists.txt selects the files to implement it.
Edward Thomson 395b3dc4 2021-11-11T22:10:51 cmake: refactor global variables Update the global variables `LIBGIT2_OBJECTS` to `LIBGIT2_DEPENDENCY_OBJECTS` for clarity and consistency.
Edward Thomson c3fec456 2021-11-11T22:37:36 cmake: reformat modules Apply the standard project cmake formatting to the modules.
Edward Thomson 4a6ef5a4 2021-11-11T17:04:24 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.
Edward Thomson f0cb3788 2021-11-10T21:51:55 cmake: refactor regex selection Move regex selection into its own cmake module.
Edward Thomson de178d36 2021-11-10T21:49:20 cmake: refactor http_parser selection Move http_parser selection into its own cmake module.
Edward Thomson 16b6e3a9 2021-11-10T21:33:28 cmake: HTTP_Parser is now HTTPParser
Edward Thomson 4e84ddd5 2021-11-10T21:59:46 cmake: refactor zlib selection Move zlib selection into its own cmake module.
Edward Thomson 83fa5480 2021-11-10T21:58:12 cmake: refactor WinHTTP selection Move WinHTTP selection into its own cmake module.
Edward Thomson e35a22a0 2021-11-10T21:55:23 cmake: refactor libssh2 selection Move SSH selection into its own cmake module.
Edward Thomson 9f37457e 2021-11-06T16:23:03 cmake: move cflag defaults into a separate module
Edward Thomson 789ab915 2021-11-10T21:02:42 cmake: standardize USE_WINHTTP WinHTTP can now be disabled with `USE_WINHTTP=OFF` instead of `WINHTTP=OFF` to better support the other cmake semantics.
Edward Thomson 9324d16e 2021-11-06T16:14:47 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.
Martin Kühl f66e7f36 2021-10-28T10:25:09 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.
Laurent Stacul 0a3a220f 2021-09-14T09:53:24 Discover libssh2 without pkg-config
Dmitry Lobanov 4c0ea9f0 2021-08-28T20:18:38 cmake: select hashes umbrella variable has been removed. Co-authored-by: Edward Thomson <ethomson@github.com>
Dmitry Lobanov 08b3ee2f 2021-08-07T15:56:29 cmake: select hashes missing umbrella header has been added.
Edward Thomson 0903cac1 2021-08-11T01:30:38 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.
Edward Thomson 3062a633 2021-07-30T12:03:35 cmake: extended futimens checking on macOS
Patrick Steinhardt 9bc6e655 2020-06-05T11:37:30 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.
Patrick Steinhardt bc02bcd9 2020-04-03T19:51:22 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.
Patrick Steinhardt b85eefb4 2020-05-15T19:52:40 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.
Patrick Steinhardt 541de515 2020-04-01T17:36:13 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.
Patrick Steinhardt 87fc539f 2020-03-13T22:08:19 cmake: use install directories provided via GNUInstallDirs We currently hand-code logic to configure where to install our artifacts via the `LIB_INSTALL_DIR`, `INCLUDE_INSTALL_DIR` and `BIN_INSTALL_DIR` variables. This is reinventing the wheel, as CMake already provide a way to do that via `CMAKE_INSTALL_<DIR>` paths, e.g. `CMAKE_INSTALL_LIB`. This requires users of libgit2 to know about the discrepancy and will require special hacks for any build systems that handle these variables in an automated way. One such example is Gentoo Linux, which sets up these paths in both the cmake and cmake-utils eclass. So let's stop doing that: the GNUInstallDirs module handles it in a better way for us, especially so as the actual values are dependent on CMAKE_INSTALL_PREFIX. This commit removes our own set of variables and instead refers users to use the standard ones. As a second benefit, this commit also fixes our pkgconfig generation to use the GNUInstallDirs module. We had a bug there where we ignored the CMAKE_INSTALL_PREFIX when configuring the libdir and includedir keys, so if libdir was set to "lib64", then libdir would be an invalid path. With GNUInstallDirs, we can now use `CMAKE_INSTALL_FULL_LIBDIR`, which handles the prefix for us.
Edward Thomson e23b8b44 2020-03-06T17:13:48 Merge pull request #5422 from pks-t/pks/cmake-booleans CMake booleans
Patrick Steinhardt 41b6d30c 2020-02-24T21:03:11 cmake: sanitize boolean options passed by user Starting with our conversions to mix backend-autodetection and selection into a single variable (USE_GSSAPI, USE_HTTPS, USE_SHA1), we have introduced a simple STREQUAL to check for "ON", which indicates that the user wants us to auto-detect available backends and pick any one that's available. This behaviour deviates from previous behaviour, as passing a value like "yes", "on" or "true" will in fact be treated like a backend name and result in autodetection failure. Fix the issue by introducing a new function `SanitizeBool`. Given a variable that may hold a boolean value, the function will sanitize that variable to hold either "ON" or "OFF". In case it is not a recognized boolean, we will just keep the value as-is. This fixes the above described issue.
Tomasz Kłoczko fbda0575 2020-02-19T12:54:19 Fix #5410: fix installing libgit2.pc in wrong location Remove using custom PKG_BUILD_PREFIu, PKG_BUILD_LIBDIR and PKG_BUILD_INCLUDEDIR variables. Use cmake CMAKE_INSTALL_PREFIX, LIB_INSTALL_DIR, INCLUDE_INSTALL_DIR instead. This patch fixes install libgit2.pc file in correct location and simpifies cmake module.
Edward Thomson 89d1fc2a 2019-10-22T09:30:50 gssapi: show information about disabled GSSAPI When USE_GSSAPI=OFF, still show information about what SPNEGO is, even though it's disabled. This is for parity with other disabled features like SSH and debugpool that still show details about what is disabled.
Patrick Steinhardt 0298e0a6 2019-10-17T12:24:25 Merge pull request #5238 from tiennou/feature/macos-gss macOS GSS Support
Etienne Samson a088a1ff 2019-10-13T14:06:47 cmake: correct the link stanza for CoreFoundation LIBRARIES is the (absolute?) path to the library. LDFLAGS is the full linker stanza to correctly link with this lib. By passing LIBRARIES as LIBGIT_LIBS, the linker ends up with the absolute path for the SDK'ed version of CoreFoundation (which doesn't exist), instead of the familiar `-framework CoreFoundation`.
Etienne Samson dbc17a7e 2019-09-21T08:46:08 negotiate: use GSS.framework on macOS
Edward Thomson 63307cba 2019-09-28T17:32:18 Merge pull request #5226 from pks-t/pks/regexp-api regexp: implement a new regular expression API
Patrick Steinhardt f585b129 2019-09-12T14:29:28 posix: remove superseded POSIX regex wrappers The old POSIX regex wrappers have been superseded by our own regexp API that provides a higher-level abstraction. Remove the POSIX wrappers in favor of the new one.
Etienne Samson d80d9d56 2019-08-17T12:17:21 cmake: streamline *.pc file handling via a module
Patrick Steinhardt 212b6f65 2019-08-02T14:00:21 cmake: fix various misuses of MESSAGE() The MESSAGE() function expects as first argument the message type, e.g. STATUS or FATAL_ERROR. In some places, we were misusing this to either not provide any type, which would then erroneously print the message to standard error, or to use FATAL instead of FATAL_ERROR. Fix all of these instances. Also, remove some MESSAGE invocations that are obvious leftovers from debugging the build system.
Patrick Steinhardt e77fdf87 2019-08-02T13:49:36 cmake: properly abort if no mbedTLS cert location is found When using mbedTLS as backend, then the user may specify the location of where system certificates are installed. If no such location is provided by the user, CMake will try to autodetect the location by using the openssl executable, if installed. If no location could be detected, then the mbedTLS is essentially worthless as it is completely unable to verify any certificates. To avoid use of such misconfigured mbedTLS configurations, let's error out if we were unable to find out the location.
Etienne Samson 1ed10009 2019-09-06T10:32:06 cmake: remove extraneous logging
Patrick Steinhardt b7c247b3 2019-07-18T13:37:02 cmake: include SHA1 headers into our source files When selecting the SHA1 backend, we only include the respective C implementation of the selected backend. But since commit bd48bf3fb (hash: introduce source files to break include circles, 2019-06-14), we have introduced separate headers and compilation units for all hashes. So by not including the headers, we may not honor them to compute whether a file needs to be recompiled and they also will not be displayed in IDEs. Add the header files to fix this problem.
Patrick Steinhardt df54c7fb 2019-06-27T07:34:43 cmake: report whether we are using sub-second stat information Depending on the platform and on build options, we may or may not build libgit2 with support for nanoseconds when using `stat` calls. It's currently unclear though whether sub-second stat information is used at all. Add feature info for this to tell at configure time whether it's being used or not.
Patrick Steinhardt e9102def 2019-06-27T11:38:04 Merge pull request #4438 from pks-t/pks/hash-algorithm Multiple hash algorithms
Patrick Steinhardt fda20622 2019-06-14T14:22:19 hash: move SHA1 implementations into 'sha1/' folder As we will include additional hash algorithms in the future due to upstream git discussing a move away from SHA1, we should accomodate for that and prepare for the move. As a first step, move all SHA1 implementations into a common subdirectory. Also, create a SHA1-specific header file that lives inside the hash folder. This header will contain the SHA1-specific header includes, function declarations and the SHA1 context structure.
Edward Thomson cc9e47c9 2019-06-15T18:51:40 win32: support upgrading warnings to errors (/WX) For MSVC, support warnings as errors by providing the /WX compiler flags. (/WX is the moral equivalent of -Werror.) Disable warnings as errors ass part of xdiff, since it contains warnings. But as a component of git itself, we want to avoid skew and keep our implementation as similar as possible to theirs. We'll work with upstream to fix these issues, but in the meantime, simply let those continue to warn.
Patrick Steinhardt bd48bf3f 2019-06-14T14:21:32 hash: introduce source files to break include circles The hash source files have circular include dependencies right now, which shows by our broken generic hash implementation. The "hash.h" header declares two functions and the `git_hash_ctx` typedef before actually including the hash backend header and can only declare the remaining hash functions after the include due to possibly static function declarations inside of the implementation includes. Let's break this cycle and help maintainability by creating a real implementation file for each of the hash implementations. Instead of relying on the exact include order, we now especially avoid the use of `GIT_INLINE` for function declarations.
Etienne Samson 94fc83b6 2019-06-13T16:48:35 cmake: Modulize our TLS & hash detection The interactions between `USE_HTTPS` and `SHA1_BACKEND` have been streamlined. Previously we would have accepted not quite working configurations (like, `-DUSE_HTTPS=OFF -DSHA1_BACKEND=OpenSSL`) and, as the OpenSSL detection only ran with `USE_HTTPS`, the link would fail. The detection was moved to a new `USE_SHA1`, modeled after `USE_HTTPS`, which takes the values "CollisionDetection/Backend/Generic", to better match how the "hashing backend" is selected, the default (ON) being "CollisionDetection". Note that, as `SHA1_BACKEND` is still used internally, you might need to check what customization you're using it for.
Edward Thomson ce6d624a 2019-05-19T10:30:04 regex: optionally use PCRE2 Use PCRE2 and its POSIX compatibility layer if requested by the user. Although PCRE2 is adequate for our needs, the PCRE2 POSIX layer as installed on Debian and Ubuntu systems is broken, so we do not opt-in to it by default to avoid breaking users on those platforms.
Edward Thomson 69ecdad5 2019-05-19T10:09:55 regex: use system PCRE if available Attempt to locate a system-installed version of PCRE and use its POSIX compatibility layer, if possible.
cheese1 67562b23 2019-04-07T16:45:45 fix typo
lhchavez 6af6170b 2019-01-05T20:50:42 Make ENABLE_WERROR actually work This change explicitly adds -Werror to the CFLAGS. Due to the way that the ADD_C_FLAG_IF_SUPPORTED() macro was mangling the flag name to convert it into a define name, any warning that had a dash in its name was not being correctly enabled. Additionally, any flag that is enabled implicitly by the compiler (like -Wunused-result and -Wdeprecated-declarations) would not cause an error unless they were explicitly enabled with the ENABLE_WARNINGS() macro.
Etienne Samson 1a9cc182 2018-08-17T15:56:30 util: make the qsort_r check work on macOS This performs a compile-check by using CMake support, to differentiate the GNU version from the BSD version of qsort_r. Module taken from 4f252abea5f1d17c60f6ff115c9c44cc0b6f1df6, which I've checked against CMake 2.8.11.
Patrick Steinhardt 2e2d8c64 2018-08-24T09:53:39 cmake: detect and use libc-provided iconv While most systems provide a separate iconv library against which applications can link, musl based systems do not provide such a library. Instead, iconv functions are directly included in the C library. As our current CMake module to locate the iconv library only checks whether a library exists somewhere in the typical library directories, we will never build libgit2 with libiconv support on such systems. Extend the iconv module to also search whether libc provides iconv functions, which we do by checking whether the `iconv_open` function exists inside of libc. If this is the case, we will default to use the libc provided one instead of trying to use a separate libiconv. While this changes which iconv we use on systems where both libc and an external libiconv exist, to the best of my knowledge common systems only provide either one or the other. Note that libiconv support in musl is held kind of basic. To quote musl libc's page on functional differences from glibc [1]: The iconv implementation musl is very small and oriented towards being unobtrusive to static link. Its character set/encoding coverage is very strong for its size, but not comprehensive like glibc’s. As we assume iconv to be a lot more capable than what musl provides, some of our tests will fail if using iconv on musl-based platforms. [1]: https://wiki.musl-libc.org/functional-differences-from-glibc.html
Patrick Steinhardt 186a7ba5 2018-07-19T15:13:40 cmake: error out if required C flags are not supported We do want to notify users compiling our source code early on if they try to use C flags which aren't supported. Add a new macro `AddCFlag`, which results in a fatal error in case the flag is not supported, and use it for our fuzzing flags.
Patrick Steinhardt 0f62e4c7 2018-04-27T10:38:49 cmake: resolve libraries found by pkg-config Libraries found by CMake modules are usually handled with their full path. This makes linking against those libraries a lot more robust when it comes to libraries in non-standard locations, as otherwise we might mix up libraries from different locations when link directories are given. One excemption are libraries found by PKG_CHECK_MODULES. Instead of returning libraries with their complete path, it will return the variable names as well as a set of link directories. In case where multiple sets of the same library are installed in different locations, this can lead the compiler to link against the wrong libraries in the end, when link directories of other dependencies are added. To fix this shortcoming, we need to manually resolve library paths returned by CMake against their respective library directories. This is an easy task to do with `FIND_LIBRARY`.
Etienne Samson ca3b2234 2018-03-29T22:13:56 mbedtls: initial support
Edward Thomson f8a2dda8 2018-02-05T15:21:37 cmake: move ENABLE_WARNINGS to a module
Edward Thomson fc6e38c2 2018-02-02T18:03:38 cmake: Move IDE source munging to a module Move the odd code that provides a hierarchical display for projects within the IDEs to its own module.
Edward Thomson ed298c8e 2018-02-02T18:01:51 cmake: move nanosecond detection to a module Move the nanosecond detection in time structures to its own module.
Etienne Samson 99d6ebb3 2017-09-06T22:01:50 cmake: make our macOS helpers more CMake-y
Etienne Samson 152f3766 2017-09-06T21:53:58 cmake: fix indentation before enhancing
Jiří Techet b7df2e8b 2015-05-01T22:48:33 Don't search iconv in /opt/local Since OpenSSL isn't used any more on OS X, there is no dependency on any MacPorts library under /opt/local and there is no danger of conflicts between MacPorts and system iconv. For this reason the system iconv can always be used now.
Carlos Martín Nieto 6bb54cbf 2014-11-02T13:23:32 Add a SecureTransport TLS channel As an alternative to OpenSSL when we're on OS X. This one can actually take advantage of stacking the streams.
Carlos Martín Nieto 4f91bfa3 2014-12-05T10:32:59 Find libssh2 via pkg-config We don't really need our own module to find libssh2. Using pkg-config lets the standard tool do the work for us and let us fit more naturally in the workflow as we respect the pkg-config search paths.
Edward Thomson 315cb38e 2014-07-31T18:43:20 Add GSSAPI support for SPNEGO/Kerberos auth over HTTP
Jacques Germishuys 5c8d5eac 2014-04-19T23:07:50 Introduce AddCFlagIfSupported CMake macro
Sascha Cunz 4bc94eb5 2014-01-30T03:01:46 We never search for libiconv via pkg-config So we actually also never know that we can set a dependency on it in pkg-config. Instead always give it the -L and -l options.
Sascha Cunz 6e0ff093 2014-01-30T02:30:55 Find and use a MacPorts version of libiconv. Fixes #2017. - Add correct -I, -L and -l flags - Search for libiconv in /opt/local/[include|lib] before in the system path. See #2017 for details. - Give splitted -L and -l arguments to pkg-config
Sascha Cunz 39949f06 2014-01-30T02:28:53 Cleanup FindIconv.cmake Doesn't change anything. Just removes stuff that was probably missed to remove when this was imported.
Russell Belfer 726b75d1 2013-12-02T11:32:37 Improve iconv finding for cmake * add FindIconv helper for CMake iconv detection * only default using iconv to ON for MacOS * update pkg-config generation to include iconv dependency better
Veeti Paananen 7a6e0281 2013-05-02T14:07:22 Build with the system's http-parser installation if available
Brad Morgan a6b79b9b 2013-05-15T12:49:15 Changed case of FindLibSSH2.cmake to FindLIBSSH2.cmake
Brad Morgan 6cbbd739 2013-05-15T12:48:43 Renamed FindLibSSH2.cmake
Brad Morgan 7369b3c3 2013-05-07T14:26:33 Added libssh2 cmake module