Skip to content

Commit fd1493b

Browse files
authored
Automatically initialize submodule if missing (#1052)
1 parent cc00fb6 commit fd1493b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1010

1111
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
1212

13+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
14+
find_package(Git QUIET)
15+
if(Git_FOUND)
16+
execute_process(
17+
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
18+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
19+
RESULT_VARIABLE TILELANG_GIT_SUBMODULE_RESULT
20+
)
21+
if(NOT TILELANG_GIT_SUBMODULE_RESULT EQUAL 0)
22+
message(
23+
FATAL_ERROR
24+
"Failed to initialize git submodules. Please run "
25+
"`git submodule update --init --recursive` and re-run CMake."
26+
)
27+
endif()
28+
else()
29+
message(
30+
FATAL_ERROR
31+
"Git is required to initialize TileLang submodules. "
32+
"Please install git or fetch the submodules manually."
33+
)
34+
endif()
35+
endif()
36+
1337
find_program(CCACHE_PROGRAM ccache)
1438
if(CCACHE_PROGRAM)
1539
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "C compiler launcher")

0 commit comments

Comments
 (0)