Skip to content

Commit 674f565

Browse files
SwooshyCuebalanking
authored andcommitted
[#172] build hook: Use system CMake if newer
1 parent 72e49af commit 674f565

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

irods_consortium_continuous_integration_build_hook.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import multiprocessing
55
import optparse
66
import os
7+
import shutil
8+
import subprocess
79
import sys
810
import tempfile
911

@@ -14,13 +16,34 @@ def add_cmake_to_front_of_path():
1416
cmake_path = '/opt/irods-externals/cmake3.21.4-0/bin'
1517
os.environ['PATH'] = os.pathsep.join([cmake_path, os.environ['PATH']])
1618

19+
def is_system_cmake_newer_than_externals_cmake():
20+
cmake_exe = shutil.which('cmake')
21+
if cmake_exe is None:
22+
return False
23+
24+
try:
25+
cmake_ver_out = subprocess.check_output(['cmake', '--version']).decode('utf-8')
26+
cmake_ver_line = cmake_ver_out.splitlines()[0]
27+
cmake_ver_str = cmake_ver_line.split()[2]
28+
29+
from packaging import version
30+
cmake_sys_ver = version.parse(cmake_ver_str)
31+
cmake_ext_ver = version.parse('3.21.4')
32+
return cmake_sys_ver > cmake_ext_ver
33+
34+
except:
35+
return False
36+
1737
def install_building_dependencies(externals_directory):
1838

19-
externals_list = ['irods-externals-cmake3.21.4-0',
20-
'irods-externals-boost1.81.0-0',
39+
use_system_cmake = is_system_cmake_newer_than_externals_cmake()
40+
41+
externals_list = ['irods-externals-boost1.81.0-0',
2142
'irods-externals-clang-runtime13.0.0-0',
2243
'irods-externals-clang13.0.0-0',
2344
'irods-externals-json3.10.4-0']
45+
if not use_system_cmake:
46+
externals_list.append('irods-externals-cmake3.21.4-0')
2447
if externals_directory == 'None' or externals_directory is None:
2548
irods_python_ci_utilities.install_irods_core_dev_repository()
2649
irods_python_ci_utilities.install_os_packages(externals_list)
@@ -31,7 +54,8 @@ def install_building_dependencies(externals_directory):
3154
for irods_externals in externals_list:
3255
externals.append(glob.glob(os.path.join(os_specific_directory, irods_externals + '*.{0}'.format(package_suffix)))[0])
3356
irods_python_ci_utilities.install_os_packages_from_files(externals)
34-
add_cmake_to_front_of_path()
57+
if not use_system_cmake:
58+
add_cmake_to_front_of_path()
3559
install_os_specific_dependencies()
3660

3761
def install_os_specific_dependencies_apt():

0 commit comments

Comments
 (0)