Skip to content

Commit 9bb88cc

Browse files
committed
tolerate older cmake versions
1 parent d145f45 commit 9bb88cc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cmakeutils/cmake_compile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def job_count() -> int:
108108
def cmake_build(src_root: Path, prefix: Path):
109109

110110
build_root = src_root / "build"
111+
build_root.mkdir(parents=True, exist_ok=True)
111112

112113
opts = [
113114
"-DCMAKE_BUILD_TYPE=Release",
@@ -118,9 +119,9 @@ def cmake_build(src_root: Path, prefix: Path):
118119
if os.environ.get("CMAKE_GENERATOR") and os.environ["CMAKE_GENERATOR"] == "Ninja":
119120
opts.append("-GNinja")
120121

121-
cmd = ["cmake", "-S", str(src_root), "-B", str(build_root)] + opts
122+
cmd = ["cmake", str(src_root)] + opts
122123
print(" ".join(cmd))
123-
subprocess.check_call(cmd)
124+
subprocess.check_call(cmd, cwd=build_root)
124125

125126
popts = ["--parallel"]
126127
Njobs = job_count()
@@ -132,7 +133,7 @@ def cmake_build(src_root: Path, prefix: Path):
132133

133134
if prefix:
134135
print("installing cmake:", prefix)
135-
cmd = ["cmake", "--install", str(build_root)]
136+
cmd = ["cmake", "--build", str(build_root), "--target", "install"]
136137
print(" ".join(cmd))
137138
subprocess.check_call(cmd)
138139

0 commit comments

Comments
 (0)