Commits

Anonymous committed 8f0fc3f

use system-cmake if available

Comments (0)

Files changed (2)

-148dfc8abc15af31968cdcda541978dde2bf1f58 waffle
+c49056662073a70352d58bce7190d5c50c973595 waffle

pkg/builders/cmake/wscript

 # @purpose: configuration of CMake
 
 import os
+import re
 
 import waflib.Logs as msg
 import waflib.Options
         'mandatory': True,
         }
 
+    cmake_min_version = (2,8,6)
+    ctx.env['BUNDLED_CMAKE'] = 0
+    try:
+        ctx.find_program(
+            'cmake',
+            var='CMAKE',
+            **common_cfg)
+        out = ctx.cmd_and_log(ctx.env['CMAKE'] + ' --version')
+        ver = re.search(r'\d+.\d+.\d+', out).group(0).split('.')
+        cmake_version = tuple([int(x) for x in ver])
+        cmake_version_str = '.'.join(ver)
+        ctx.msg('Checking for cmake version >= %r' % (cmake_min_version,),
+                cmake_version)
+        if cmake_version < cmake_min_version:
+            err = "cmake version %r is too old, need >= %r" % \
+                  (cmake_version, cmake_min_version)
+            msg.warn(err)
+            raise ctx.errors.ConfigurationError(err)
+
+        ctx.env['CMAKE_VERSION'] = cmake_version_str
+        return
+    except Exception:
+        ctx.env['BUNDLED_CMAKE'] = 1
+
     msg.warn('building cmake from sources...')
 
     ctx.env['EXT_BUNDLED_CMAKE_VERSION'] = '2.8.6'
 
 def build(ctx):
 
+    if ctx.env['BUNDLED_CMAKE'] == 0:
+        return
+
     root = subst_vars('${EXT_BUNDLED_CMAKE_PREFIX}', ctx.env)
     bindir = os.path.join(root, 'bin')
     bindir = ctx.root.find_dir(bindir)