Skip to content

Commit e5eb6a5

Browse files
committed
Adding the vcpkg integration files
Signed-off-by: Matthew A Johnson <matjoh@microsoft.com>
1 parent c2f0d1c commit e5eb6a5

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

ports/snmalloc/portfile.cmake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Without static-shim: INTERFACE only — Release and Debug are identical.
2+
# With static-shim: compiled code is produced — both variants are needed.
3+
if(NOT "static-shim" IN_LIST FEATURES)
4+
set(VCPKG_BUILD_TYPE release)
5+
endif()
6+
7+
vcpkg_from_github(
8+
OUT_SOURCE_PATH SOURCE_PATH
9+
REPO microsoft/snmalloc
10+
REF "v${VERSION}"
11+
SHA512 0 # Placeholder: compute the real SHA512 from the GitHub release tarball before publishing to the vcpkg registry.
12+
HEAD_REF main
13+
)
14+
15+
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
16+
FEATURES
17+
"static-shim" SNMALLOC_STATIC_LIBRARY
18+
INVERTED_FEATURES
19+
"static-shim" SNMALLOC_HEADER_ONLY_LIBRARY
20+
)
21+
22+
vcpkg_cmake_configure(
23+
SOURCE_PATH "${SOURCE_PATH}"
24+
OPTIONS
25+
-DSNMALLOC_BUILD_TESTING=OFF
26+
${FEATURE_OPTIONS}
27+
)
28+
29+
vcpkg_cmake_install()
30+
31+
vcpkg_cmake_config_fixup(
32+
PACKAGE_NAME snmalloc
33+
CONFIG_PATH share/snmalloc
34+
)
35+
36+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
37+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
38+
39+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
40+
41+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage"
42+
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

ports/snmalloc/usage

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
snmalloc provides CMake integration via:
2+
3+
find_package(snmalloc CONFIG REQUIRED)
4+
target_link_libraries(<your-target> PRIVATE snmalloc::snmalloc)
5+
6+
If installed with the "static-shim" feature, a compiled static library is also
7+
available that replaces malloc/free with a "sn_" prefix (e.g. sn_malloc, sn_free):
8+
9+
target_link_libraries(<your-target> PRIVATE snmalloc::snmallocshim-static)
10+
11+
On non-Windows, the "static-shim" feature also installs shared library shims
12+
(snmalloc::snmallocshim, snmalloc::snmallocshim-checks, snmalloc::snmalloc-minimal)
13+
that can be used for LD_PRELOAD-based allocator replacement.

ports/snmalloc/vcpkg.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "snmalloc",
3+
"version-semver": "0.7.4",
4+
"description": "A high-performance, message passing based allocator",
5+
"homepage": "https://github.com/microsoft/snmalloc",
6+
"license": "MIT",
7+
"features": {
8+
"static-shim": {
9+
"description": "Build and install snmallocshim-static, a compiled static library that exports malloc/free with a configurable symbol prefix (default: sn_)"
10+
}
11+
}
12+
}

vcpkg.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "snmalloc",
3+
"version-semver": "0.7.4",
4+
"description": "A high-performance, message passing based allocator",
5+
"homepage": "https://github.com/microsoft/snmalloc",
6+
"license": "MIT",
7+
"features": {
8+
"static-shim": {
9+
"description": "Build and install snmallocshim-static, a compiled static library that exports malloc/free with a configurable symbol prefix (default: sn_)"
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)