cmake: Re-run cmake if submodule commits change or a submodule is deinit-ed
This commit is contained in:
parent
4f1a856dbf
commit
be962a9444
1 changed files with 10 additions and 0 deletions
|
@ -41,6 +41,16 @@ else(NOT GIT_FOUND)
|
||||||
elseif(NOT "${status}" STREQUAL " ")
|
elseif(NOT "${status}" STREQUAL " ")
|
||||||
message(WARNING "Git submodule ${submodule_path} is out of date. Run 'git submodule update --init --recursive' to fix.")
|
message(WARNING "Git submodule ${submodule_path} is out of date. Run 'git submodule update --init --recursive' to fix.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Force a re-run of cmake if the submodule's .git file changes or is changed (ie accidental deinit)
|
||||||
|
get_filename_component(submodule_abs_path ${submodule_path} ABSOLUTE BASE_DIR ${root_path})
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${submodule_abs_path}/.git)
|
||||||
|
# same if the HEAD file in the submodule's directory changes (ie commit changes). This will at least prit the 'out of date' warning
|
||||||
|
set(submodule_head "${root_path}/.git/modules/${submodule_path}/HEAD")
|
||||||
|
if(EXISTS "${submodule_head}")
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${submodule_head})
|
||||||
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction(git_submodule_check)
|
endfunction(git_submodule_check)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue