Skip to content

Commit

Permalink
Add CMake package
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewlacy committed Nov 23, 2024
1 parent 2bf7bcc commit ee1a5b6
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/cmake/brioche.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions packages/cmake/project.bri
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import * as std from "std";
import openssl from "openssl";
import curl from "curl";

export const project = {
name: "cmake",
version: "3.31.0",
};

const source = (() => {
let source = Brioche.download(
`https://github.com/Kitware/CMake/releases/download/v${project.version}/cmake-${project.version}.tar.gz`,
)
.unarchive("tar", "gzip")
.peel();

source = std
.process({
command: "patch",
args: [
"-p1",
"-i",
Brioche.includeFile("testbigendian-brioche.patch"),
"-d",
std.outputPath,
],
outputScaffold: source,
dependencies: [std.tools()],
})
.toDirectory();

return source;
})();

export default function (): std.Recipe<std.Directory> {
let cmake = std.runBash`
./bootstrap \\
--prefix=/ \\
--system-curl \\
--parallel=16 \\
-- \\
--trace-expand
make
make install DESTDIR="$BRIOCHE_OUTPUT"
`
.workDir(source)
.dependencies(std.toolchain(), openssl(), curl())
.env({
OPENSSL_ROOT_DIR: openssl(),
ZLIB_ROOT: std.toolchain(),
CURL_ROOT: curl(),
})
.toDirectory();

cmake = std.setEnv(cmake, {
CPATH: { append: [{ path: "include" }] },
LIBRARY_PATH: { append: [{ path: "lib" }] },
PKG_CONFIG_PATH: { append: [{ path: "lib/pkgconfig" }] },
});

return std.withRunnableLink(cmake, "bin/cmake");
}
26 changes: 26 additions & 0 deletions packages/cmake/testbigendian-brioche.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake
index 03c8588fb7..c2de891665 100644
--- a/Modules/TestBigEndian.cmake
+++ b/Modules/TestBigEndian.cmake
@@ -85,10 +85,21 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE)
file(READ "${CMAKE_ROOT}/Modules/TestEndianess.c.in" TEST_ENDIANESS_FILE_CONTENT)
string(CONFIGURE "${TEST_ENDIANESS_FILE_CONTENT}" TEST_ENDIANESS_FILE_CONTENT @ONLY)

+ # (Patched) Disable Brioche autopack so endianness check works
+ if(DEFINED ENV{BRIOCHE_LD_AUTOPACK})
+ set(old_brioche_ld_autopack $ENV{BRIOCHE_LD_AUTOPACK})
+ endif()
+ set(ENV{BRIOCHE_LD_AUTOPACK} "false")
+
try_compile(HAVE_${VARIABLE}
SOURCE_FROM_VAR "${_test_file}" TEST_ENDIANESS_FILE_CONTENT
COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" )

+ if(DEFINED old_brioche_ld_autopack)
+ set(ENV{BRIOCHE_LD_AUTOPACK} ${old_brioche_ld_autopack})
+ endif()
+ unset(old_brioche_ld_autopack)
+
if(HAVE_${VARIABLE})

cmake_policy(PUSH)

0 comments on commit ee1a5b6

Please sign in to comment.