Skip to content

Commit 1de5216

Browse files
committed
Pick up submodules from CMake config
1 parent b13a1c7 commit 1de5216

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ set(OPENMC_DIR /opt/openmc)
1818
set(OPENMC_INC_DIR ${OPENMC_DIR}/include)
1919
set(OPENMC_LIB_DIR ${OPENMC_DIR}/lib)
2020

21+
# Ensure submodules are available and up to date
22+
find_package(Git QUIET)
23+
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
24+
# Update submodules as needed
25+
option(GIT_SUBMODULE "Check submodules during build" ON)
26+
if(GIT_SUBMODULE)
27+
message(STATUS "Submodule update")
28+
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
29+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
30+
RESULT_VARIABLE GIT_SUBMOD_RESULT)
31+
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
32+
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
33+
endif()
34+
endif()
35+
endif()
36+
37+
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/pybind11/CMakeLists.txt")
38+
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
39+
endif()
40+
2141
# Build source_sampling
2242
list(APPEND source_sampling_SOURCES
2343
${SRC_DIR}/source_sampling.cpp

0 commit comments

Comments
 (0)