Skip to content

Commit 78d3474

Browse files
committed
adding cmake check
1 parent 4f1fe25 commit 78d3474

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lisa/tools/lagscope.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,25 @@ def _install(self) -> bool:
404404
code_path = tool_path.joinpath("lagscope")
405405

406406
src_path = code_path.joinpath("src")
407-
# Read the CMakeLists.txt file and update the version requirement
407+
408+
# Get the installed CMake version dynamically
409+
cmake_version_result = self.node.execute(
410+
"cmake --version | head -n1 | grep -oP '\\d+\\.\\d+'",
411+
shell=True,
412+
)
413+
414+
if cmake_version_result.exit_code == 0 and cmake_version_result.stdout.strip():
415+
cmake_version = cmake_version_result.stdout.strip()
416+
self._log.debug(f"Detected CMake version: {cmake_version}")
417+
else:
418+
# Fallback to a safe minimum version if detection fails
419+
cmake_version = "3.5"
420+
self._log.warning(f"Could not detect CMake version, using fallback: {cmake_version}")
421+
422+
# Update CMakeLists.txt with the detected version
408423
self.node.execute(
409424
f"sed -i 's/cmake_minimum_required(VERSION [0-9.]\\+)/"
410-
f"cmake_minimum_required(VERSION 3.5)/' "
425+
f"cmake_minimum_required(VERSION {cmake_version})/' "
411426
f"{src_path}/CMakeLists.txt",
412427
cwd=code_path,
413428
sudo=True,

0 commit comments

Comments
 (0)