write_pkg_config.cmake 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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. # First, retrieve the current version from CHANGES
  15. file(STRINGS ${CHANGES_FILE} CHANGES_CONTENT)
  16. string(
  17. REGEX
  18. MATCH "v[0-9]+(.[0-9]+)?(-dev)? [0-9]+-[0-9]+-[0-9]+"
  19. FIRST_VERSION_LINE
  20. ${CHANGES_CONTENT})
  21. string(
  22. REGEX
  23. REPLACE "^v([^ ]+) .+$" "\\1"
  24. CURRENT_VERSION
  25. "${FIRST_VERSION_LINE}")
  26. # If this is a development version, replace "-dev" by ".0" as pkg-config nor
  27. # CMake support "-dev" in the version.
  28. # If it's not a "-dev" version then ensure it ends with ".1"
  29. string(REGEX REPLACE "-dev.1" ".0" CURRENT_VERSION "${CURRENT_VERSION}.1")
  30. configure_file(${TEMPLATE_FILE} ${OUT_FILE} @ONLY)