Skip to content

Commit

Permalink
cmake: git: Add submodule update inside if check
Browse files Browse the repository at this point in the history
The return was wrong since the GIT_* variables are never set if GIT_SUBMODULE is OFF

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Nov 30, 2021
1 parent 7c52f76 commit a1e202c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cmake/git.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ endif()

# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(NOT GIT_SUBMODULE)
return()
endif()

message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE GIT_SUBMODULE_RESULT)
if(NOT GIT_SUBMODULE_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMODULE_RESULT}, please checkout submodules")
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_SUBMODULE_RESULT)
if(NOT GIT_SUBMODULE_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMODULE_RESULT}, please checkout submodules")
endif()
endif()

# Fetch the necessary git variables
Expand Down

0 comments on commit a1e202c

Please sign in to comment.