Improve build: parse out the version

This commit is contained in:
Ryan Pavlik
2010-11-11 13:17:44 -06:00
parent cc4e9e9fd6
commit 394ade9cf0
2 changed files with 51 additions and 4 deletions

28
ParseVersion.cmake Normal file
View File

@@ -0,0 +1,28 @@
set(_version_file "${CMAKE_CURRENT_SOURCE_DIR}/src/wiiuse.h")
if(EXISTS "${_version_file}")
file(READ "${_version_file}" _version_contents)
endif()
if("${_version_contents}" MATCHES "WIIUSE_MAJOR ([0-9]+)")
set(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
set(CPACK_PACKAGE_VERSION_MAJOR "0")
message("Could not parse major version from wiiuse.h")
endif()
if("${_version_contents}" MATCHES "WIIUSE_MINOR ([0-9]+)")
set(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_MATCH_1}")
else()
set(CPACK_PACKAGE_VERSION_MINOR "13")
message("Could not parse minor version from wiiuse.h")
endif()
if("${_version_contents}" MATCHES "WIIUSE_MICRO ([0-9]+)")
set(CPACK_PACKAGE_VERSION_MICRO "${CMAKE_MATCH_1}")
else()
set(CPACK_PACKAGE_VERSION_MICRO "0")
message("Could not parse micro version from wiiuse.h")
endif()
set(CPACK_PACKAGE_VERSION
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_MICRO}")