]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: cmake -DOFFLINE=TRUE for offline builds (#1341)
authorRafael Kitover <rkitover@gmail.com>
Sun, 29 Oct 2023 08:31:15 +0000 (08:31 +0000)
committerGitHub <noreply@github.com>
Sun, 29 Oct 2023 08:31:15 +0000 (09:31 +0100)
Add the cmake option OFFLINE, defaulting to the value of the standard
variable FETCHCONTENT_FULLY_DISCONNECTED, which is OFF by default, to
disable downloading anything from the internet.

When ON, set FETCHCONTENT_FULLY_DISCONNECTED to ON, ZSTD_FROM_INTERNET
to OFF and HIREDIS_FROM_INTERNET to OFF.

When downloading is OFF and either library is not found, throw an error
using find_package_handle_standard_args().

Add the option to INSTALL.md doc.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
CMakeLists.txt
cmake/Findhiredis.cmake
cmake/Findzstd.cmake
doc/INSTALL.md

index 403e64740ba3e642cb25b45e27056c33ccb9bac0..dcfc82981cf9c46d13153fee1223e915390d07f3 100644 (file)
@@ -84,12 +84,23 @@ include(GenerateVersionFile)
 #
 # Third party
 #
+
 set(ZSTD_FROM_INTERNET AUTO CACHE STRING "Download and use libzstd from the Internet")
 set_property(CACHE ZSTD_FROM_INTERNET PROPERTY STRINGS AUTO ON OFF)
 
 set(HIREDIS_FROM_INTERNET AUTO CACHE STRING "Download and use libhiredis from the Internet")
 set_property(CACHE HIREDIS_FROM_INTERNET PROPERTY STRINGS AUTO ON OFF)
 
+option(
+  OFFLINE "Do not download anything from the internet"
+  "$(FETCHCONTENT_FULLY_DISCONNECTED}"
+)
+if(OFFLINE)
+  set(FETCHCONTENT_FULLY_DISCONNECTED ON)
+  set(ZSTD_FROM_INTERNET OFF)
+  set(HIREDIS_FROM_INTERNET OFF)
+endif()
+
 find_package(zstd 1.1.2 MODULE REQUIRED)
 
 option(REDIS_STORAGE_BACKEND "Enable Redis remote storage" ON)
index 7c5b2d1cb3032404b3a88bd956d6d65c59d61213..6374c34783d15affd2b222316403264c5ce36712 100644 (file)
@@ -51,6 +51,12 @@ else()
   elseif(HIREDIS_FROM_INTERNET STREQUAL "AUTO")
     message(STATUS "*** WARNING ***: Using hiredis from the Internet because it was not found and HIREDIS_FROM_INTERNET is AUTO")
     set(do_download TRUE)
+  else()
+    include(FindPackageHandleStandardArgs)
+    find_package_handle_standard_args(
+      hiredis
+      REQUIRED_VARS HIREDIS_LIBRARY HIREDIS_INCLUDE_DIR
+    )
   endif()
 endif()
 
index 14aeda5c26207a14a18ac638fc6a9a16487a240c..dd69351d8d417c9b19e2266619f048abab9b4764 100644 (file)
@@ -46,6 +46,12 @@ else()
   elseif(ZSTD_FROM_INTERNET STREQUAL "AUTO")
     message(STATUS "*** WARNING ***: Using zstd from the Internet because it was not found and ZSTD_FROM_INTERNET is AUTO")
     set(do_download TRUE)
+  else()
+    include(FindPackageHandleStandardArgs)
+    find_package_handle_standard_args(
+      zstd
+      REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR
+    )
   endif()
 endif()
 
index 920cb4de89f632c4d69ef3e1fe0e02671eece0c6..05dd77d05dc7dc69286a221e3828d7a7f1ca4f79 100644 (file)
@@ -14,9 +14,10 @@ To build ccache you need:
 - [libzstd](http://www.zstd.net). If you don't have libzstd installed and can't
   or don't want to install it in a standard system location, it will be
   automatically downloaded, built and linked statically as part of the build
-  process. To disable this, pass `-DZSTD_FROM_INTERNET=OFF` to `cmake`, or pass
-  `-DZSTD_FROM_INTERNET=ON` to force downloading. You can also install zstd in a
-  custom path and pass `-DCMAKE_PREFIX_PATH=/some/custom/path` to `cmake`.
+  process. To disable this, pass `-DOFFLINE=TRUE` or `-DZSTD_FROM_INTERNET=OFF`
+  to `cmake`, or pass `-DZSTD_FROM_INTERNET=ON` to force downloading. You can
+  also install zstd in a custom path and pass
+  `-DCMAKE_PREFIX_PATH=/some/custom/path` to `cmake`.
 
   To link libzstd statically (and you have a static libzstd available), pass
   `-DSTATIC_LINK=ON` to `cmake`. This is the default on Windows. Alternatively,
@@ -25,12 +26,13 @@ To build ccache you need:
 Optional:
 
 - [hiredis](https://github.com/redis/hiredis) for the Redis storage backend. If
-  you don't have libhiredis installed and can't or don't want to install it in a
-  standard system location, it will be automatically downloaded, built and
+  you don't have libhiredis installed and can't or don't want to install it in
+  standard system location, it will be automatically downloaded, built and
   linked statically as part of the build process. To disable this, pass
-  `-DHIREDIS_FROM_INTERNET=OFF` to `cmake`, or pass `-DHIREDIS_FROM_INTERNET=ON`
-  to force downloading.. You can also install hiredis in a custom path and pass
-  `-DCMAKE_PREFIX_PATH=/some/custom/path` to `cmake`.
+  `-DOFFLINE=TRUE` or `-DHIREDIS_FROM_INTERNET=OFF` to `cmake`, or pass
+  `-DHIREDIS_FROM_INTERNET=ON` to force downloading. You can also install
+  hiredis in a custom path and pass `-DCMAKE_PREFIX_PATH=/some/custom/path` to
+  `cmake`.
 
   To link libhiredis statically (and you have a static libhiredis available),
   pass `-DSTATIC_LINK=ON` to `cmake`. This is the default on Windows.