From c28b1ee6bd9eaef28848f7e17a12b01c12d52bf3 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Sat, 29 Dec 2018 00:21:32 -0800 Subject: [PATCH] cmake to do a git submodule update --- xc7/family.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xc7/family.cmake b/xc7/family.cmake index 9de869ee..6d24b405 100644 --- a/xc7/family.cmake +++ b/xc7/family.cmake @@ -1,3 +1,19 @@ +# Adapted https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html +find_package(Git QUIET) +if(GIT_FOUND AND EXISTS ".gitmodules") +# Update submodules as needed + option(GIT_SUBMODULE "Check submodules during build" ON) + if(GIT_SUBMODULE) + message(STATUS "Submodule update") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() +endif() + add_dependencies(nextpnr-${family} torc) add_custom_target(torc ALL COMMAND $(MAKE) > /dev/null 2> /dev/null