-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Guard against duplicating btwxt builds
- Loading branch information
pmskintner
committed
Mar 23, 2022
1 parent
58fc6e7
commit dd8e413
Showing
2 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
macro(initialize_submodules) | ||
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") | ||
set(git_modules_file "${PROJECT_SOURCE_DIR}/.gitmodules") | ||
if (EXISTS ${git_modules_file}) | ||
file(STRINGS ${git_modules_file} file_lines) | ||
foreach(line ${file_lines}) | ||
if (${line} MATCHES "url =") | ||
string(REGEX REPLACE "\\s*url = .*/(.*).git" "\\1" submodule "${line}") | ||
string(STRIP "${submodule}" submodule) | ||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${submodule}") | ||
message(FATAL_ERROR "Submodule directory \"${CMAKE_CURRENT_SOURCE_DIR}/${submodule}\" does not exist") | ||
endif() | ||
# Initialize submodule if it hasn't already been cloned | ||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${submodule}/.git") | ||
message(STATUS "Initialize ${submodule} submodule") | ||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive "${CMAKE_CURRENT_SOURCE_DIR}/${submodule}" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
RESULT_VARIABLE GIT_SUBMOD_RESULT) | ||
if(NOT GIT_SUBMOD_RESULT EQUAL "0") | ||
message(FATAL_ERROR "git submodule update --init --recursive ${CMAKE_CURRENT_SOURCE_DIR}/${submodule} failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") | ||
endif() | ||
endif() | ||
endif() | ||
endforeach() | ||
endif() | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
|
||
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") | ||
# Update submodules as needed | ||
option(GIT_SUBMODULE "Check submodules during build" ON) | ||
if(GIT_SUBMODULE) | ||
message(STATUS "Submodule update") | ||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
RESULT_VARIABLE GIT_SUBMOD_RESULT) | ||
if(NOT GIT_SUBMOD_RESULT EQUAL "0") | ||
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
include(initialize-submodules) | ||
initialize_submodules() | ||
|
||
add_subdirectory(btwxt) | ||
if (NOT TARGET btwxt) | ||
add_subdirectory(btwxt) | ||
endif () |