aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxiphon <xiphon@protonmail.com>2018-10-16 14:43:56 +0000
committerxiphon <xiphon@protonmail.com>2018-10-16 14:43:56 +0000
commitad4cce930b3d969feaf9225e07f9f13688f21fe7 (patch)
tree4c6bcb7b6383a48206212f09e178f425ed02db31
parentMerge pull request #4572 (diff)
downloadmonero-ad4cce930b3d969feaf9225e07f9f13688f21fe7.tar.xz
build: fixed submodule check
-rw-r--r--CMakeLists.txt26
1 files changed, 14 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8baac02e9..72aec521a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -175,19 +175,21 @@ endif()
if(NOT MANUAL_SUBMODULES)
find_package(Git)
if(GIT_FOUND)
+ function (check_submodule relative_path)
+ execute_process(COMMAND git -C ${relative_path} rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE localHead)
+ execute_process(COMMAND git rev-parse "HEAD:${relative_path}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE checkedHead)
+ string(COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate)
+ if (upToDate)
+ message(STATUS "Submodule '${relative_path}' is up-to-date")
+ else()
+ message(FATAL_ERROR "Submodule '${relative_path}' is not up-to-date. Please update with\ngit submodule update --init --force ${relative_path}\nor run cmake with -DMANUAL_SUBMODULES=1")
+ endif()
+ endfunction ()
+
message(STATUS "Checking submodules")
- execute_process(COMMAND bash -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/external/miniupnp && git rev-parse HEAD" OUTPUT_VARIABLE miniupnpLocalHead WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
- execute_process(COMMAND bash -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound && git rev-parse HEAD" OUTPUT_VARIABLE unboundLocalHead WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
- execute_process(COMMAND bash -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/external/rapidjson && git rev-parse HEAD" OUTPUT_VARIABLE rapidjsonLocalHead WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
- execute_process(COMMAND bash -c "git ls-tree HEAD ${CMAKE_CURRENT_SOURCE_DIR}/external/miniupnp | awk '{print $3}'" OUTPUT_VARIABLE miniupnpCheckedHead WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
- execute_process(COMMAND bash -c "git ls-tree HEAD ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound | awk '{print $3}'" OUTPUT_VARIABLE unboundCheckedHead WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
- execute_process(COMMAND bash -c "git ls-tree HEAD ${CMAKE_CURRENT_SOURCE_DIR}/external/rapidjson | awk '{print $3}'" OUTPUT_VARIABLE rapidjsonCheckedHead WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
- string(COMPARE EQUAL "${miniupnpLocalHead}" "${miniupnpCheckedHead}" miniupnpUpToDate)
- string(COMPARE EQUAL "${unboundLocalHead}" "${unboundCheckedHead}" unboundUpToDate)
- string(COMPARE EQUAL "${rapidjsonLocalHead}" "${rapidjsonCheckedHead}" rapidjsonUpToDate)
- if (NOT miniupnpUpToDate OR NOT unboundUpToDate OR NOT rapidjsonUpToDate)
- message(FATAL_ERROR "Submodules not up to date. Please update with git submodule init && git submodule update, or run cmake with -DMANUAL_SUBMODULES=1")
- endif()
+ check_submodule(external/miniupnp)
+ check_submodule(external/unbound)
+ check_submodule(external/rapidjson)
endif()
endif()