Skip to content

Commit 1c1e813

Browse files
committed
Replaced FetchContent with git submodules, raised the CMake minimum required version to 3.15
1 parent 972360a commit 1c1e813

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "DPP"]
2+
path = DPP
3+
url = https://github.com/brainboxdotcc/DPP

CMakeLists.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.6)
1+
cmake_minimum_required (VERSION 3.15)
22

33
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
44
set(BOT_NAME "templatebot")
@@ -50,19 +50,19 @@ if (DPP_FOUND)
5050
target_link_libraries(${BOT_NAME} ${DPP_LIBRARIES})
5151
target_include_directories(${BOT_NAME} PUBLIC ${DPP_INCLUDE_DIR})
5252
else()
53-
message(WARNING "Could not find DPP install. Building from source instead.")
54-
option(DPP_BUILD_TEST "" OFF)
55-
include(FetchContent)
56-
57-
FetchContent_Declare(
58-
libdpp
59-
GIT_REPOSITORY https://github.com/brainboxdotcc/DPP.git
60-
GIT_TAG master)
61-
62-
FetchContent_GetProperties(libdpp)
63-
if(NOT libdpp_POPULATED)
64-
FetchContent_MakeAvailable(libdpp)
65-
endif()
66-
67-
target_link_libraries(${BOT_NAME} dpp)
53+
find_package(Git)
54+
message(WARNING "Could not find DPP install. Building from source instead.")
55+
if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
56+
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init
57+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
58+
RESULT_VARIABLE RESULT)
59+
if (NOT RESULT EQUAL 0)
60+
message(FATAL_ERROR "Failed to update the D++ submodule. Code: ${RESULT}.")
61+
else()
62+
add_subdirectory(DPP)
63+
target_link_libraries(${BOT_NAME} dpp)
64+
endif()
65+
else()
66+
message(FATAL_ERROR "Failed to find the git executable. Can't update the D++ submodule.")
67+
endif()
6868
endif()

DPP

Submodule DPP added at 8293247

0 commit comments

Comments
 (0)