myx-cmake/MyxCMake/modules/MyxCMakeProjectVersion.cmake

18 lines
538 B
CMake

function(myx_cmake_check_project_version)
if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)")
message(FATAL_ERROR "MyxCMake: Please set project version in X.Y.Z format")
endif()
endfunction()
function(myx_cmake_set_project_version_int)
myx_cmake_check_project_version()
math(
EXPR
_version_int
"(${PROJECT_VERSION_MAJOR} << 16) + (${PROJECT_VERSION_MINOR} << 8) + ${PROJECT_VERSION_PATCH}"
)
set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${_version_int})
endfunction()
myx_cmake_set_project_version_int()