Skip to content

Commit

Permalink
Added GitSubmoduleCheck.cmake module
Browse files Browse the repository at this point in the history
  • Loading branch information
redtide authored and paulfd committed Dec 10, 2023
1 parent c6287a1 commit d91b338
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ set(PROJECT_REPOSITORY https://github.com/sfztools/sfizz)

# External configuration CMake scripts
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Ensure presence of Git submodules (when not using the source tarball)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
include(GitSubmoduleCheck)
git_submodule_check(external/abseil-cpp)
git_submodule_check(external/filesystem)
git_submodule_check(external/simde)
git_submodule_check(external/st_audiofile/thirdparty/dr_libs)
git_submodule_check(external/st_audiofile/thirdparty/libaiff)
git_submodule_check(external/st_audiofile/thirdparty/wavpack)
endif()

include(BuildType)

# Build Options
Expand Down
13 changes: 13 additions & 0 deletions cmake/GitSubmoduleCheck.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
find_package(Git REQUIRED)

# https://gist.github.com/scivision/bb1d47a9529e153617414e91ff5390af

function(git_submodule_check dir)
if(NOT EXISTS "${dir}/CMakeLists.txt")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
endif()
# Add a Git submodule directory to CMake, assuming the Git submodule directory is a CMake project.
# add_subdirectory(${dir} EXCLUDE_FROM_ALL)
endfunction()

0 comments on commit d91b338

Please sign in to comment.