-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache coerced C files, simplify build logic
- Loading branch information
Showing
2 changed files
with
104 additions
and
60 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,51 @@ | ||
# Quick Utility for validating and -- if needed -- cloning a git submodule | ||
# This project depends on "CheckCommand", which is part of the LMMS project. | ||
# | ||
# Copyright (c) 2017, Tres Finocchiaro, <tres.finocchiaro@gmail.com> | ||
# | ||
# Redistribution and use is allowed according to the terms of the BSD license. | ||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
INCLUDE(CheckCommand) | ||
|
||
# Looks for a relative file inside source directory of current target | ||
# - attempts to clone with git if it's missing | ||
# - throws FATAL_ERROR by default unless OPTIONAL is specified | ||
# | ||
# Note: If submodule "foo" is located inside "3rdparty/foo", the RELATIVE_FILE | ||
# should be foo/file.c, which would be 3rdparty/foo/foo/file.c | ||
MACRO(CHECK_SUBMODULE RELATIVE_FILE OPTIONAL) | ||
# Guess submodule name from the path prefix | ||
STRING(REPLACE "/" ";" PARTS ${RELATIVE_FILE}) | ||
LIST(GET PARTS 0 SUBMODULE_NAME) | ||
SET(ABSOLUTE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${RELATIVE_FILE}") | ||
SET(SUBMODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_NAME}") | ||
|
||
# Attempt to do lazy clone | ||
IF(NOT EXISTS "${ABSOLUTE_FILE}") | ||
MESSAGE("-- Submodule '${SUBMODULE_NAME}' missing") | ||
MESSAGE("-- Cloning '${SUBMODULE_NAME}' using git") | ||
CHECK_COMMAND(git) | ||
EXECUTE_PROCESS( | ||
COMMAND git submodule update --init --recursive | ||
WORKING_DIRECTORY "${SUBMODULE_PATH}" | ||
ERROR_VARIABLE GIT_STDERR | ||
) | ||
IF(NOT GIT_STDERR EQUAL "") | ||
MESSAGE("${GIT_STDERR}") | ||
ENDIF() | ||
ENDIF() | ||
|
||
IF(EXISTS "${ABSOLUTE_FILE}") | ||
MESSAGE("-- Found submodule '${SUBMODULE_NAME}': ${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_NAME}") | ||
ELSE() | ||
# Handle optional/warning mode | ||
IF(OPTIONAL STREQUAL "OPTIONAL") | ||
SET(MESSAGE_STATUS WARNING) | ||
ELSE() | ||
SET(MESSAGE_STATUS FATAL_ERROR) | ||
ENDIF() | ||
MESSAGE(${MESSAGE_STATUS} "Submodule '${SUBMODULE_NAME}' missing or incomplete (${RELATIVE_FILE} file not found)\n" | ||
"Did you forget to specify '--recurse' when it was cloned?\n\n") | ||
|
||
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