apotocki/libsodium 1.0.22 (r1, windows)
- Library
- libsodium
- Variant
- windows, target windows
- Channel
- stable
- Published
- 2026-11-10
- Recipe source
- https://github.com/otok-dev/recipes.git
7387b6ee8dee98c91c576f3e39051559e5e83d83inrecipes/libsodium/1.0/windows/ - Recipe SHA-256
7fdf0c4aee349fa206d6c62d689a1c7573882a5ecb9701d26baebcd9a0400260
Recipe files changed
Inputs
| source.mirrors | ["https://github.com/jedisct1/libsodium/releases/download/1.0.22-RELEASE/libsodium-1.0.22.tar.gz"] |
|---|---|
| source.sha256 | adbdd8f16149e81ac6078a03aca6fc03b592b89ef7b5ed83841c086191be3349 |
| source.url | https://download.libsodium.org/libsodium/releases/libsodium-1.0.22.tar.gz |
Platforms
windows
Toolchains
cmake { default-recipe = "apotocki/cmake", version = ">= 3.20" }ninja { default-recipe = "apotocki/ninja", version = ">= 1.10" }
Recipe files
CMakeLists.txt
# libsodium for MSVC, as its Visual Studio projects (builds/msvc/vs2026/libsodium) build it: every C file of
# src/libsodium with the same definitions, the prebuilt builds/msvc/version.h and, for the DLL, its version resource.
# SODIUM_SOURCE is the root of libsodium's sources.
cmake_minimum_required(VERSION 3.20)
project(libsodium C)
set(src "${SODIUM_SOURCE}/src/libsodium")
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${src}/*.c")
list(SORT sources)
if(BUILD_SHARED_LIBS)
list(APPEND sources "${SODIUM_SOURCE}/builds/msvc/resource.rc")
endif()
add_library(libsodium ${sources})
# version.h first: the one of builds/msvc, written for this release, before version.h.in
target_include_directories(libsodium PRIVATE "${SODIUM_SOURCE}/builds/msvc" "${src}/include" "${src}/include/sodium")
target_compile_definitions(libsodium PRIVATE inline=__inline NATIVE_LITTLE_ENDIAN _CRT_SECURE_NO_WARNINGS
UNICODE _UNICODE $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,SODIUM_DLL_EXPORT,SODIUM_STATIC>)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM64|arm64|aarch64)$")
target_compile_definitions(libsodium PRIVATE ARM64)
else()
target_compile_definitions(libsodium PRIVATE x64)
endif()
target_link_libraries(libsodium PRIVATE advapi32)
include(GNUInstallDirs)
install(TARGETS libsodium RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(FILES "${src}/include/sodium.h" DESTINATION include)
install(DIRECTORY "${src}/include/sodium/" DESTINATION include/sodium
FILES_MATCHING PATTERN "*.h" PATTERN "private" EXCLUDE)
install(FILES "${SODIUM_SOURCE}/builds/msvc/version.h" DESTINATION include/sodium)
build.lua
-- libsodium's sources with the recipe's CMakeLists.txt, which builds them as builds/msvc/vs2026/libsodium does. What it
-- installs: libsodium.lib, or libsodium.lib with libsodium.dll.
function build(slice, options, deps)
local static = slice.linkage == "static"
otok.copy(slice.recipe .. "/CMakeLists.txt", slice.source .. "/otok/CMakeLists.txt")
otok.cmake{ source = slice.source .. "/otok", defines = { SODIUM_SOURCE = slice.source } }
local p = slice.prefix
if static then
-- consumers of the static library define nothing: its export.h says so itself, as libsodium's own static
-- builds for MSVC ask SODIUM_STATIC of them
local header = p .. "/include/sodium/export.h"
local text, n = otok.read(header):gsub("#ifdef SODIUM_STATIC\n", "#if 1 /* static, SODIUM_STATIC */\n")
assert(n == 1, "export.h has no '#ifdef SODIUM_STATIC'")
otok.write(header, text)
return { libraries = { sodium = p .. "/lib/libsodium.lib" }, headers = p .. "/include" }
end
return { libraries = { sodium = { link = p .. "/lib/libsodium.lib", runtime = p .. "/bin/libsodium.dll" } },
headers = p .. "/include" }
end
recipe.toml
# The otok recipe of libsodium (https://github.com/apotocki/otok): libsodium for Windows, from the release archive,
# built with MSVC by the recipe's CMakeLists.txt as libsodium's own Visual Studio projects build it; static or dynamic.
[recipe]
api = 1
library = "libsodium"
name = "libsodium"
version = "1.0.22"
revision = 1
license = "ISC"
license-files = ["LICENSE"]
homepage = "https://libsodium.org"
documentation = "https://doc.libsodium.org"
description = "Sodium, a modern, easy-to-use library for encryption, decryption, signatures, password hashing and more."
keywords = ["crypto", "cryptography", "encryption", "signatures", "nacl"]
linkage = ["static", "dynamic"]
# The archive of the release, signed with minisign by libsodium's key RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3
# (libsodium-1.0.22.tar.gz.minisig); the same file is an asset of the release on GitHub.
[source]
url = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.22.tar.gz"
sha256 = "adbdd8f16149e81ac6078a03aca6fc03b592b89ef7b5ed83841c086191be3349"
mirrors = ["https://github.com/jedisct1/libsodium/releases/download/1.0.22-RELEASE/libsodium-1.0.22.tar.gz"]
[platforms]
supported = ["windows"]
build-on = ["windows/msvc"]
[toolchains]
cmake = { version = ">= 3.20", default-recipe = "apotocki/cmake" }
ninja = { version = ">= 1.10", default-recipe = "apotocki/ninja" }
[[product]]
name = "Sodium"
libraries = ["sodium"]
link = { libraries = ["advapi32"] }