Skip to content

Commit

Permalink
cmake changes
Browse files Browse the repository at this point in the history
  • Loading branch information
deciduously committed Jan 3, 2025
1 parent 6124122 commit 8cdea10
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake
index 03c8588f..6f8f7213 100644
--- a/Modules/TestBigEndian.cmake
+++ b/Modules/TestBigEndian.cmake
@@ -85,9 +85,11 @@ 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)

+ set(ENV{TANGRAM_LINKER_PASSTHROUGH} "TRUE")
try_compile(HAVE_${VARIABLE}
SOURCE_FROM_VAR "${_test_file}" TEST_ENDIANESS_FILE_CONTENT
COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" )
+ unset(ENV{TANGRAM_LINKER_PASSTHROUGH})

if(HAVE_${VARIABLE})

49 changes: 36 additions & 13 deletions packages/cmake/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import * as libpsl from "libpsl" with { path: "../libpsl" };
import * as make from "gnumake" with { path: "../gnumake" };
import * as ncurses from "ncurses" with { path: "../ncurses" };
import * as pkgConf from "pkgconf" with { path: "../pkgconf" };
import * as pkgConfig from "pkg-config" with { path: "../pkgconf" };
import * as openssl from "openssl" with { path: "../openssl" };
import * as zlib from "zlib" with { path: "../zlib" };
import * as zstd from "zstd" with { path: "../zstd" };

import patches from "./patches" with { type: "directory" };

import * as ninja from "./ninja.tg.ts";
export * as ninja from "./ninja.tg.ts";

Expand All @@ -26,14 +29,16 @@ export const source = tg.target(() => {
const owner = "Kitware";
const repo = "CMake";
const tag = `v${version}`;
return std.download.fromGithub({
checksum,
owner,
repo,
source: "release",
tag,
version,
});
return std.download
.fromGithub({
checksum,
owner,
repo,
source: "release",
tag,
version,
})
.then((source) => std.patch(source, patches));
});

export type Arg = {
Expand All @@ -44,7 +49,6 @@ export type Arg = {
libpsl?: libpsl.Arg;
ncurses?: ncurses.Arg;
openssl?: openssl.Arg;
pkgconf?: pkgConf.Arg;
zlib?: zlib.Arg;
zstd?: zstd.Arg;
};
Expand All @@ -63,7 +67,6 @@ export const cmake = tg.target(async (...args: std.Args<Arg>) => {
libpsl: libpslArg = {},
ncurses: ncursesArg = {},
openssl: opensslArg = {},
pkgconf: pkgconfArg = {},
zlib: zlibArg = {},
zstd: zstdArg = {},
} = {},
Expand All @@ -73,6 +76,7 @@ export const cmake = tg.target(async (...args: std.Args<Arg>) => {
source: source_,
} = await std.args.apply<Arg>(...args);
const sourceDir = source_ ?? source();
const os = std.triple.os(host);

const curlRoot = curl.default_({ build, env: env_, host, sdk }, curlArg);
const ncursesRoot = ncurses.default_(
Expand All @@ -95,20 +99,38 @@ export const cmake = tg.target(async (...args: std.Args<Arg>) => {
args: [
"--parallel=$(nproc)",
"--system-curl",
"--",
// "-DCMAKE_VERBOSE_MAKEFILE=ON",
// "-DFindZLIB_DEBUG=ON"
// tg`-DZLIB_ROOT=${zlibRoot}`
// "--debug-find",
// "--debug-output",
// "--trace-expand",
`-DCMAKE_LIBRARY_PATH="$(echo $LIBRARY_PATH | tr ':' ';')"`,
`-DCMAKE_INCLUDE_PATH="$(echo $CPATH | tr ':' ';')"`,
`-DCMAKE_VERBOSE_MAKEFILE=ON`,
],
};
const phases = { configure };

let pkgConfigRoot;
if (os === "linux") {
pkgConfigRoot = pkgConfig.default_({ build, host: build });
} else {
pkgConfigRoot = pkgConf.default_({ build, host: build });
}

const deps = [
curlRoot,
pkgConf.default_({ build, host: build }, pkgconfArg),
pkgConfigRoot,
ncursesRoot,
libpslRoot,
opensslRoot,
zlibRoot,
zstdRoot,
];
const env = [...deps, env_];
if (std.triple.os(host) === "darwin") {
if (os === "darwin") {
// On macOS, the bootstrap script wants to test for `ext/stdio_filebuf.h`, which is not part of the macOS toolchain.
// Using the `gcc` and `g++` named symlinks to the AppleClang compiler instead of `clang`/`clang++` prevents this.
env.push({
Expand All @@ -120,7 +142,8 @@ export const cmake = tg.target(async (...args: std.Args<Arg>) => {
const result = std.autotools.build({
...(await std.triple.rotate({ build, host })),
env: std.env.arg(...env),
phases: { configure },
phases,
setRuntimeLibraryPath: os === "linux",
sdk,
source: sourceDir,
});
Expand Down

0 comments on commit 8cdea10

Please sign in to comment.