BuildVersion.cmake 1.2 KB

1234567891011121314151617181920212223242526272829
  1. # -*- cmake -*-
  2. if (BUILDVERSION_CMAKE_INCLUDED)
  3. return()
  4. endif (BUILDVERSION_CMAKE_INCLUDED)
  5. set (BUILDVERSION_CMAKE_INCLUDED TRUE)
  6. function (build_version _target)
  7. # Read version components from the header file.
  8. file(STRINGS ${CMAKE_SOURCE_DIR}/llcommon/llversion${_target}.h lines
  9. REGEX " LL_VERSION_")
  10. foreach(line ${lines})
  11. string(REGEX REPLACE ".*LL_VERSION_([A-Z]+).*" "\\1" comp "${line}")
  12. string(REGEX REPLACE ".* = ([0-9]+);.*" "\\1" value "${line}")
  13. set(v${comp} "${value}")
  14. endforeach(line)
  15. # Compose the version.
  16. set(${_target}_VER "${vMAJOR}.${vMINOR}.${vBRANCH}.${vRELEASE}")
  17. if (${_target}_VER MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
  18. message(STATUS "========================================")
  19. message(STATUS "Version of ${_target} is ${${_target}_VER}")
  20. message(STATUS "========================================")
  21. else (${_target}_VER MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
  22. message(FATAL_ERROR "Could not determine ${_target} version (${${_target}_VER})")
  23. endif (${_target}_VER MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
  24. # Report version to caller.
  25. set(${_target}_VER "${${_target}_VER}" PARENT_SCOPE)
  26. endfunction (build_version)