You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SetProjectVersion.cmake 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. function(SET_PROJECT_VERSION)
  2. find_file(OVSDK_DOTINSTALL NAMES .install PATHS ${OPENVIBE_SDK_PATH} NO_DEFAULT_PATH)
  3. if(CMAKE_BUILD_TYPE)
  4. string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
  5. find_file(OVSDK_DOTINSTALL NAMES .install PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES openvibe-sdk-${CMAKE_BUILD_TYPE_LOWER} NO_DEFAULT_PATH)
  6. else()
  7. find_file(OVSDK_DOTINSTALL NAMES .install PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES openvibe-sdk-release openvibe-sdk-debug NO_DEFAULT_PATH)
  8. endif()
  9. file(STRINGS ${OVSDK_DOTINSTALL} ov_sdk_install_manifest)
  10. foreach(NameAndValue ${ov_sdk_install_manifest})
  11. string(STRIP NameAndValue ${NameAndValue})
  12. string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
  13. string(REPLACE "${Name}=" "" Value ${NameAndValue})
  14. if(${Name} STREQUAL "[Version]")
  15. set(OV_SDK_VERSION_STRING "${Value}" PARENT_SCOPE)
  16. endif()
  17. endforeach()
  18. set(OV_GLOBAL_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} PARENT_SCOPE)
  19. set(OV_GLOBAL_VERSION_MINOR ${PROJECT_VERSION_MINOR} PARENT_SCOPE)
  20. set(OV_GLOBAL_VERSION_PATCH ${PROJECT_VERSION_PATCH} PARENT_SCOPE)
  21. set(OV_GLOBAL_VERSION_BUILD ${PROJECT_VERSION_BUILD} PARENT_SCOPE)
  22. set(OV_GLOBAL_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_BUILD}" PARENT_SCOPE)
  23. set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} PARENT_SCOPE)
  24. set(OV_PROJECT_BRANCH ${PROJECT_BRANCH} PARENT_SCOPE)
  25. set(OV_PROJECT_COMMITHASH ${PROJECT_COMMITHASH} PARENT_SCOPE)
  26. # Write version to .install file
  27. string(TIMESTAMP BUILD_DATE "%d/%m/%y %H:%M:%S")
  28. set(INSTALL_MANIFEST_STR "[Package]=${PROJECT_NAME}\
  29. \n[Version]=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_BUILD}\
  30. \n[BuildHash]=${PROJECT_COMMITHASH}\
  31. \n[BuildBranch]=${PROJECT_BRANCH}\
  32. \n[BuildDate]=${BUILD_DATE}"
  33. )
  34. file(WRITE ${CMAKE_BINARY_DIR}/.install "${INSTALL_MANIFEST_STR}")
  35. endfunction(SET_PROJECT_VERSION)