Skip to content

Commit 88f520d

Browse files
committed
Update submodules before CMake enters their directories
1 parent f0f8ee1 commit 88f520d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

thirdparty/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
function(update_submodule submodule)
2+
find_package(Git REQUIRED)
3+
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init thirdparty/${submodule}
4+
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
5+
endfunction()
16

27
find_package(expected-lite QUIET)
38
if(expected-lite_FOUND)
49
add_library(expected-lite ALIAS expected-lite::expected-lite)
510
else()
611
message(STATUS "expected-lite not found, using submodule")
12+
update_submodule(nonstd/expected-light)
713
add_subdirectory(nonstd/expected-light EXCLUDE_FROM_ALL)
814
endif()
915

@@ -12,6 +18,7 @@ if(variant-lite_FOUND)
1218
add_library(variant-lite ALIAS variant-lite::variant-lite)
1319
else()
1420
message(STATUS "variant-lite not found, using submodule")
21+
update_submodule(nonstd/variant-light)
1522
add_subdirectory(nonstd/variant-light EXCLUDE_FROM_ALL)
1623
# There's a bug in the lib, the target does not include the header include dirs.
1724
# See https://github.com/martinmoene/variant-lite/issues/25
@@ -23,6 +30,7 @@ if(value-ptr-lite_FOUND)
2330
add_library(value-ptr-lite ALIAS value-ptr-lite::value-ptr-lite)
2431
else()
2532
message(STATUS "value-ptr-lite not found, using submodule")
33+
update_submodule(nonstd/value-ptr-lite)
2634
add_subdirectory(nonstd/value-ptr-lite EXCLUDE_FROM_ALL)
2735
add_library(value-ptr-lite ALIAS value_ptr-lite)
2836
endif()
@@ -42,6 +50,7 @@ if(boost_filesystem_FOUND AND
4250
add_library(boost_optional ALIAS boost_optional::boost_optional)
4351
else()
4452
message(STATUS "One or more boost modules not found, using submodule")
53+
update_submodule(boost)
4554
set(BOOST_CMAKE_LIBRARIES filesystem algorithm variant optional CACHE INTERNAL "")
4655
add_subdirectory(boost EXCLUDE_FROM_ALL)
4756

@@ -71,6 +80,7 @@ if(JINJA2CPP_BUILD_TESTS)
7180
add_library(gtest ALIAS gtest::gtest)
7281
else()
7382
message(STATUS "expected-lite not found, using submodule")
83+
update_submodule(gtest)
7484

7585
if(MSVC)
7686
if (MSVC_RUNTIME_TYPE STREQUAL "/MD" OR NOT MSVC_RUNTIME_TYPE)

0 commit comments

Comments
 (0)