Make better use of simplification pass
[platform/upstream/SPIRV-Tools.git] / cmake / write_pkg_config.cmake
1 # Copyright (c) 2017 Pierre Moreau
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # First, retrieve the current version from CHANGES
16 file(STRINGS ${CHANGES_FILE} CHANGES_CONTENT)
17 string(
18 REGEX
19   MATCH "v[0-9]+(.[0-9]+)?(-dev)? [0-9]+-[0-9]+-[0-9]+"
20   FIRST_VERSION_LINE
21   ${CHANGES_CONTENT})
22 string(
23 REGEX
24   REPLACE "^v([^ ]+) .+$" "\\1"
25   CURRENT_VERSION
26   "${FIRST_VERSION_LINE}")
27 # If this is a development version, replace "-dev" by ".0" as pkg-config nor
28 # CMake support "-dev" in the version.
29 # If it's not a "-dev" version then ensure it ends with ".1"
30 string(REGEX REPLACE "-dev.1" ".0" CURRENT_VERSION "${CURRENT_VERSION}.1")
31 configure_file(${TEMPLATE_FILE} ${OUT_FILE} @ONLY)