mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-11 06:15:56 +03:00
Switch to manual project versioning
This commit is contained in:
parent
d12077ccc1
commit
7aaa3ba985
@ -9,14 +9,13 @@ project(marian CXX)
|
||||
option(COMPILE_EXAMPLES "Compile examples" OFF)
|
||||
option(COMPILE_TESTS "Compile tests" OFF)
|
||||
option(USE_CUDNN "Use CUDNN library" OFF)
|
||||
option(VERSION_UPDATE_FROM_GIT "Update project version from git" OFF)
|
||||
|
||||
# Project versioning
|
||||
find_package(Git QUIET)
|
||||
include(GetVersionFromGitTag)
|
||||
include(GetVersionFromFile)
|
||||
|
||||
message(STATUS "Project name: ${PROJECT_NAME}")
|
||||
message(STATUS "Project version: ${marian_VERSION}")
|
||||
message(STATUS "Project version: ${PROJECT_VERSION_STRING}")
|
||||
|
||||
|
||||
# Set compilation flags
|
||||
@ -28,7 +27,7 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
# Find packages
|
||||
find_package(CUDA "8.0" REQUIRED)
|
||||
if(CUDA_FOUND)
|
||||
set(EXT_LIBS ${EXT_LIBS} ${CUDA_curand_LIBRARY} ${CUDA_cusparse_LIBRARY})
|
||||
set(EXT_LIBS ${EXT_LIBS} ${CUDA_curand_LIBRARY} ${CUDA_cusparse_LIBRARY})
|
||||
endif(CUDA_FOUND)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
@ -41,33 +40,33 @@ list(REMOVE_DUPLICATES CUDA_NVCC_FLAGS)
|
||||
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
|
||||
|
||||
if(USE_CUDNN)
|
||||
find_package(CUDNN "5.0")
|
||||
if(CUDNN_FOUND)
|
||||
include_directories(${CUDNN_INCLUDE_DIRS})
|
||||
set(EXT_LIBS ${EXT_LIBS} ${CUDNN_LIBRARIES})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDNN")
|
||||
LIST(APPEND CUDA_NVCC_FLAGS -DCUDNN; )
|
||||
endif(CUDNN_FOUND)
|
||||
find_package(CUDNN "5.0")
|
||||
if(CUDNN_FOUND)
|
||||
include_directories(${CUDNN_INCLUDE_DIRS})
|
||||
set(EXT_LIBS ${EXT_LIBS} ${CUDNN_LIBRARIES})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDNN")
|
||||
LIST(APPEND CUDA_NVCC_FLAGS -DCUDNN; )
|
||||
endif(CUDNN_FOUND)
|
||||
endif(USE_CUDNN)
|
||||
|
||||
find_package(ZLIB)
|
||||
if(ZLIB_FOUND)
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
set(EXT_LIBS ${EXT_LIBS} ${ZLIB_LIBRARIES})
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
set(EXT_LIBS ${EXT_LIBS} ${ZLIB_LIBRARIES})
|
||||
else(ZLIB_FOUND)
|
||||
message(SEND_ERROR "Cannot find zlib" )
|
||||
message(SEND_ERROR "Cannot find zlib" )
|
||||
endif(ZLIB_FOUND)
|
||||
|
||||
find_package(Boost COMPONENTS system timer iostreams filesystem chrono program_options thread)
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
set(EXT_LIBS ${EXT_LIBS} ${Boost_LIBRARIES})
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
set(EXT_LIBS ${EXT_LIBS} ${Boost_LIBRARIES})
|
||||
else(Boost_FOUND)
|
||||
message(SEND_ERROR "Cannot find Boost libraries. Terminating." )
|
||||
message(SEND_ERROR "Cannot find Boost libraries. Terminating." )
|
||||
endif(Boost_FOUND)
|
||||
|
||||
if(COMPILE_TESTS)
|
||||
enable_testing()
|
||||
enable_testing()
|
||||
endif(COMPILE_TESTS)
|
||||
|
||||
|
||||
@ -82,11 +81,11 @@ add_subdirectory(src)
|
||||
# Add a target to generate API documentation with Doxygen
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
add_custom_target(doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
add_custom_target(doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
endif(DOXYGEN_FOUND)
|
||||
|
2
VERSION
2
VERSION
@ -1 +1 @@
|
||||
v0.0.0-test+3.13905be*v0.0.0-test*0*0*0*test*3*13905be
|
||||
v0.0.1-workable
|
||||
|
60
cmake/GetVersionFromFile.cmake
Normal file
60
cmake/GetVersionFromFile.cmake
Normal file
@ -0,0 +1,60 @@
|
||||
##
|
||||
# This CMake modules sets the project version from a version file.
|
||||
#
|
||||
# The module sets the following variables:
|
||||
#
|
||||
# * PROJECT_VERSION_STRING
|
||||
# * PROJECT_VERSION_STRING_FULL
|
||||
# * PROJECT_VERSION_MAJOR
|
||||
# * PROJECT_VERSION_MINOR
|
||||
# * PROJECT_VERSION_PATCH
|
||||
# * PROJECT_VERSION_TWEAK
|
||||
# * PROJECT_VERSION_GIT_SHA
|
||||
#
|
||||
# This module is public domain, use it as it fits you best.
|
||||
##
|
||||
|
||||
# Get full string version from file
|
||||
if(PROJECT_VERSION_FILE)
|
||||
file(STRINGS ${PROJECT_VERSION_FILE} PROJECT_VERSION_STRING)
|
||||
else()
|
||||
file(STRINGS ${CMAKE_SOURCE_DIR}/VERSION PROJECT_VERSION_STRING)
|
||||
endif()
|
||||
|
||||
# Get current commit SHA from git
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE PROJECT_VERSION_GIT_SHA
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Get partial versions into a list
|
||||
string(REGEX MATCHALL "-.*$|[0-9]+" PROJECT_PARTIAL_VERSION_LIST
|
||||
${PROJECT_VERSION_STRING})
|
||||
|
||||
# Set the version numbers
|
||||
list(GET PROJECT_PARTIAL_VERSION_LIST 0 PROJECT_VERSION_MAJOR)
|
||||
list(GET PROJECT_PARTIAL_VERSION_LIST 1 PROJECT_VERSION_MINOR)
|
||||
list(GET PROJECT_PARTIAL_VERSION_LIST 2 PROJECT_VERSION_PATCH)
|
||||
|
||||
# The tweak part is optional, so check if the list contains it
|
||||
list(LENGTH PROJECT_PARTIAL_VERSION_LIST PROJECT_PARTIAL_VERSION_LIST_LEN)
|
||||
if(PROJECT_PARTIAL_VERSION_LIST_LEN GREATER 3)
|
||||
list(GET PROJECT_PARTIAL_VERSION_LIST 3 PROJECT_VERSION_TWEAK)
|
||||
string(SUBSTRING ${PROJECT_VERSION_TWEAK} 1 -1 PROJECT_VERSION_TWEAK)
|
||||
endif()
|
||||
|
||||
# Unset the list
|
||||
unset(PROJECT_PARTIAL_VERSION_LIST)
|
||||
|
||||
# Set full project version string
|
||||
set(PROJECT_VERSION_STRING_FULL
|
||||
${PROJECT_VERSION_STRING}+${PROJECT_VERSION_GIT_SHA})
|
||||
|
||||
# Print all variables for debugging
|
||||
#message(STATUS ${PROJECT_VERSION_STRING_FULL})
|
||||
#message(STATUS ${PROJECT_VERSION_STRING})
|
||||
#message(STATUS ${PROJECT_VERSION_MAJOR})
|
||||
#message(STATUS ${PROJECT_VERSION_MINOR})
|
||||
#message(STATUS ${PROJECT_VERSION_PATCH})
|
||||
#message(STATUS ${PROJECT_VERSION_TWEAK})
|
||||
#message(STATUS ${PROJECT_VERSION_GIT_SHA})
|
@ -1,115 +0,0 @@
|
||||
#
|
||||
# This cmake module sets the project version and partial version
|
||||
# variables by analysing the git tag and commit history. It expects git
|
||||
# tags defined with semantic versioning 2.0.0 (http://semver.org/).
|
||||
#
|
||||
# The module expects the PROJECT_NAME variable to be set, and recognizes
|
||||
# the GIT_FOUND, GIT_EXECUTABLE and VERSION_UPDATE_FROM_GIT variables.
|
||||
# If Git is found and VERSION_UPDATE_FROM_GIT is set to boolean TRUE,
|
||||
# the project version will be updated using information fetched from the
|
||||
# most recent git tag and commit. Otherwise, the module will try to read
|
||||
# a VERSION file containing the full and partial versions. The module
|
||||
# will update this file each time the project version is updated.
|
||||
#
|
||||
# Once done, this module will define the following variables:
|
||||
#
|
||||
# ${PROJECT_NAME}_VERSION_STRING - Version string without metadata
|
||||
# such as "v2.0.0" or "v1.2.41-beta.1". This should correspond to the
|
||||
# most recent git tag.
|
||||
# ${PROJECT_NAME}_VERSION_STRING_FULL - Version string with metadata
|
||||
# such as "v2.0.0+3.a23fbc" or "v1.3.1-alpha.2+4.9c4fd1"
|
||||
# ${PROJECT_NAME}_VERSION - Same as ${PROJECT_NAME}_VERSION_STRING,
|
||||
# without the preceding 'v', e.g. "2.0.0" or "1.2.41-beta.1"
|
||||
# ${PROJECT_NAME}_VERSION_MAJOR - Major version integer (e.g. 2 in v2.3.1-RC.2+21.ef12c8)
|
||||
# ${PROJECT_NAME}_VERSION_MINOR - Minor version integer (e.g. 3 in v2.3.1-RC.2+21.ef12c8)
|
||||
# ${PROJECT_NAME}_VERSION_PATCH - Patch version integer (e.g. 1 in v2.3.1-RC.2+21.ef12c8)
|
||||
# ${PROJECT_NAME}_VERSION_TWEAK - Tweak version string (e.g. "RC.2" in v2.3.1-RC.2+21.ef12c8)
|
||||
# ${PROJECT_NAME}_VERSION_AHEAD - How many commits ahead of last tag (e.g. 21 in v2.3.1-RC.2+21.ef12c8)
|
||||
# ${PROJECT_NAME}_VERSION_GIT_SHA - The git sha1 of the most recent commit (e.g. the "ef12c8" in v2.3.1-RC.2+21.ef12c8)
|
||||
#
|
||||
# This module is public domain, use it as it fits you best.
|
||||
#
|
||||
# Author: Nuno Fachada
|
||||
|
||||
# Check if git is found...
|
||||
if (GIT_FOUND AND VERSION_UPDATE_FROM_GIT)
|
||||
|
||||
# Get last tag from git
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_STRING
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
#How many commits since last tag
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list master ${${PROJECT_NAME}_VERSION_STRING}^..HEAD --count
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_AHEAD
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Get current commit SHA from git
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_GIT_SHA
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Get partial versions into a list
|
||||
string(REGEX MATCHALL "-.*$|[0-9]+" ${PROJECT_NAME}_PARTIAL_VERSION_LIST
|
||||
${${PROJECT_NAME}_VERSION_STRING})
|
||||
|
||||
# Set the version numbers
|
||||
list(GET ${PROJECT_NAME}_PARTIAL_VERSION_LIST
|
||||
0 ${PROJECT_NAME}_VERSION_MAJOR)
|
||||
list(GET ${PROJECT_NAME}_PARTIAL_VERSION_LIST
|
||||
1 ${PROJECT_NAME}_VERSION_MINOR)
|
||||
list(GET ${PROJECT_NAME}_PARTIAL_VERSION_LIST
|
||||
2 ${PROJECT_NAME}_VERSION_PATCH)
|
||||
|
||||
# The tweak part is optional, so check if the list contains it
|
||||
list(LENGTH ${PROJECT_NAME}_PARTIAL_VERSION_LIST
|
||||
${PROJECT_NAME}_PARTIAL_VERSION_LIST_LEN)
|
||||
if (${PROJECT_NAME}_PARTIAL_VERSION_LIST_LEN GREATER 3)
|
||||
list(GET ${PROJECT_NAME}_PARTIAL_VERSION_LIST 3 ${PROJECT_NAME}_VERSION_TWEAK)
|
||||
string(SUBSTRING ${${PROJECT_NAME}_VERSION_TWEAK} 1 -1 ${PROJECT_NAME}_VERSION_TWEAK)
|
||||
endif()
|
||||
|
||||
# Unset the list
|
||||
unset(${PROJECT_NAME}_PARTIAL_VERSION_LIST)
|
||||
|
||||
# Set full project version string
|
||||
set(${PROJECT_NAME}_VERSION_STRING_FULL
|
||||
${${PROJECT_NAME}_VERSION_STRING}+${${PROJECT_NAME}_VERSION_AHEAD}.${${PROJECT_NAME}_VERSION_GIT_SHA})
|
||||
|
||||
# Save version to file (which will be used when Git is not available
|
||||
# or VERSION_UPDATE_FROM_GIT is disabled)
|
||||
file(WRITE ${CMAKE_SOURCE_DIR}/VERSION ${${PROJECT_NAME}_VERSION_STRING_FULL}
|
||||
"*" ${${PROJECT_NAME}_VERSION_STRING}
|
||||
"*" ${${PROJECT_NAME}_VERSION_MAJOR}
|
||||
"*" ${${PROJECT_NAME}_VERSION_MINOR}
|
||||
"*" ${${PROJECT_NAME}_VERSION_PATCH}
|
||||
"*" ${${PROJECT_NAME}_VERSION_TWEAK}
|
||||
"*" ${${PROJECT_NAME}_VERSION_AHEAD}
|
||||
"*" ${${PROJECT_NAME}_VERSION_GIT_SHA})
|
||||
|
||||
else()
|
||||
|
||||
# Git not available, get version from file
|
||||
file(STRINGS ${CMAKE_SOURCE_DIR}/VERSION ${PROJECT_NAME}_VERSION_LIST)
|
||||
string(REPLACE "*" ";" ${PROJECT_NAME}_VERSION_LIST ${${PROJECT_NAME}_VERSION_LIST})
|
||||
# Set partial versions
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 0 ${PROJECT_NAME}_VERSION_STRING_FULL)
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 1 ${PROJECT_NAME}_VERSION_STRING)
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 2 ${PROJECT_NAME}_VERSION_MAJOR)
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 3 ${PROJECT_NAME}_VERSION_MINOR)
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 4 ${PROJECT_NAME}_VERSION_PATCH)
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 5 ${PROJECT_NAME}_VERSION_TWEAK)
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 6 ${PROJECT_NAME}_VERSION_AHEAD)
|
||||
list(GET ${PROJECT_NAME}_VERSION_LIST 7 ${PROJECT_NAME}_VERSION_GIT_SHA)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# Set project version (without the preceding 'v')
|
||||
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
|
||||
if (${PROJECT_NAME}_VERSION_TWEAK)
|
||||
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION}-${${PROJECT_NAME}_VERSION_TWEAK})
|
||||
endif()
|
@ -6,9 +6,9 @@
|
||||
*/
|
||||
|
||||
// e.g. v1.2.3-beta+1.abc123d
|
||||
#define PROJECT_VERSION_FULL "@marian_VERSION_STRING_FULL@"
|
||||
#define PROJECT_VERSION_FULL "@PROJECT_VERSION_STRING_FULL@"
|
||||
// e.g. v1.2.3-beta
|
||||
#define PROJECT_VERSION "@marian_VERSION@"
|
||||
#define PROJECT_VERSION_MAJOR @marian_VERSION_MAJOR@
|
||||
#define PROJECT_VERSION_MINOR @marian_VERSION_MINOR@
|
||||
#define PROJECT_VERSION_PATCH @marian_vERSION_PATCH@
|
||||
#define PROJECT_VERSION "@PROJECT_VERSION_STRING@"
|
||||
#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
||||
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define PROJECT_VERSION_PATCH @PROJECT_vERSION_PATCH@
|
||||
|
Loading…
Reference in New Issue
Block a user