Get things to configure and compile.

This commit is contained in:
Ulrich Germann 2020-05-06 13:18:55 +01:00
Родитель e3e3c17fe2
Коммит cf6f1813b4
4 изменённых файлов: 128 добавлений и 14 удалений

Просмотреть файл

@ -21,7 +21,7 @@ option(COMPILE_EXAMPLES "Compile examples" OFF)
option(COMPILE_REST_SERVER "Compile Marian REST server" ON)
option(COMPILE_SERVER "Compile marian-server" OFF)
option(COMPILE_TESTS "Compile tests" OFF)
option(UPDATE_SUBMODULES "Check for changes in submodules" OFF)
option(UPDATE_SUBMODULES "Check for changes in submodules" ON)
option(USE_CCACHE "Use ccache compiler cache (https://ccache.dev)" ON)
option(USE_CUDNN "Use CUDNN library" OFF)
option(USE_DOXYGEN "Build documentation with Doxygen" OFF)
@ -32,13 +32,14 @@ option(USE_NCCL "Use NCCL library" ON)
option(USE_SENTENCEPIECE "Download and compile SentencePiece" ON)
option(USE_STATIC_LIBS "Link statically against non-system libs" ON)
include(UpdateSubmodules)
# Project versioning
find_package(Git QUIET)
include(GetVersionFromFile)
message(STATUS "Project name: ${PROJECT_NAME}")
message(STATUS "Project version: ${PROJECT_VERSION_STRING_FULL}")
include(UpdateSubmodules)
add_subdirectory(3rd_party)
message("EXT_LIBS ${EXT_LIBS}")

Просмотреть файл

@ -1 +0,0 @@
../3rd_party/marian/cmake/GetCacheVariables.cmake

Просмотреть файл

@ -0,0 +1,52 @@
##
# This module extracts CMake cached variables into a variable.
#
# Author: snukky
#
# This module sets the following variables:
# * PROJECT_CMAKE_CACHE - to the output of "cmake -L" - an uncached list of
# non-advanced cached variables
# * PROJECT_CMAKE_CACHE_ADVANCED - to the output of "cmake -LA" - an uncached
# list of advanced cached variables
#
set(PROJECT_CMAKE_CACHE "")
set(PROJECT_CMAKE_CACHE_ADVANCED "")
# Get all CMake variables
get_cmake_property(_variableNames VARIABLES)
list(SORT _variableNames)
list(REMOVE_DUPLICATES _variableNames)
foreach(_variableName ${_variableNames})
# If it is a cache variable
get_property(_cachePropIsSet CACHE "${_variableName}" PROPERTY VALUE SET)
if(_cachePropIsSet)
# Get the variable's type
get_property(_variableType CACHE ${_variableName} PROPERTY TYPE)
# Get the variable's value
set(_variableValue "${${_variableName}}")
# Skip static or internal cached variables, cmake -L[A] does not print them, see
# https://github.com/Kitware/CMake/blob/master/Source/cmakemain.cxx#L282
if( (NOT "${_variableType}" STREQUAL "STATIC") AND
(NOT "${_variableType}" STREQUAL "INTERNAL") AND
(NOT "${_variableValue}" STREQUAL "") )
set(PROJECT_CMAKE_CACHE_ADVANCED "${PROJECT_CMAKE_CACHE_ADVANCED} \"${_variableName}=${_variableValue}\\n\"\n")
# Get the variable's advanced flag
get_property(_isAdvanced CACHE ${_variableName} PROPERTY ADVANCED SET)
if(NOT _isAdvanced)
set(PROJECT_CMAKE_CACHE "${PROJECT_CMAKE_CACHE} \"${_variableName}=${_variableValue}\\n\"\n")
endif()
# Print variables for debugging
#message(STATUS "${_variableName}=${${_variableName}}")
#message(STATUS " Type=${_variableType}")
#message(STATUS " Advanced=${_isAdvanced}")
endif()
endif(_cachePropIsSet)
endforeach()

Просмотреть файл

@ -1 +0,0 @@
../3rd_party/marian/cmake/GetVersionFromFile.cmake

Просмотреть файл

@ -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_CURRENT_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,28 +1,31 @@
# Init submodules if necessary, complain if out of sync
if (${UPDATE_SUBMODULES})
if (UPDATE_SUBMODULES)
# Update submodules but only if there are no local uncommited changes
# 1. Check for uncommitted changes
execute_process(COMMAND git submodule foreach --recursive
git status -uno --porcelain OUTPUT_VARIABLE SUBMODULE_STATUS)
string(REGEX MATCH "Entering [^\n]*\n M [^\n]*"
CHANGED_FILES_IN_SUBMODULES ${SUBMODULE_STATUS})
CHANGED_FILES_IN_SUBMODULES "${SUBMODULE_STATUS}")
if(NOT ("${CHANGED_FILES_IN_SUBMODULES}" STREQUAL ""))
# There are uncommitted changes in submodules; list them
message(FATAL_ERROR "There are uncommited changes in submodules:\n${CHANGED_FILES_IN_SUBMODULES}")
else()
# 2. Check for mismatches in submodules; fail if they don't match.
execute_process(COMMAND git diff OUTPUT_VARIABLE SUBMODULE_STATUS)
string(REGEX MATCH "Subproject commit " CHANGED_SUBMODULES ${SUBMODULE_STATUS})
execute_process(COMMAND git diff -- 3rd_party OUTPUT_VARIABLE SUBMODULE_STATUS)
string(REGEX MATCH "Subproject commit " CHANGED_SUBMODULES "${SUBMODULE_STATUS}")
if(NOT ("${CHANGED_SUBMODULES}" STREQUAL ""))
message(FATAL_ERROR "There are mismatches between the recorded commit hash "
"and the local commit hash for some submodules. Run git --diff in "
"${CMAKE_CURRENT_SOURCE_DIR} for details, then commit local changes "
"or update the respective submodules.")
"or update the respective submodules. Configure with -DUPDATE_SUBMODULES=OFF "
"to turn off submodule updates.")
else() # new checkout, no submodules initialized
# Initialize/update all submodules
message("Updating submodules")
execute_process(COMMAND git submodule update --init --recursive --no-fetch
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
else() # new checkout, no submodules initialized
# Initialize/update all submodules
execute_process(COMMAND git submodule update --init --recursive --no-fetch
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
else(UPDATE_SUBMODULES)
message(WARNING "Not checking for submodule updates!")
endif()