aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--third-party/cmake/DownloadAndExtractFile.cmake14
2 files changed, 15 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 844c02f7e5..d67aebee64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,9 @@ if(APPLE)
endif()
endif()
+# Default to -O2 on release builds.
+string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+
# gcc 4.0 and better turn on _FORTIFY_SOURCE=2 automatically. This currently
# does not work with Neovim due to some uses of dynamically-sized structures.
# See https://github.com/neovim/neovim/issues/223 for details.
diff --git a/third-party/cmake/DownloadAndExtractFile.cmake b/third-party/cmake/DownloadAndExtractFile.cmake
index 14873793d9..eb5c1c6602 100644
--- a/third-party/cmake/DownloadAndExtractFile.cmake
+++ b/third-party/cmake/DownloadAndExtractFile.cmake
@@ -18,6 +18,18 @@ if(NOT DEFINED TARGET)
message(FATAL_ERROR "TARGET must be defined.")
endif()
+set(SRC_DIR ${PREFIX}/src/${TARGET})
+
+# Check whether the source has been downloaded. If true, skip it.
+# Useful for external downloads like homebrew.
+if(EXISTS "${SRC_DIR}" AND IS_DIRECTORY "${SRC_DIR}")
+ file(GLOB EXISTED_FILES "${SRC_DIR}/*")
+ if(EXISTED_FILES)
+ message(STATUS "${SRC_DIR} is found and not empty, skipping download and extraction. ")
+ return()
+ endif()
+endif()
+
# Taken from ExternalProject_Add. Let's hope we can drop this one day when
# ExternalProject_Add allows you to disable SHOW_PROGRESS on the file download.
if(TIMEOUT)
@@ -71,8 +83,6 @@ endif()
message(STATUS "downloading... done")
-set(SRC_DIR ${PREFIX}/src/${TARGET})
-
# Slurped from a generated extract-TARGET.cmake file.
message(STATUS "extracting...
src='${file}'