blob: 3ccbbfc9467013838a7b2c6c58752b62a73deb58 [file]
#!/usr/bin/env cmake -P
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.4)
execute_process(COMMAND @GIT_EXECUTABLE@ rev-parse HEAD
WORKING_DIRECTORY @CMAKE_SOURCE_DIR@
OUTPUT_VARIABLE REV_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND @GIT_EXECUTABLE@ show -s --format=%cD
WORKING_DIRECTORY @CMAKE_SOURCE_DIR@
OUTPUT_VARIABLE REV_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if ("@GIT_VERSION_STRING@" VERSION_LESS 1.8)
set(GIT_BRANCH_COMMAND @GIT_EXECUTABLE@ rev-parse --abbrev-ref HEAD)
else()
set(GIT_BRANCH_COMMAND @GIT_EXECUTABLE@ symbolic-ref --short HEAD)
endif()
execute_process(COMMAND ${GIT_BRANCH_COMMAND}
WORKING_DIRECTORY @CMAKE_SOURCE_DIR@
OUTPUT_VARIABLE REV_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
#message(STATUS "REV_COUNT: ${REV_COUNT}")
#message(STATUS "REV_SHA: ${REV_SHA}")
#message(STATUS "REV_DATE: ${REV_DATE}")
#message(STATUS "REV_BRANCH: ${REV_BRANCH}")
set(PRODUCT_VERSION @PRODUCT_VERSION@)
set(PRODUCT_VERSION_RC @PRODUCT_VERSION_RC@)
set(PRODUCT_BUILDDATE ${REV_DATE})
set(PRODUCT_SOURCE_REVISION ${REV_SHA})
set(PRODUCT_SOURCE_REPOSITORY ${REV_BRANCH})
configure_file(@CMAKE_CURRENT_SOURCE_DIR@/src/version.h.in @CMAKE_CURRENT_BINARY_DIR@/version.h)
# Always touch since configure_file will not update file if values haven't change
# but the index must have changed for this command to be called. If we don't touch
# then we keep getting called because the index is newer than version.h
execute_process(COMMAND ${CMAKE_COMMAND} -E touch_nocreate @CMAKE_CURRENT_BINARY_DIR@/version.h)