Find CiviCRM version programmatically?
I'd use System.get API call. (source)

In the return values, there's a value for version which corresponds to the value in civicrm-version.php

$ cv api System.get name=version
{
    "is_error": 0,
    "version": 3,
    "count": 1,
    "id": 0,
    "values": [
        {
            "version": "4.6.20.0",
            "uf": "Drupal",
            "php": {
            // lots more info ...


Only worry about this might be how heavy that API call is - since I see data there from OS etc, it might not be suitable for calling frequently if rebuilding the data each time. There seems to be a bit of overhead to this API call (~0.07s per call in a randomly picked test environment), so for frequent use you'd want something lighter.