mirror of https://gitlab.com/QEF/q-e.git
Enable CMake support when source is not git repo.
This commit is contained in:
parent
ce169be3f6
commit
dbf306d739
|
@ -233,6 +233,17 @@ if(QE_ENABLE_MPI)
|
|||
INTERFACE MPI::MPI_Fortran)
|
||||
endif(QE_ENABLE_MPI)
|
||||
|
||||
###########################################################
|
||||
# Lapack
|
||||
###########################################################
|
||||
find_package(Git 2.13 REQUIRED)
|
||||
if(EXISTS ${qe_SOURCE_DIR}/.git)
|
||||
message(" Source files are cloned from a git repository.")
|
||||
set(IS_GIT_PROJECT 1)
|
||||
else()
|
||||
message(" Source files are not cloned from a git repository.")
|
||||
endif()
|
||||
|
||||
###########################################################
|
||||
# Lapack
|
||||
# The following targets will be defined:
|
||||
|
|
|
@ -92,14 +92,70 @@ function(_qe_add_cuda_link_flags TGT)
|
|||
endfunction(_qe_add_cuda_link_flags)
|
||||
|
||||
function(qe_git_submodule_update PATH)
|
||||
find_package(Git)
|
||||
# Old versions of git aren't able to run init+update
|
||||
# in one go (via 'git submodule update --init'), we need
|
||||
# to call one command for each operation:
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule init -- ${PATH}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --depth 1 -- ${PATH}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
# validate update_commits against git database
|
||||
get_filename_component(SUBMODULE_NAME ${PATH} NAME)
|
||||
get_filename_component(SUBMODULE_UPPER_DIR ${PATH} DIRECTORY)
|
||||
set(commit_hash_file ${qe_SOURCE_DIR}/${SUBMODULE_UPPER_DIR}/submodule_commit_hash_records)
|
||||
# a submodule hash consistency check
|
||||
if(IS_GIT_PROJECT AND EXISTS ${commit_hash_file})
|
||||
# Extract submodule commit hash from git repo database
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} ls-tree HEAD ${PATH}
|
||||
OUTPUT_VARIABLE DATABASE_STRING
|
||||
WORKING_DIRECTORY ${qe_SOURCE_DIR})
|
||||
string(REGEX REPLACE " |\t" ";" DATABASE_OUTPUT ${DATABASE_STRING})
|
||||
list(GET DATABASE_OUTPUT 2 DATABASE_HASH)
|
||||
|
||||
# Extract submodule commit hash from saved records
|
||||
execute_process(COMMAND grep ${SUBMODULE_NAME} ${commit_hash_file}
|
||||
OUTPUT_VARIABLE RECORD_STRING)
|
||||
string(REPLACE " " ";" RECORD_OUTPUT ${RECORD_STRING})
|
||||
list(GET RECORD_OUTPUT 0 RECORD_HASH)
|
||||
|
||||
if(NOT DATABASE_HASH STREQUAL RECORD_HASH)
|
||||
message(FATAL_ERROR "If you are a user, please file a bug report! "
|
||||
"If you are a developer, probably submodules '${SUBMODULE_NAME}' is being touched. "
|
||||
"Inconsistent submodule commit hashes have been detected.\n"
|
||||
" ${DATABASE_HASH} from repo data base.\n"
|
||||
" ${RECORD_HASH} from 'submodule_commit_hash_records' file.\n")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(IS_GIT_PROJECT)
|
||||
# Old versions of git aren't able to run init+update
|
||||
# in one go (via 'git submodule update --init'), we need
|
||||
# to call one command for each operation:
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule init -- ${PATH}
|
||||
WORKING_DIRECTORY ${qe_SOURCE_DIR})
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --depth 1 -- ${PATH}
|
||||
WORKING_DIRECTORY ${qe_SOURCE_DIR})
|
||||
else()
|
||||
if(EXISTS ${commit_hash_file})
|
||||
if(EXISTS ${qe_SOURCE_DIR}/${PATH}/.git)
|
||||
message(STATUS "Previous clone found at ${qe_SOURCE_DIR}/${PATH}.")
|
||||
else()
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} config --file .gitmodules --get submodule.${PATH}.URL
|
||||
OUTPUT_VARIABLE SUBMODULE_URL
|
||||
WORKING_DIRECTORY ${qe_SOURCE_DIR}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
message(STATUS "Cloning ${SUBMODULE_URL} into ${qe_SOURCE_DIR}/${PATH}.")
|
||||
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} clone --no-checkout ${SUBMODULE_URL} ${PATH}
|
||||
WORKING_DIRECTORY ${qe_SOURCE_DIR})
|
||||
|
||||
# Extract submodule commit hash from saved records
|
||||
execute_process(COMMAND grep ${SUBMODULE_NAME} ${commit_hash_file}
|
||||
OUTPUT_VARIABLE RECORD_STRING)
|
||||
string(REPLACE " " ";" RECORD_OUTPUT ${RECORD_STRING})
|
||||
list(GET RECORD_OUTPUT 0 RECORD_HASH)
|
||||
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} checkout -b recorded_HEAD ${RECORD_HASH}
|
||||
WORKING_DIRECTORY ${qe_SOURCE_DIR}/${PATH})
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Failed to handle submodules '${SUBMODULE_NAME}'!")
|
||||
endif()
|
||||
endif()
|
||||
endfunction(qe_git_submodule_update)
|
||||
|
||||
function(qe_add_executable EXE)
|
||||
|
@ -164,4 +220,4 @@ endfunction(qe_ensure_build_type)
|
|||
|
||||
if(TARGET QEGlobalCompileDefinitions)
|
||||
qe_install_targets(QEGlobalCompileDefinitions)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
00c140557725bdd9b155566924c01cfe3d61081a devxlib
|
||||
d0197c76ae76bbf4d3fed20444fac31af550069d eigensolver_gpu
|
||||
7cc70b4bc5668769b2edb28117375f5dab33ecd1 fox
|
||||
12d825396fcef1e0a1b27be9f119f9e554621e55 lapack
|
||||
82005cbb65bdf5d32ca021848eec8f19da956a77 mbd
|
||||
9676b93252046524852445c8e44fbe7ce347f63d wannier90
|
|
@ -0,0 +1 @@
|
|||
git ls-tree HEAD . | grep "^160000" | awk '{print $3, $4}' > submodule_commit_hash_records
|
Loading…
Reference in New Issue