aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authoryexin <yexin13@huawei.com>2018-08-19 21:59:16 +0800
committeryexin <x1314aq@sina.cn>2018-08-19 22:12:32 +0800
commit866a942c3581440bef9ebda5d84c039490bb3179 (patch)
treebfdb5a7266890ba4d5e025071fbd69faaf7f49ac /CMakeLists.txt
parent5624a8bd09a92196d69444ed76bab3b03280ed8f (diff)
Fix: cmake error when no .git exist
Related issue: Jira DMM-21 Change-Id: I2fd5496eddb2ef0d5bb516d751f8c606efa6631e Signed-off-by: yexin <yexin13@huawei.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt70
1 files changed, 38 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ecc7e8..cf17c75 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,47 +48,53 @@ add_custom_target(clean-cmake-files
COMMAND ${CMAKE_COMMAND} -P clean-all.cmake
)
-execute_process(COMMAND git config --local --get commit.template
- OUTPUT_VARIABLE commit_template)
-if(commit_template STREQUAL "")
+if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
message(STATUS "Setting git commit template...")
- execute_process(COMMAND git config --local commit.template ${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-template)
- message(STATUS "Setting git commit template...done")
-endif()
-
-find_program(GIT_REVIEW git-review)
-if(NOT GIT_REVIEW)
- if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg")
- message(STATUS "git-review not found!")
- message(STATUS "Setting git commit hook...")
- execute_process(COMMAND ln -s ${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg)
- message(STATUS "Setting git commit hook...done")
+ execute_process(COMMAND git config --local commit.template ${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-template
+ RESULT_VARIABLE git_config_ret)
+ if(git_config_ret EQUAL 0)
+ message(STATUS "Setting git commit template...done")
+ else()
+ message(WARNING "Setting git commit template...failed")
endif()
-else()
- if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg")
- execute_process(COMMAND git-review -s
- RESULT_VARIABLE git_review_ret)
- if(${git_review_ret} EQUAL 0)
- file(APPEND ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg "${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py $1")
+
+ find_program(GIT_REVIEW git-review)
+ if(NOT GIT_REVIEW)
+ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg")
+ message(STATUS "git-review not found")
+ message(STATUS "Setting git commit hook...")
+ execute_process(COMMAND ln -s ${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg
+ RESULT_VARIABLE ln_ret)
+ if(ln_ret EQUAL 0)
+ message(STATUS "Setting git commit hook...done")
+ else()
+ message(WARNING "Setting git commit hook...failed")
+ endif()
endif()
else()
- file(READ ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg contents)
- string(FIND "${contents}" "commit-msg-hook.py" match_ret)
- if(${match_ret} EQUAL -1)
- file(APPEND ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg "${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py $1")
+ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg")
+ message(AUTHOR_WARNING "Found git-review but this repo does not seem to have been initialized by git-review. Please manually execute 'git review -s' before cmake.")
+ else()
+ file(READ ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg contents)
+ string(FIND "${contents}" "commit-msg-hook.py" match_ret)
+ if(${match_ret} EQUAL -1)
+ file(APPEND ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg "${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py $1")
+ endif()
endif()
endif()
-endif()
-if(RMWS)
- message(STATUS "Setting git pre-commit hook...")
- execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/scripts/git/pre-commit ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit)
- message(STATUS "Setting git pre-commit hook...done")
+ if(RMWS)
+ message(STATUS "Setting git pre-commit hook...")
+ execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/scripts/git/pre-commit ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit
+ RESULT_VARIABLE ln_sf_ret)
+ if(ln_sf_ret EQUAL 0)
+ message(STATUS "Setting git pre-commit hook...done")
+ else()
+ message(WARNING "Setting git pre-commit hook...failed")
+ endif()
+ endif()
endif()
-option(WITH_SECUREC_LIB "Option description" OFF)
-option(WITH_HAL_LIB "Option description" OFF)
-
if(WITH_SECUREC_LIB)
add_definitions(-DSECUREC_LIB)
endif()