|
1 | | -cmake_minimum_required (VERSION 3.6) |
| 1 | +cmake_minimum_required (VERSION 3.15) |
2 | 2 |
|
3 | 3 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
4 | 4 | set(BOT_NAME "templatebot") |
@@ -50,26 +50,19 @@ if (DPP_FOUND) |
50 | 50 | target_link_libraries(${BOT_NAME} ${DPP_LIBRARIES}) |
51 | 51 | target_include_directories(${BOT_NAME} PUBLIC ${DPP_INCLUDE_DIR}) |
52 | 52 | 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_Populate(libdpp) |
65 | | - target_include_directories(${BOT_NAME} PUBLIC |
66 | | - ${libdpp_SOURCE_DIR}/include |
67 | | - ) |
68 | | - add_subdirectory( |
69 | | - ${libdpp_SOURCE_DIR} |
70 | | - ${libdpp_BINARY_DIR} |
71 | | - EXCLUDE_FROM_ALL) |
72 | | - endif() |
73 | | - |
74 | | - 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() |
75 | 68 | endif() |
0 commit comments