1# 2# Copyright (c) 2017, Alliance for Open Media. All rights reserved. 3# 4# This source code is subject to the terms of the BSD 2 Clause License and the 5# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was 6# not distributed with this source code in the LICENSE file, you can obtain it 7# at www.aomedia.org/license/software. If the Alliance for Open Media Patent 8# License 1.0 was not distributed with this source code in the PATENTS file, you 9# can obtain it at www.aomedia.org/license/patent. 10# 11cmake_minimum_required(VERSION 3.5) 12 13set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "GIT_EXECUTABLE" 14 "PERL_EXECUTABLE") 15 16foreach(arg ${REQUIRED_ARGS}) 17 if("${${arg}}" STREQUAL "") 18 message(FATAL_ERROR "${arg} must not be empty.") 19 endif() 20endforeach() 21 22include("${AOM_ROOT}/build/cmake/util.cmake") 23 24# Generate the version string for this run. 25unset(aom_version) 26if(EXISTS "${GIT_EXECUTABLE}") 27 execute_process(COMMAND ${GIT_EXECUTABLE} 28 --git-dir=${AOM_ROOT}/.git describe 29 --match=v[0-9]* 30 OUTPUT_VARIABLE aom_version 31 ERROR_QUIET 32 RESULT_VARIABLE version_check_result) 33 34 if(${version_check_result} EQUAL 0) 35 string(STRIP "${aom_version}" aom_version) 36 37 # Remove the leading 'v' from the version string. 38 string(FIND "${aom_version}" "v" v_pos) 39 if(${v_pos} EQUAL 0) 40 string(SUBSTRING "${aom_version}" 1 -1 aom_version) 41 endif() 42 else() 43 set(aom_version "") 44 endif() 45endif() 46 47if("${aom_version}" STREQUAL "") 48 set(aom_version "${AOM_ROOT}/CHANGELOG") 49endif() 50 51unset(last_aom_version) 52set(version_file "${AOM_CONFIG_DIR}/config/aom_version.h") 53if(EXISTS "${version_file}") 54 extract_version_string("${version_file}" last_aom_version) 55 if("${aom_version}" MATCHES "CHANGELOG$") 56 set(aom_version "${last_aom_version}") 57 endif() 58endif() 59 60if(NOT "${aom_version}" STREQUAL "${last_aom_version}") 61 # TODO(tomfinegan): Perl dependency is unnecessary. CMake can do everything 62 # that is done by version.pl on its own (if a bit more verbosely...). 63 execute_process(COMMAND ${PERL_EXECUTABLE} 64 "${AOM_ROOT}/build/cmake/version.pl" 65 --version_data=${aom_version} 66 --version_filename=${version_file} VERBATIM) 67endif() 68