path: testdir.tar.xz
build_macos_universal:
- name: MacOS Universal Binary
+ name: macOS universal binary
runs-on: macos-12
env:
CMAKE_GENERATOR: Ninja
#
# Third party
#
-option(ZSTD_FROM_INTERNET
- "Download and use libzstd from the Internet if not available" ON)
-option(HIREDIS_FROM_INTERNET
- "Download and use libhiredis from the Internet if not available" ON)
+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)
-option(FORCE_INTERNET_ZSTD
- "Only use libzstd from the Internet" 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)
find_package(zstd 1.1.2 MODULE REQUIRED)
build() {
mkdir -p "build_$1"
cd "build_$1"
- cmake -DFORCE_INTERNET_ZSTD=ON -DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" -DCMAKE_OSX_ARCHITECTURES="$1" -DCMAKE_SYSTEM_PROCESSOR="$1" ..
+ cmake \
+ -DZSTD_FROM_INTERNET=ON \
+ -DHIREDIS_FROM_INTERNET=ON \
+ -DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" \
+ -DCMAKE_OSX_ARCHITECTURES="$1" \
+ -DCMAKE_SYSTEM_PROCESSOR="$1" \
+ ..
cmake --build .
cd ..
}
set(hiredis_FOUND FALSE)
-find_package(PkgConfig)
-if(PKG_CONFIG_FOUND)
- pkg_check_modules(HIREDIS hiredis>=${hiredis_FIND_VERSION})
- find_library(HIREDIS_LIBRARY ${HIREDIS_LIBRARIES} HINTS ${HIREDIS_LIBDIR})
- find_path(HIREDIS_INCLUDE_DIR hiredis/hiredis.h HINTS ${HIREDIS_PREFIX}/include)
+if(HIREDIS_FROM_INTERNET AND NOT HIREDIS_FROM_INTERNET STREQUAL "AUTO")
+ message(STATUS "Using hiredis from the Internet")
+ set(do_download TRUE)
else()
- find_library(HIREDIS_LIBRARY hiredis)
- find_path(HIREDIS_INCLUDE_DIR hiredis/hiredis.h)
-endif()
-
-if(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARY)
- mark_as_advanced(HIREDIS_INCLUDE_DIR HIREDIS_LIBRARY)
+ find_package(PkgConfig)
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(HIREDIS hiredis>=${hiredis_FIND_VERSION})
+ find_library(HIREDIS_LIBRARY ${HIREDIS_LIBRARIES} HINTS ${HIREDIS_LIBDIR})
+ find_path(HIREDIS_INCLUDE_DIR hiredis/hiredis.h HINTS ${HIREDIS_PREFIX}/include)
+ if(HIREDIS_LIBRARY AND HIREDIS_INCLUDE_DIR)
+ message(STATUS "Using hiredis from ${HIREDIS_LIBRARY} via pkg-config")
+ set(hiredis_FOUND TRUE)
+ endif()
+ endif()
- add_library(HIREDIS::HIREDIS UNKNOWN IMPORTED)
- set_target_properties(
- HIREDIS::HIREDIS
- PROPERTIES
- IMPORTED_LOCATION "${HIREDIS_LIBRARY}"
- INTERFACE_COMPILE_OPTIONS "${HIREDIS_CFLAGS_OTHER}"
- INTERFACE_INCLUDE_DIRECTORIES "${HIREDIS_INCLUDE_DIR}")
- if(WIN32 AND STATIC_LINK)
- target_link_libraries(HIREDIS::HIREDIS INTERFACE ws2_32)
+ if(NOT hiredis_FOUND)
+ find_library(HIREDIS_LIBRARY hiredis)
+ find_path(HIREDIS_INCLUDE_DIR hiredis/hiredis.h)
+ if(HIREDIS_LIBRARY AND HIREDIS_INCLUDE_DIR)
+ message(STATUS "Using hiredis from ${HIREDIS_LIBRARY}")
+ set(hiredis_FOUND TRUE)
+ endif()
endif()
- set(hiredis_FOUND TRUE)
- set(target HIREDIS::HIREDIS)
-elseif(HIREDIS_FROM_INTERNET)
- message(STATUS "*** WARNING ***: Using hiredis from the internet because it was NOT found and HIREDIS_FROM_INTERNET is TRUE")
+ if(hiredis_FOUND)
+ mark_as_advanced(HIREDIS_INCLUDE_DIR HIREDIS_LIBRARY)
+ add_library(HIREDIS::HIREDIS UNKNOWN IMPORTED)
+ set_target_properties(
+ HIREDIS::HIREDIS
+ PROPERTIES
+ IMPORTED_LOCATION "${HIREDIS_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${HIREDIS_CFLAGS_OTHER}"
+ INTERFACE_INCLUDE_DIRECTORIES "${HIREDIS_INCLUDE_DIR}"
+ )
+ if(WIN32 AND STATIC_LINK)
+ target_link_libraries(HIREDIS::HIREDIS INTERFACE ws2_32)
+ endif()
+ set(hiredis_FOUND TRUE)
+ set(target HIREDIS::HIREDIS)
+ 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)
+ endif()
+endif()
+if(do_download)
set(hiredis_version "1.1.0")
-
set(hiredis_dir ${CMAKE_BINARY_DIR}/hiredis-${hiredis_version})
set(hiredis_build ${CMAKE_BINARY_DIR}/hiredis-build)
include(FetchContent)
-
FetchContent_Declare(
hiredis
- URL https://github.com/redis/hiredis/archive/v${hiredis_version}.tar.gz
- URL_HASH SHA256=fe6d21741ec7f3fc9df409d921f47dfc73a4d8ff64f4ac6f1d95f951bf7f53d6
- SOURCE_DIR ${hiredis_dir}
- BINARY_DIR ${hiredis_build}
+ URL https://github.com/redis/hiredis/archive/v${hiredis_version}.tar.gz
+ URL_HASH SHA256=fe6d21741ec7f3fc9df409d921f47dfc73a4d8ff64f4ac6f1d95f951bf7f53d6
+ SOURCE_DIR ${hiredis_dir}
+ BINARY_DIR ${hiredis_build}
)
FetchContent_GetProperties(hiredis)
-
if(NOT hiredis_POPULATED)
FetchContent_Populate(hiredis)
endif()
if(WIN32 AND hiredis_FOUND)
target_link_libraries(${target} INTERFACE ws2_32)
endif()
-unset(target)
include(FeatureSummary)
set_package_properties(
set(zstd_FOUND FALSE)
-if(NOT FORCE_INTERNET_ZSTD)
+if(ZSTD_FROM_INTERNET AND NOT ZSTD_FROM_INTERNET STREQUAL "AUTO")
+ message(STATUS "Using zstd from the Internet")
+ set(do_download TRUE)
+else()
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_search_module(PC_ZSTD libzstd)
find_library(ZSTD_LIBRARY zstd HINTS ${PC_ZSTD_LIBDIR} ${PC_ZSTD_LIBRARY_DIRS})
find_path(ZSTD_INCLUDE_DIR zstd.h HINTS ${PC_ZSTD_INCLUDEDIR} ${PC_ZSTD_INCLUDE_DIRS})
- else()
+ if(ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR)
+ message(STATUS "Using zstd from ${ZSTD_LIBRARY} via pkg-config")
+ set(zstd_FOUND TRUE)
+ endif()
+ endif()
+
+ if(NOT zstd_FOUND)
find_library(ZSTD_LIBRARY zstd)
find_path(ZSTD_INCLUDE_DIR zstd.h)
+ if(ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR)
+ message(STATUS "Using zstd from ${ZSTD_LIBRARY}")
+ set(zstd_FOUND TRUE)
+ endif()
endif()
-endif()
-
-if(ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR)
- mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY)
-
- add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
- set_target_properties(
- ZSTD::ZSTD
- PROPERTIES
- IMPORTED_LOCATION "${ZSTD_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIR}")
- set(zstd_FOUND TRUE)
-elseif(ZSTD_FROM_INTERNET)
- message(STATUS "*** WARNING ***: Using zstd from the internet because it was NOT found and ZSTD_FROM_INTERNET is TRUE")
+ if(zstd_FOUND)
+ mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY)
+ add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
+ set_target_properties(
+ ZSTD::ZSTD
+ PROPERTIES
+ IMPORTED_LOCATION "${ZSTD_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIR}"
+ )
+ set(zstd_FOUND TRUE)
+ 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)
+ endif()
+endif()
+if(do_download)
# Although ${zstd_FIND_VERSION} was requested, let's download a newer version.
# Note: The directory structure has changed in 1.3.0; we only support 1.3.0
# and newer.
set(zstd_version "1.5.2")
-
set(zstd_dir ${CMAKE_BINARY_DIR}/zstd-${zstd_version})
set(zstd_build ${CMAKE_BINARY_DIR}/zstd-build)
include(FetchContent)
-
FetchContent_Declare(
zstd
- URL https://github.com/facebook/zstd/archive/v${zstd_version}.tar.gz
- URL_HASH SHA256=f7de13462f7a82c29ab865820149e778cbfe01087b3a55b5332707abf9db4a6e
- SOURCE_DIR ${zstd_dir}
- BINARY_DIR ${zstd_build}
+ URL https://github.com/facebook/zstd/archive/v${zstd_version}.tar.gz
+ URL_HASH SHA256=f7de13462f7a82c29ab865820149e778cbfe01087b3a55b5332707abf9db4a6e
+ SOURCE_DIR ${zstd_dir}
+ BINARY_DIR ${zstd_build}
)
FetchContent_GetProperties(zstd)
-
if(NOT zstd_POPULATED)
FetchContent_Populate(zstd)
endif()
zstd
PROPERTIES
URL "https://facebook.github.io/zstd"
- DESCRIPTION "Zstandard - Fast real-time compression algorithm")
+ DESCRIPTION "Zstandard - Fast real-time compression algorithm"
+)
- [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`. You can
- also install zstd in a custom path and pass
- `-DCMAKE_PREFIX_PATH=/some/custom/path` to `cmake`.
+ 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`.
To link libzstd statically (and you have a static libzstd available), pass
`-DSTATIC_LINK=ON` to `cmake`. This is the default on Windows. Alternatively,
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
linked statically as part of the build process. To disable this, pass
- `-DHIREDIS_FROM_INTERNET=OFF` to cmake. You can also install hiredis in a
- custom path and pass `-DCMAKE_PREFIX_PATH=/some/custom/path` to `cmake`.
+ `-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.