myx-cmake/MyxCMake/modules/MyxCMakeProjectVersion.cmake

18 lines
592 B
CMake
Raw Normal View History

2022-05-06 09:49:46 +00:00
include_guard(GLOBAL)
2021-12-08 11:32:04 +00:00
function(myx_cmake_check_project_version)
if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)")
2021-12-21 10:45:09 +00:00
myx_cmake_message_error("MyxCMake: Please set project version in X.Y.Z format")
2021-12-08 11:32:04 +00:00
endif()
endfunction()
function(myx_cmake_set_project_version_int)
2021-12-21 10:45:09 +00:00
# cmake-format: off
2021-12-08 11:32:04 +00:00
myx_cmake_check_project_version()
2021-12-21 10:45:09 +00:00
math(EXPR _version_int "(${PROJECT_VERSION_MAJOR} << 16) + (${PROJECT_VERSION_MINOR} << 8) + ${PROJECT_VERSION_PATCH}")
2021-12-08 11:32:04 +00:00
set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${_version_int})
2021-12-21 10:45:09 +00:00
# cmake-format: on
2021-12-08 11:32:04 +00:00
endfunction()
myx_cmake_set_project_version_int()