Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / cmake / version.cmake
1 #===============================================================================
2 # Copyright 2019 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #===============================================================================
16
17 # Control generating version file
18 #===============================================================================
19
20 if(version_cmake_included)
21     return()
22 endif()
23 set(version_cmake_included true)
24
25 string(REPLACE "." ";" VERSION_LIST ${PROJECT_VERSION})
26 list(GET VERSION_LIST 0 MKLDNN_VERSION_MAJOR)
27 list(GET VERSION_LIST 1 MKLDNN_VERSION_MINOR)
28 list(GET VERSION_LIST 2 MKLDNN_VERSION_PATCH)
29
30 find_package(Git)
31 if (GIT_FOUND)
32     execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
33         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
34         RESULT_VARIABLE RESULT
35         OUTPUT_VARIABLE MKLDNN_VERSION_HASH
36         OUTPUT_STRIP_TRAILING_WHITESPACE)
37 endif()
38
39 if(NOT GIT_FOUND OR RESULT)
40     set(MKLDNN_VERSION_HASH "N/A")
41 endif()
42
43 configure_file(
44     "${PROJECT_SOURCE_DIR}/include/mkldnn_version.h.in"
45     "${PROJECT_BINARY_DIR}/include/mkldnn_version.h"
46 )