Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check for project submodules. #2329

Merged
merged 1 commit into from
Jan 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,29 @@ endmacro()
# Save the old value of CMAKE_REQUIRED_FLAGS
set( TEMP_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} )

# Check submodules
if(NOT MANUAL_SUBMODULES)
find_package(Git)
if(GIT_FOUND)
function (check_submodule relative_path)
execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path} 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 all submodules with\ngit submodule update --init --recursive --force\nor run cmake with -DMANUAL_SUBMODULES=1\n")
endif()
endfunction ()

message(STATUS "Checking submodules")
check_submodule(docs)
check_submodule(libraries/fc)
endif()
endif()
philmb3487 marked this conversation as resolved.
Show resolved Hide resolved
# Make sure to always re-run the test.
unset( MANUAL_SUBMODULES CACHE )

# Fortify source
if (CMAKE_COMPILER_IS_GNUCXX)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand Down