Skip to content
Snippets Groups Projects
Commit f58b8b5f authored by Lars Bilke's avatar Lars Bilke
Browse files

Merge pull request #46 from bilke/SubmoduleInitialization

Added functionality for automatically initializing git submodules.
parents ba3511f2 9cfe1f6f
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ INCLUDE(scripts/cmake/FindIncludeHeader.cmake)
INCLUDE(scripts/cmake/Functions.cmake)
INCLUDE(scripts/cmake/CMakeSetup.cmake)
INCLUDE(scripts/cmake/CompilerSetup.cmake)
INCLUDE(scripts/cmake/SubmoduleSetup.cmake)
IF(NOT OGS_NO_EXTERNAL_LIBS)
INCLUDE(scripts/cmake/Find.cmake)
ENDIF() # NOT OGS_NO_EXTERNAL_LIBS
......
......@@ -7,8 +7,8 @@ ADD_LIBRARY(GeoLib STATIC ${SOURCES_GeoLib})
include_directories(
.
../BaseLib
../MathLib
${CMAKE_SOURCE_DIR}/BaseLib
${CMAKE_SOURCE_DIR}/MathLib
)
......
......@@ -27,6 +27,11 @@ FIND_PACKAGE(cppcheck)
FIND_PACKAGE(PythonInterp)
FIND_PACKAGE(GitHub)
# Find bash itself ...
FIND_PROGRAM(BASH_TOOL_PATH bash
HINTS ${GITHUB_BIN_DIR} DOC "The bash executable")
######################
### Find libraries ###
######################
......
# Checks for unitialized git submodules
# Parameter 1: The path to the submodule
# Returns 0 if there is no such submodule
# Returns 1 if the module is already initialized
result=$(git submodule status $1 | grep '^-' | wc -l); exit $result
\ No newline at end of file
# This file initializes the required submodules
SET(REQUIRED_SUBMODULES
Tests/quickcheck
)
FOREACH(SUBMODULE ${REQUIRED_SUBMODULES})
# Check if submodule is already initialized
# MESSAGE(STATUS "Checking module ${SUBMODULE}")
EXECUTE_PROCESS(
COMMAND ${BASH_TOOL_PATH} ${CMAKE_SOURCE_DIR}/scripts/cmake/SubmoduleCheck.sh ${SUBMODULE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE SUBMODULE_IS_NOT_INITIALIZED
)
IF(SUBMODULE_IS_NOT_INITIALIZED)
MESSAGE(STATUS "Initializing submodule ${SUBMODULE}")
EXECUTE_PROCESS(
COMMAND git submodule update --init ${SUBMODULE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ENDIF()
ENDFOREACH()
\ No newline at end of file
# - Find GitHub for Windows
#
# GITHUB_FOUND - Was GitHub for Windows found
# GITHUB_BIN_DIR - Path to the bin-directory where useful bash tools can be found
#
# Example usage:
# FIND_PACKAGE(GitHub)
# FIND_PROGRAM(BASH_TOOL_PATH bash HINTS ${GITHUB_BIN_DIR} DOC "The bash executable")
IF(WIN32 AND NOT GITHUB_FOUND)
# Check install Path
FIND_PATH(
GITHUB_DIR
shell.ps1
PATHS $ENV{LOCALAPPDATA}/GitHub
NO_DEFAULT_PATH
)
IF(GITHUB_DIR)
FILE(TO_NATIVE_PATH ${GITHUB_DIR} GITHUB_WIN_DIR)
EXECUTE_PROCESS (
COMMAND cmd /c "cd ${GITHUB_WIN_DIR}/PortableGit* & cd"
OUTPUT_VARIABLE PORTABLE_GIT_WIN_DIR
)
IF(PORTABLE_GIT_WIN_DIR)
STRING(STRIP ${PORTABLE_GIT_WIN_DIR} PORTABLE_GIT_WIN_DIR)
FILE(TO_CMAKE_PATH ${PORTABLE_GIT_WIN_DIR} PORTABLE_GIT_DIR)
SET(GITHUB_FOUND ON CACHE BOOL "Was GitHub for Windows found?")
SET(GITHUB_BIN_DIR ${PORTABLE_GIT_DIR}/bin CACHE PATH "The path to the GitHub for Windows binaries.")
MESSAGE(STATUS "GitHub for Windows found.")
ENDIF()
ENDIF()
ENDIF()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment