ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/tools/cmake/patches/100-no-testing.patch b/tools/cmake/patches/100-no-testing.patch
new file mode 100644
index 0000000..736a365
--- /dev/null
+++ b/tools/cmake/patches/100-no-testing.patch
@@ -0,0 +1,33 @@
+--- a/Modules/CTest.cmake
++++ b/Modules/CTest.cmake
+@@ -47,7 +47,7 @@ the :variable:`CTEST_USE_LAUNCHERS` vari
+ in the ``CTestConfig.cmake`` file.
+ #]=======================================================================]
+
+-option(BUILD_TESTING "Build the testing tree." ON)
++option(BUILD_TESTING "Build the testing tree." OFF)
+
+ # function to turn generator name into a version string
+ # like vs9 or vs10
+--- a/Modules/Dart.cmake
++++ b/Modules/Dart.cmake
+@@ -47,7 +47,7 @@ if(cmp0145 STREQUAL "")
+ message(AUTHOR_WARNING "${_cmp0145_warning}")
+ endif()
+
+-option(BUILD_TESTING "Build the testing tree." ON)
++option(BUILD_TESTING "Build the testing tree." OFF)
+
+ if(BUILD_TESTING)
+ # We only get here if a project already ran include(Dart),
+--- a/Tests/Contracts/VTK/Dashboard.cmake.in
++++ b/Tests/Contracts/VTK/Dashboard.cmake.in
+@@ -25,7 +25,7 @@ ctest_empty_binary_directory(${CTEST_BIN
+
+ file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "
+ VTK_BUILD_EXAMPLES:BOOL=ON
+- VTK_BUILD_TESTING:STRING=WANT
++ VTK_BUILD_TESTING:STRING=OFF
+ VTK_WRAP_PYTHON:BOOL=ON
+ ExternalData_OBJECT_STORES:FILEPATH=@base_dir@/ExternalData
+ ")
diff --git a/tools/cmake/patches/110-liblzma.patch b/tools/cmake/patches/110-liblzma.patch
new file mode 100644
index 0000000..4b8ec0d
--- /dev/null
+++ b/tools/cmake/patches/110-liblzma.patch
@@ -0,0 +1,17 @@
+--- a/Modules/FindLibLZMA.cmake
++++ b/Modules/FindLibLZMA.cmake
+@@ -61,7 +61,13 @@ The following variables are provided for
+ cmake_policy(PUSH)
+ cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
+
+-find_path(LIBLZMA_INCLUDE_DIR lzma.h )
++if(UNIX)
++ find_package(PkgConfig QUIET)
++ pkg_search_module(PC_liblzma liblzma)
++endif()
++
++find_path(LIBLZMA_INCLUDE_DIR lzma.h HINTS ${PC_liblzma_INCLUDEDIR} ${PC_liblzma_INCLUDE_DIRS})
++find_library(LIBLZMA_LIBRARY NAMES lzma HINTS ${PC_liblzma_LIBDIR} ${PC_liblzma_LIBRARY_DIRS})
+ if(NOT LIBLZMA_LIBRARY)
+ find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma NAMES_PER_DIR PATH_SUFFIXES lib)
+ find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad NAMES_PER_DIR PATH_SUFFIXES lib)
diff --git a/tools/cmake/patches/120-curl-fix-libressl-linking.patch b/tools/cmake/patches/120-curl-fix-libressl-linking.patch
new file mode 100644
index 0000000..1921734
--- /dev/null
+++ b/tools/cmake/patches/120-curl-fix-libressl-linking.patch
@@ -0,0 +1,37 @@
+From: Jo-Philipp Wich <jo@mein.io>
+Date: Wed, 11 Jan 2017 03:36:04 +0100
+Subject: [PATCH] cmcurl: link librt
+
+When cmake is linked against LibreSSL, there might be an indirect
+dependency on librt on certain systems if LibreSSL's libcrypto uses
+clock_gettime() from librt:
+
+ [ 28%] Linking C executable LIBCURL
+ .../lib/libcrypto.a(getentropy_linux.o): In function `getentropy_fallback':
+ getentropy_linux.c:(.text+0x16d): undefined reference to `clock_gettime'
+ getentropy_linux.c:(.text+0x412): undefined reference to `clock_gettime'
+ collect2: error: ld returned 1 exit status
+ make[5]: *** [Utilities/cmcurl/LIBCURL] Error 1
+
+Modify the cmcurl CMakeLists.txt to check for clock_gettime() in librt
+and unconditionally link the rt library when the symbol is found.
+
+Signed-off-by: Jo-Philipp Wich <jo@mein.io>
+---
+--- a/Utilities/cmcurl/CMakeLists.txt
++++ b/Utilities/cmcurl/CMakeLists.txt
+@@ -648,6 +648,14 @@ if(CURL_USE_OPENSSL)
+ endif()
+ set(SSL_ENABLED ON)
+ set(USE_OPENSSL ON)
++ check_library_exists("rt" clock_gettime "" HAVE_LIBRT)
++ if(HAVE_LIBRT)
++ list(APPEND OPENSSL_LIBRARIES rt)
++ endif()
++ check_library_exists("pthread" pthread_once "" HAVE_PTHREAD)
++ if(HAVE_PTHREAD)
++ list(APPEND OPENSSL_LIBRARIES pthread)
++ endif()
+ list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
+ include_directories(${OPENSSL_INCLUDE_DIR})
+
diff --git a/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch b/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch
new file mode 100644
index 0000000..a2a873f
--- /dev/null
+++ b/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch
@@ -0,0 +1,14 @@
+--- a/bootstrap
++++ b/bootstrap
+@@ -1509,7 +1509,10 @@ int main(){ printf("1%c", (char)0x0a); r
+ ' > "test.c"
+ cmake_original_make_flags="${cmake_make_flags}"
+ if test "x${cmake_parallel_make}" != "x"; then
+- cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
++ case "$cmake_parallel_make" in
++ [0-9]*) cmake_parallel_make="-j ${cmake_parallel_make}";;
++ esac
++ cmake_make_flags="${cmake_make_flags} ${cmake_parallel_make}"
+ fi
+ for a in ${cmake_make_processors}; do
+ if test -z "${cmake_make_processor}" && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
diff --git a/tools/cmake/patches/140-zlib.patch b/tools/cmake/patches/140-zlib.patch
new file mode 100644
index 0000000..17334a6
--- /dev/null
+++ b/tools/cmake/patches/140-zlib.patch
@@ -0,0 +1,20 @@
+--- a/Modules/FindZLIB.cmake
++++ b/Modules/FindZLIB.cmake
+@@ -120,10 +120,13 @@ else()
+ set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibwapid zlibvcd zlibstatd)
+ endif()
+
+-# Try each search configuration.
+-foreach(search ${_ZLIB_SEARCHES})
+- find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include)
+-endforeach()
++if(UNIX)
++ find_package(PkgConfig QUIET)
++ pkg_search_module(PC_zlib zlib)
++endif()
++
++find_path(ZLIB_INCLUDE_DIR zlib.h HINTS ${PC_zlib_INCLUDEDIR} ${PC_zlib_INCLUDE_DIRS})
++find_library(ZLIB_LIBRARY NAMES z HINTS ${PC_zlib_LIBDIR} ${PC_zlib_LIBRARY_DIRS})
+
+ # Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library
+ if(NOT ZLIB_LIBRARY)
diff --git a/tools/cmake/patches/150-zstd-libarchive.patch b/tools/cmake/patches/150-zstd-libarchive.patch
new file mode 100644
index 0000000..a6f8e35
--- /dev/null
+++ b/tools/cmake/patches/150-zstd-libarchive.patch
@@ -0,0 +1,11 @@
+--- a/Utilities/cmlibarchive/CMakeLists.txt
++++ b/Utilities/cmlibarchive/CMakeLists.txt
+@@ -656,7 +656,7 @@ IF(ENABLE_ZSTD)
+ SET(ZSTD_FIND_QUIETLY TRUE)
+ ENDIF (ZSTD_INCLUDE_DIR)
+
+- IF(0) # CMake does not let pkg-config override its search paths.
++ IF(1) # CMake does not let pkg-config override its search paths.
+ IF(UNIX)
+ FIND_PACKAGE(PkgConfig QUIET)
+ PKG_SEARCH_MODULE(PC_ZSTD libzstd)
diff --git a/tools/cmake/patches/160-disable_xcode_generator.patch b/tools/cmake/patches/160-disable_xcode_generator.patch
new file mode 100644
index 0000000..0e29ded
--- /dev/null
+++ b/tools/cmake/patches/160-disable_xcode_generator.patch
@@ -0,0 +1,22 @@
+--- a/Source/CMakeLists.txt
++++ b/Source/CMakeLists.txt
+@@ -858,7 +858,7 @@ if(CMake_USE_XCOFF_PARSER)
+ endif()
+
+ # Xcode only works on Apple
+-if(APPLE)
++if(APPLE_DISABLED)
+ target_sources(
+ CMakeLib
+ PRIVATE
+--- a/Source/cmake.cxx
++++ b/Source/cmake.cxx
+@@ -134,7 +134,7 @@
+ # include "cmGlobalGhsMultiGenerator.h"
+ #endif
+
+-#if defined(__APPLE__)
++#if defined(__APPLE_DISABLED__)
+ # if !defined(CMAKE_BOOTSTRAP)
+ # include "cmGlobalXCodeGenerator.h"
+