|
1 | 1 | #[[
|
2 | 2 | Build options:
|
3 |
| - * BUILD_SHARED_LIBS (default off) builds as a static library (if HTTPLIB_COMPILE is ON) |
| 3 | + * BUILD_SHARED_LIBS (default off) builds as a shared library (if HTTPLIB_COMPILE is ON) |
4 | 4 | * HTTPLIB_USE_OPENSSL_IF_AVAILABLE (default on)
|
5 | 5 | * HTTPLIB_USE_ZLIB_IF_AVAILABLE (default on)
|
6 | 6 | * HTTPLIB_REQUIRE_OPENSSL (default off)
|
|
60 | 60 | ]]
|
61 | 61 | cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
|
62 | 62 |
|
63 |
| -# Gets the latest tag as a string like "v0.6.6" |
64 |
| -# Can silently fail if git isn't on the system |
65 |
| -execute_process(COMMAND git describe --tags --abbrev=0 |
66 |
| - OUTPUT_VARIABLE _raw_version_string |
67 |
| - ERROR_VARIABLE _git_tag_error |
68 |
| -) |
| 63 | +# On systems without Git installed, there were errors since execute_process seemed to not throw an error without it? |
| 64 | +find_package(Git QUIET) |
| 65 | +if(Git_FOUND) |
| 66 | + # Gets the latest tag as a string like "v0.6.6" |
| 67 | + # Can silently fail if git isn't on the system |
| 68 | + execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 |
| 69 | + OUTPUT_VARIABLE _raw_version_string |
| 70 | + ERROR_VARIABLE _git_tag_error |
| 71 | + ) |
| 72 | +endif() |
69 | 73 |
|
70 | 74 | # execute_process can fail silenty, so check for an error
|
71 | 75 | # if there was an error, just use the user agent as a version
|
72 |
| -if(_git_tag_error) |
73 |
| - message(WARNING "cpp-httplib failed to find the latest git tag, falling back to using user agent as the version.") |
| 76 | +if(_git_tag_error OR NOT Git_FOUND) |
| 77 | + message(WARNING "cpp-httplib failed to find the latest Git tag, falling back to using user agent as the version.") |
74 | 78 | # Get the user agent and use it as a version
|
75 | 79 | # This gets the string with the user agent from the header.
|
76 | 80 | # This is so the maintainer doesn't actually need to update this manually.
|
@@ -101,7 +105,7 @@ if(HTTPLIB_COMPILE)
|
101 | 105 | endif()
|
102 | 106 |
|
103 | 107 | option(HTTPLIB_REQUIRE_BROTLI "Requires Brotli to be found & linked, or fails build." OFF)
|
104 |
| -option(HTTPLIB_USE_BROTLI_IF_AVAILABLE "Uses Brotli (if available) to enable Brotli compression support." ON) |
| 108 | +option(HTTPLIB_USE_BROTLI_IF_AVAILABLE "Uses Brotli (if available) to enable Brotli decompression support." ON) |
105 | 109 | # Defaults to static library
|
106 | 110 | option(BUILD_SHARED_LIBS "Build the library as a shared library instead of static. Has no effect if using header-only." OFF)
|
107 | 111 | if (BUILD_SHARED_LIBS AND WIN32 AND HTTPLIB_COMPILE)
|
|
0 commit comments