From 4847a88556f71033ae65212962b25e03c5dcb305 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 13 Apr 2017 13:46:31 +0800 Subject: [PATCH] cmake: do not try to add submodule to exclude list if .git is not around Signed-off-by: Kefu Chai --- cmake/modules/CTags.cmake | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmake/modules/CTags.cmake b/cmake/modules/CTags.cmake index 7d40984f749..55b22888311 100644 --- a/cmake/modules/CTags.cmake +++ b/cmake/modules/CTags.cmake @@ -12,13 +12,16 @@ function(add_tags name) COMMAND git config --file .gitmodules --get-regexp path COMMAND awk "/${TAGS_SRC_DIR}/ { print $2 }" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + RESULT_VARIABLE result_code OUTPUT_VARIABLE submodules OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE "${TAGS_SRC_DIR}/" "" submodules ${submodules}) - # cmake list uses ";" as the delimiter, so split the string manually - # before iterating in it. - string(REPLACE "\n" ";" submodules ${submodules}) - list(APPEND excludes ${submodules}) + if(${result_code} EQUAL 0) + string(REPLACE "${TAGS_SRC_DIR}/" "" submodules ${submodules}) + # cmake list uses ";" as the delimiter, so split the string manually + # before iterating in it. + string(REPLACE "\n" ";" submodules ${submodules}) + list(APPEND excludes ${submodules}) + endif() endif() message(STATUS "exclude following files under ${TAGS_SRC_DIR}: ${excludes}") # add_custom_target() accepts a list after "COMMAND" keyword, so we should -- 2.39.5