Version String Manipulation
Splitting Version Strings
macro(breakdown_version_string version major minor patch) if(${version} MATCHES ${THREE_PART_VERSION_REGEX}) string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" ${major} "${version}") string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" ${minor} "${version}") string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" ${patch} "${version}") else(${version} MATCHES ${THREE_PART_VERSION_REGEX}) message("macro(breakdown_version_string ${version} ${major} ${minor} ${patch}") message(FATAL_ERROR "Problem parsing version string, I can't parse it properly.") endif(${version} MATCHES ${THREE_PART_VERSION_REGEX}) endmacro(breakdown_version_string) # example usage breakdown_version_string(${${PROJECT_NAME}_VERSION} CPACK_PACKAGE_VERSION_MAJOR CPACK_PACKAGE_VERSION_MINOR CPACK_PACKAGE_VERSION_PATCH)