mirror of
https://github.com/Hizenberg469/OTP-rfc4226-rfc6238-rfc4648.git
synced 2026-04-19 18:02:23 +03:00
Working model finished
This commit is contained in:
39
cmake/AddGitSubmodule.cmake
Normal file
39
cmake/AddGitSubmodule.cmake
Normal file
@@ -0,0 +1,39 @@
|
||||
function(add_git_submodule relative_dir lib link)
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir})
|
||||
|
||||
#For intializing git if not already initialized.
|
||||
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
# If .git directory does not exist, execute git init
|
||||
execute_process(
|
||||
COMMAND git init
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
RESULT_VARIABLE result
|
||||
)
|
||||
|
||||
if(result)
|
||||
message(FATAL_ERROR "Failed to initialize git repository.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#For adding the external deps if not added yet
|
||||
if (NOT EXISTS ${FULL_DIR}/${lib})
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE}
|
||||
submodule add -- ${link}
|
||||
WORKING_DIRECTORY ${FULL_DIR}
|
||||
)
|
||||
elseif (NOT EXISTS ${FULL_DIR}/CMakeLists.txt)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE}
|
||||
submodule update --init -- ${relative_dir}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${FULL_DIR}/CMakeLists.txt)
|
||||
message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt")
|
||||
add_subdirectory(${FULL_DIR})
|
||||
else()
|
||||
message("Submodule is NO CMake Project: ${FULL_DIR}")
|
||||
endif()
|
||||
endfunction(add_git_submodule)
|
||||
Reference in New Issue
Block a user