Merge branch 'FindBoost-1.69' into release-3.13

Merge-request: !2522
diff --git a/Auxiliary/vim/cmake.vim.in b/Auxiliary/vim/cmake.vim.in
index d7eff3e..77ad3d8 100644
--- a/Auxiliary/vim/cmake.vim.in
+++ b/Auxiliary/vim/cmake.vim.in
@@ -19,8 +19,10 @@
 let s:keepcpo= &cpo
 set cpo&vim
 
-syn region cmakeComment start="#" end="$" contains=cmakeTodo,cmakeLuaComment,@Spell
-syn region cmakeLuaComment start="\[\z(=*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
+syn region cmakeBracketArgument start="\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
+
+syn region cmakeComment start="#" end="$" contains=cmakeTodo,@Spell
+syn region cmakeBracketComment start="#\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
 
 syn match cmakeEscaped /\(\\\\\|\\"\|\\n\|\\t\)/ contained
 syn region cmakeRegistry start="\[" end="]" contained oneline contains=cmakeTodo,cmakeEscaped
@@ -33,7 +35,7 @@
 
 syn region cmakeEnvironment start="$ENV{" end="}" contained oneline contains=cmakeTodo
 
-syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeArguments,cmakeTodo
+syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo
 
 syn case match
 
@@ -75,6 +77,8 @@
             \ TODO FIXME XXX
             \ contained
 
+hi def link cmakeBracketArgument String
+hi def link cmakeBracketComment Comment
 hi def link cmakeCommand Function
 hi def link cmakeCommandConditional Conditional
 hi def link cmakeCommandDeprecated WarningMsg
@@ -84,7 +88,6 @@
 hi def link cmakeEscaped Special
 hi def link cmakeGeneratorExpression WarningMsg
 hi def link cmakeGeneratorExpressions Constant
-hi def link cmakeLuaComment Comment
 hi def link cmakeModule Include
 hi def link cmakeProperty Constant
 hi def link cmakeRegistry Underlined
@@ -95,6 +98,30 @@
 
 @KEYWORDS_HIGHLIGHT@
 
+" Manually added - difficult to parse out of documentation
+syn case ignore
+
+syn keyword cmakeCommandManuallyAdded
+            \ configure_package_config_file write_basic_package_version_file
+            \ nextgroup=cmakeArguments
+
+syn case match
+
+syn keyword cmakeKWconfigure_package_config_file contained
+            \ INSTALL_DESTINATION PATH_VARS NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO INSTALL_PREFIX
+
+syn keyword cmakeKWconfigure_package_config_file_constants contained
+            \ AnyNewerVersion SameMajorVersion SameMinorVersion ExactVersion
+
+syn keyword cmakeKWwrite_basic_package_version_file contained
+            \ VERSION COMPATIBILITY
+
+hi def link cmakeCommandManuallyAdded Function
+
+hi def link cmakeKWconfigure_package_config_file ModeMsg
+hi def link cmakeKWwrite_basic_package_version_file ModeMsg
+hi def link cmakeKWconfigure_package_config_file_constants Constant
+
 let b:current_syntax = "cmake"
 
 let &cpo = s:keepcpo
diff --git a/Auxiliary/vim/extract-upper-case.pl b/Auxiliary/vim/extract-upper-case.pl
index 6dbb678..bd62ade 100755
--- a/Auxiliary/vim/extract-upper-case.pl
+++ b/Auxiliary/vim/extract-upper-case.pl
@@ -103,25 +103,25 @@
 			my @tmp = grep { ! exists $conditional{$_} and
 			                 ! exists $loop{$_} and
 			                 ! exists $deprecated{$_} } @commands;
-			print OUT " " x 12 , "\\ ", join(" ", @tmp), "\n";
+			print_list(\*OUT, @tmp);
 		} elsif ($1 eq "VARIABLE_LIST") {
-			print OUT " " x 12 , "\\ ", join(" ", sort keys %variables), "\n";
+			print_list(\*OUT, keys %variables);
 		} elsif ($1 eq "MODULES") {
-			print OUT " " x 12 , "\\ ", join("\n", @modules), "\n";
+			print_list(\*OUT, @modules);
 		} elsif ($1 eq "GENERATOR_EXPRESSIONS") {
-			print OUT " " x 12 , "\\ ", join(" ", @generator_expr), "\n";
+			print_list(\*OUT, @generator_expr);
 		} elsif ($1 eq "CONDITIONALS") {
-			print OUT " " x 12 , "\\ ", join(" ", sort keys %conditional), "\n";
+			print_list(\*OUT, keys %conditional);
 		} elsif ($1 eq "LOOPS") {
-			print OUT " " x 12 , "\\ ", join(" ", sort keys %loop), "\n";
+			print_list(\*OUT, keys %loop);
 		} elsif ($1 eq "DEPRECATED") {
-			print OUT " " x 12 , "\\ ", join(" ", sort keys %deprecated), "\n";
+			print_list(\*OUT, keys %deprecated);
 		} elsif ($1 eq "PROPERTIES") {
-			print OUT " " x 12 , "\\ ", join(" ", sort keys %properties), "\n";
+			print_list(\*OUT, keys %properties);
 		} elsif ($1 eq "KEYWORDS") {
 			foreach my $k (sort keys %keywords) {
 				print OUT "syn keyword cmakeKW$k contained\n";
-				print OUT " " x 12, "\\ ", join(" ", @{$keywords{$k}}), "\n";
+				print_list(\*OUT, @{$keywords{$k}});
 				print OUT "\n";
 				push @keyword_hi, "hi def link cmakeKW$k ModeMsg";
 			}
@@ -164,3 +164,10 @@
 
 	return @word;
 }
+
+sub print_list
+{
+	my $O = shift;
+	my $indent = " " x 12 . "\\ ";
+	print $O $indent, join("\n" . $indent, sort @_), "\n";
+}
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim
index 5c153c1..076b47f 100644
--- a/Auxiliary/vim/syntax/cmake.vim
+++ b/Auxiliary/vim/syntax/cmake.vim
@@ -1,13 +1,13 @@
 " Vim syntax file
 " Program:      CMake - Cross-Platform Makefile Generator
-" Version:      cmake version 3.10.20171031-gfd2e6
+" Version:      cmake version 3.13.20181010-ga3598
 " Language:     CMake
 " Author:       Andy Cedilnik <andy.cedilnik@kitware.com>,
 "               Nicholas Hutchinson <nshutchinson@gmail.com>,
 "               Patrick Boettcher <patrick.boettcher@posteo.de>
 " Maintainer:   Dimitri Merejkowsky <d.merej@gmail.com>
 " Former Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
-" Last Change:  2017 Oct 31
+" Last Change:  2018 Oct 18
 "
 " Licence:      The CMake license applies to this file. See
 "               https://cmake.org/licensing
@@ -19,8 +19,10 @@
 let s:keepcpo= &cpo
 set cpo&vim
 
-syn region cmakeComment start="#" end="$" contains=cmakeTodo,cmakeLuaComment,@Spell
-syn region cmakeLuaComment start="\[\z(=*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
+syn region cmakeBracketArgument start="\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
+
+syn region cmakeComment start="#" end="$" contains=cmakeTodo,@Spell
+syn region cmakeBracketComment start="#\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
 
 syn match cmakeEscaped /\(\\\\\|\\"\|\\n\|\\t\)/ contained
 syn region cmakeRegistry start="\[" end="]" contained oneline contains=cmakeTodo,cmakeEscaped
@@ -33,291 +35,2138 @@
 
 syn region cmakeEnvironment start="$ENV{" end="}" contained oneline contains=cmakeTodo
 
-syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeArguments,cmakeTodo
+syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo
 
 syn case match
 
 syn keyword cmakeProperty contained
-            \ ABSTRACT ADDITIONAL_MAKE_CLEAN_FILES ADVANCED ALIASED_TARGET ALLOW_DUPLICATE_CUSTOM_TARGETS ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_API ANDROID_API_MIN ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES ANDROID_GUI ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_NAME ATTACHED_FILES ATTACHED_FILES_ON_FAIL AUTOGEN_BUILD_DIR AUTOGEN_SOURCE_GROUP AUTOGEN_TARGETS_FOLDER AUTOGEN_TARGET_DEPENDS AUTOMOC AUTOMOC_COMPILER_PREDEFINES AUTOMOC_DEPEND_FILTERS AUTOMOC_MACRO_NAMES AUTOMOC_MOC_OPTIONS AUTOMOC_SOURCE_GROUP AUTOMOC_TARGETS_FOLDER AUTORCC AUTORCC_OPTIONS AUTORCC_SOURCE_GROUP AUTOUIC AUTOUIC_OPTIONS AUTOUIC_SEARCH_PATHS BINARY_DIR BUILDSYSTEM_TARGETS BUILD_RPATH BUILD_WITH_INSTALL_NAME_DIR BUILD_WITH_INSTALL_RPATH BUNDLE BUNDLE_EXTENSION CACHE_VARIABLES CLEAN_NO_CUSTOM CMAKE_CONFIGURE_DEPENDS CMAKE_CXX_KNOWN_FEATURES CMAKE_C_KNOWN_FEATURES COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING COMPILE_DEFINITIONS COMPILE_FEATURES COMPILE_FLAGS COMPILE_OPTIONS COMPILE_PDB_NAME COMPILE_PDB_OUTPUT_DIRECTORY COST CPACK_DESKTOP_SHORTCUTS CPACK_NEVER_OVERWRITE CPACK_PERMANENT CPACK_STARTUP_SHORTCUTS CPACK_START_MENU_SHORTCUTS CPACK_WIX_ACL CROSSCOMPILING_EMULATOR CUDA_EXTENSIONS CUDA_PTX_COMPILATION CUDA_RESOLVE_DEVICE_SYMBOLS CUDA_SEPARABLE_COMPILATION CUDA_STANDARD CUDA_STANDARD_REQUIRED CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED DEBUG_CONFIGURATIONS DEBUG_POSTFIX DEFINE_SYMBOL DEFINITIONS DEPENDS DEPLOYMENT_REMOTE_DIRECTORY DISABLED DISABLED_FEATURES ECLIPSE_EXTRA_NATURES ENABLED_FEATURES ENABLED_LANGUAGES ENABLE_EXPORTS ENVIRONMENT EXCLUDE_FROM_ALL EXCLUDE_FROM_DEFAULT_BUILD EXPORT_NAME EXTERNAL_OBJECT EchoString FAIL_REGULAR_EXPRESSION FIND_LIBRARY_USE_LIB32_PATHS FIND_LIBRARY_USE_LIB64_PATHS FIND_LIBRARY_USE_LIBX32_PATHS FIND_LIBRARY_USE_OPENBSD_VERSIONING FIXTURES_CLEANUP FIXTURES_REQUIRED FIXTURES_SETUP FOLDER FRAMEWORK FRAMEWORK_VERSION Fortran_FORMAT Fortran_MODULE_DIRECTORY GENERATED GENERATOR_FILE_NAME GENERATOR_IS_MULTI_CONFIG GLOBAL_DEPENDS_DEBUG_MODE GLOBAL_DEPENDS_NO_CYCLES GNUtoMS HAS_CXX HEADER_FILE_ONLY HELPSTRING IMPLICIT_DEPENDS_INCLUDE_TRANSFORM IMPORTED IMPORTED_CONFIGURATIONS IMPORTED_IMPLIB IMPORTED_LIBNAME IMPORTED_LINK_DEPENDENT_LIBRARIES IMPORTED_LINK_INTERFACE_LANGUAGES IMPORTED_LINK_INTERFACE_LIBRARIES IMPORTED_LINK_INTERFACE_MULTIPLICITY IMPORTED_LOCATION IMPORTED_NO_SONAME IMPORTED_OBJECTS IMPORTED_SONAME IMPORT_PREFIX IMPORT_SUFFIX INCLUDE_DIRECTORIES INCLUDE_REGULAR_EXPRESSION INSTALL_NAME_DIR INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH INTERFACE_AUTOUIC_OPTIONS INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SOURCES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES INTERPROCEDURAL_OPTIMIZATION IN_TRY_COMPILE IOS_INSTALL_COMBINED JOB_POOLS JOB_POOL_COMPILE JOB_POOL_LINK KEEP_EXTENSION LABELS LANGUAGE LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_NAME LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_DIRECTORIES LINK_FLAGS LINK_INTERFACE_LIBRARIES LINK_INTERFACE_MULTIPLICITY LINK_LIBRARIES LINK_SEARCH_END_STATIC LINK_SEARCH_START_STATIC LINK_WHAT_YOU_USE LISTFILE_STACK LOCATION MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_PACKAGE_LOCATION MACOSX_RPATH MACROS MANUALLY_ADDED_DEPENDENCIES MEASUREMENT MODIFIED NAME NO_SONAME NO_SYSTEM_FROM_IMPORTED OBJECT_DEPENDS OBJECT_OUTPUTS OSX_ARCHITECTURES OUTPUT_NAME PACKAGES_FOUND PACKAGES_NOT_FOUND PARENT_DIRECTORY PASS_REGULAR_EXPRESSION PDB_NAME PDB_OUTPUT_DIRECTORY POSITION_INDEPENDENT_CODE POST_INSTALL_SCRIPT PREDEFINED_TARGETS_FOLDER PREFIX PRE_INSTALL_SCRIPT PRIVATE_HEADER PROCESSORS PROJECT_LABEL PUBLIC_HEADER REPORT_UNDEFINED_PROPERTIES REQUIRED_FILES RESOURCE RESOURCE_LOCK RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK RULE_MESSAGES RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_NAME RUN_SERIAL SKIP_AUTOGEN SKIP_AUTOMOC SKIP_AUTORCC SKIP_AUTOUIC SKIP_BUILD_RPATH SKIP_RETURN_CODE SOURCES SOURCE_DIR SOVERSION STATIC_LIBRARY_FLAGS STRINGS SUBDIRECTORIES SUFFIX SYMBOLIC TARGET_ARCHIVES_MAY_BE_SHARED_LIBS TARGET_MESSAGES TARGET_SUPPORTS_SHARED_LIBS TEST_INCLUDE_FILE TEST_INCLUDE_FILES TIMEOUT TIMEOUT_AFTER_MATCH TYPE USE_FOLDERS VALUE VARIABLES VERSION VISIBILITY_INLINES_HIDDEN VS_CONFIGURATION_TYPE VS_COPY_TO_OUT_DIR VS_DEBUGGER_WORKING_DIRECTORY VS_DEPLOYMENT_CONTENT VS_DEPLOYMENT_LOCATION VS_DESKTOP_EXTENSIONS_VERSION VS_DOTNET_REFERENCES VS_DOTNET_REFERENCES_COPY_LOCAL VS_DOTNET_TARGET_FRAMEWORK_VERSION VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE VS_INCLUDE_IN_VSIX VS_IOT_EXTENSIONS_VERSION VS_IOT_STARTUP_TASK VS_KEYWORD VS_MOBILE_EXTENSIONS_VERSION VS_RESOURCE_GENERATOR VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER VS_SDK_REFERENCES VS_SHADER_ENTRYPOINT VS_SHADER_FLAGS VS_SHADER_MODEL VS_SHADER_OUTPUT_HEADER_FILE VS_SHADER_TYPE VS_SHADER_VARIABLE_NAME VS_STARTUP_PROJECT VS_TOOL_OVERRIDE VS_USER_PROPS VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES VS_XAML_TYPE WILL_FAIL WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS WORKING_DIRECTORY WRAP_EXCLUDE XCODE_EMIT_EFFECTIVE_PLATFORM_NAME XCODE_EXPLICIT_FILE_TYPE XCODE_FILE_ATTRIBUTES XCODE_LAST_KNOWN_FILE_TYPE XCODE_PRODUCT_TYPE XCTEST
+            \ ABSTRACT
+            \ ADDITIONAL_MAKE_CLEAN_FILES
+            \ ADVANCED
+            \ ALIASED_TARGET
+            \ ALLOW_DUPLICATE_CUSTOM_TARGETS
+            \ ANDROID_ANT_ADDITIONAL_OPTIONS
+            \ ANDROID_API
+            \ ANDROID_API_MIN
+            \ ANDROID_ARCH
+            \ ANDROID_ASSETS_DIRECTORIES
+            \ ANDROID_GUI
+            \ ANDROID_JAR_DEPENDENCIES
+            \ ANDROID_JAR_DIRECTORIES
+            \ ANDROID_JAVA_SOURCE_DIR
+            \ ANDROID_NATIVE_LIB_DEPENDENCIES
+            \ ANDROID_NATIVE_LIB_DIRECTORIES
+            \ ANDROID_PROCESS_MAX
+            \ ANDROID_PROGUARD
+            \ ANDROID_PROGUARD_CONFIG_PATH
+            \ ANDROID_SECURE_PROPS_PATH
+            \ ANDROID_SKIP_ANT_STEP
+            \ ANDROID_STL_TYPE
+            \ ARCHIVE_OUTPUT_DIRECTORY
+            \ ARCHIVE_OUTPUT_NAME
+            \ ATTACHED_FILES
+            \ ATTACHED_FILES_ON_FAIL
+            \ AUTOGEN_BUILD_DIR
+            \ AUTOGEN_PARALLEL
+            \ AUTOGEN_SOURCE_GROUP
+            \ AUTOGEN_TARGETS_FOLDER
+            \ AUTOGEN_TARGET_DEPENDS
+            \ AUTOMOC
+            \ AUTOMOC_COMPILER_PREDEFINES
+            \ AUTOMOC_DEPEND_FILTERS
+            \ AUTOMOC_MACRO_NAMES
+            \ AUTOMOC_MOC_OPTIONS
+            \ AUTOMOC_SOURCE_GROUP
+            \ AUTOMOC_TARGETS_FOLDER
+            \ AUTORCC
+            \ AUTORCC_OPTIONS
+            \ AUTORCC_SOURCE_GROUP
+            \ AUTOUIC
+            \ AUTOUIC_OPTIONS
+            \ AUTOUIC_SEARCH_PATHS
+            \ BINARY_DIR
+            \ BUILDSYSTEM_TARGETS
+            \ BUILD_RPATH
+            \ BUILD_WITH_INSTALL_NAME_DIR
+            \ BUILD_WITH_INSTALL_RPATH
+            \ BUNDLE
+            \ BUNDLE_EXTENSION
+            \ CACHE_VARIABLES
+            \ CLEAN_NO_CUSTOM
+            \ CMAKE_CONFIGURE_DEPENDS
+            \ CMAKE_CXX_KNOWN_FEATURES
+            \ CMAKE_C_KNOWN_FEATURES
+            \ COMMON_LANGUAGE_RUNTIME
+            \ COMPATIBLE_INTERFACE_BOOL
+            \ COMPATIBLE_INTERFACE_NUMBER_MAX
+            \ COMPATIBLE_INTERFACE_NUMBER_MIN
+            \ COMPATIBLE_INTERFACE_STRING
+            \ COMPILE_DEFINITIONS
+            \ COMPILE_FEATURES
+            \ COMPILE_FLAGS
+            \ COMPILE_OPTIONS
+            \ COMPILE_PDB_NAME
+            \ COMPILE_PDB_OUTPUT_DIRECTORY
+            \ COST
+            \ CPACK_DESKTOP_SHORTCUTS
+            \ CPACK_NEVER_OVERWRITE
+            \ CPACK_PERMANENT
+            \ CPACK_STARTUP_SHORTCUTS
+            \ CPACK_START_MENU_SHORTCUTS
+            \ CPACK_WIX_ACL
+            \ CROSSCOMPILING_EMULATOR
+            \ CUDA_EXTENSIONS
+            \ CUDA_PTX_COMPILATION
+            \ CUDA_RESOLVE_DEVICE_SYMBOLS
+            \ CUDA_SEPARABLE_COMPILATION
+            \ CUDA_STANDARD
+            \ CUDA_STANDARD_REQUIRED
+            \ CXX_EXTENSIONS
+            \ CXX_STANDARD
+            \ CXX_STANDARD_REQUIRED
+            \ C_EXTENSIONS
+            \ C_STANDARD
+            \ C_STANDARD_REQUIRED
+            \ DEBUG_CONFIGURATIONS
+            \ DEBUG_POSTFIX
+            \ DEFINE_SYMBOL
+            \ DEFINITIONS
+            \ DEPENDS
+            \ DEPLOYMENT_ADDITIONAL_FILES
+            \ DEPLOYMENT_REMOTE_DIRECTORY
+            \ DISABLED
+            \ DISABLED_FEATURES
+            \ DOTNET_TARGET_FRAMEWORK_VERSION
+            \ ECLIPSE_EXTRA_CPROJECT_CONTENTS
+            \ ECLIPSE_EXTRA_NATURES
+            \ ENABLED_FEATURES
+            \ ENABLED_LANGUAGES
+            \ ENABLE_EXPORTS
+            \ ENVIRONMENT
+            \ EXCLUDE_FROM_ALL
+            \ EXCLUDE_FROM_DEFAULT_BUILD
+            \ EXPORT_NAME
+            \ EXPORT_PROPERTIES
+            \ EXTERNAL_OBJECT
+            \ EchoString
+            \ FAIL_REGULAR_EXPRESSION
+            \ FIND_LIBRARY_USE_LIB32_PATHS
+            \ FIND_LIBRARY_USE_LIB64_PATHS
+            \ FIND_LIBRARY_USE_LIBX32_PATHS
+            \ FIND_LIBRARY_USE_OPENBSD_VERSIONING
+            \ FIXTURES_CLEANUP
+            \ FIXTURES_REQUIRED
+            \ FIXTURES_SETUP
+            \ FOLDER
+            \ FRAMEWORK
+            \ FRAMEWORK_VERSION
+            \ Fortran_FORMAT
+            \ Fortran_MODULE_DIRECTORY
+            \ GENERATED
+            \ GENERATOR_FILE_NAME
+            \ GENERATOR_IS_MULTI_CONFIG
+            \ GLOBAL_DEPENDS_DEBUG_MODE
+            \ GLOBAL_DEPENDS_NO_CYCLES
+            \ GNUtoMS
+            \ HAS_CXX
+            \ HEADER_FILE_ONLY
+            \ HELPSTRING
+            \ IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
+            \ IMPORTED
+            \ IMPORTED_COMMON_LANGUAGE_RUNTIME
+            \ IMPORTED_CONFIGURATIONS
+            \ IMPORTED_GLOBAL
+            \ IMPORTED_IMPLIB
+            \ IMPORTED_LIBNAME
+            \ IMPORTED_LINK_DEPENDENT_LIBRARIES
+            \ IMPORTED_LINK_INTERFACE_LANGUAGES
+            \ IMPORTED_LINK_INTERFACE_LIBRARIES
+            \ IMPORTED_LINK_INTERFACE_MULTIPLICITY
+            \ IMPORTED_LOCATION
+            \ IMPORTED_NO_SONAME
+            \ IMPORTED_OBJECTS
+            \ IMPORTED_SONAME
+            \ IMPORT_PREFIX
+            \ IMPORT_SUFFIX
+            \ INCLUDE_DIRECTORIES
+            \ INCLUDE_REGULAR_EXPRESSION
+            \ INSTALL_NAME_DIR
+            \ INSTALL_RPATH
+            \ INSTALL_RPATH_USE_LINK_PATH
+            \ INTERFACE_AUTOUIC_OPTIONS
+            \ INTERFACE_COMPILE_DEFINITIONS
+            \ INTERFACE_COMPILE_FEATURES
+            \ INTERFACE_COMPILE_OPTIONS
+            \ INTERFACE_INCLUDE_DIRECTORIES
+            \ INTERFACE_LINK_DEPENDS
+            \ INTERFACE_LINK_DIRECTORIES
+            \ INTERFACE_LINK_LIBRARIES
+            \ INTERFACE_LINK_OPTIONS
+            \ INTERFACE_POSITION_INDEPENDENT_CODE
+            \ INTERFACE_SOURCES
+            \ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
+            \ INTERPROCEDURAL_OPTIMIZATION
+            \ IN_TRY_COMPILE
+            \ IOS_INSTALL_COMBINED
+            \ JOB_POOLS
+            \ JOB_POOL_COMPILE
+            \ JOB_POOL_LINK
+            \ KEEP_EXTENSION
+            \ LABELS
+            \ LANGUAGE
+            \ LIBRARY_OUTPUT_DIRECTORY
+            \ LIBRARY_OUTPUT_NAME
+            \ LINKER_LANGUAGE
+            \ LINK_DEPENDS
+            \ LINK_DEPENDS_NO_SHARED
+            \ LINK_DIRECTORIES
+            \ LINK_FLAGS
+            \ LINK_INTERFACE_LIBRARIES
+            \ LINK_INTERFACE_MULTIPLICITY
+            \ LINK_LIBRARIES
+            \ LINK_OPTIONS
+            \ LINK_SEARCH_END_STATIC
+            \ LINK_SEARCH_START_STATIC
+            \ LINK_WHAT_YOU_USE
+            \ LISTFILE_STACK
+            \ LOCATION
+            \ MACOSX_BUNDLE
+            \ MACOSX_BUNDLE_INFO_PLIST
+            \ MACOSX_FRAMEWORK_INFO_PLIST
+            \ MACOSX_PACKAGE_LOCATION
+            \ MACOSX_RPATH
+            \ MACROS
+            \ MANUALLY_ADDED_DEPENDENCIES
+            \ MEASUREMENT
+            \ MODIFIED
+            \ NAME
+            \ NO_SONAME
+            \ NO_SYSTEM_FROM_IMPORTED
+            \ OBJECT_DEPENDS
+            \ OBJECT_OUTPUTS
+            \ OSX_ARCHITECTURES
+            \ OUTPUT_NAME
+            \ PACKAGES_FOUND
+            \ PACKAGES_NOT_FOUND
+            \ PARENT_DIRECTORY
+            \ PASS_REGULAR_EXPRESSION
+            \ PDB_NAME
+            \ PDB_OUTPUT_DIRECTORY
+            \ POSITION_INDEPENDENT_CODE
+            \ POST_INSTALL_SCRIPT
+            \ PREDEFINED_TARGETS_FOLDER
+            \ PREFIX
+            \ PRE_INSTALL_SCRIPT
+            \ PRIVATE_HEADER
+            \ PROCESSORS
+            \ PROCESSOR_AFFINITY
+            \ PROJECT_LABEL
+            \ PUBLIC_HEADER
+            \ REPORT_UNDEFINED_PROPERTIES
+            \ REQUIRED_FILES
+            \ RESOURCE
+            \ RESOURCE_LOCK
+            \ RULE_LAUNCH_COMPILE
+            \ RULE_LAUNCH_CUSTOM
+            \ RULE_LAUNCH_LINK
+            \ RULE_MESSAGES
+            \ RUNTIME_OUTPUT_DIRECTORY
+            \ RUNTIME_OUTPUT_NAME
+            \ RUN_SERIAL
+            \ SKIP_AUTOGEN
+            \ SKIP_AUTOMOC
+            \ SKIP_AUTORCC
+            \ SKIP_AUTOUIC
+            \ SKIP_BUILD_RPATH
+            \ SKIP_RETURN_CODE
+            \ SOURCES
+            \ SOURCE_DIR
+            \ SOVERSION
+            \ STATIC_LIBRARY_FLAGS
+            \ STATIC_LIBRARY_OPTIONS
+            \ STRINGS
+            \ SUBDIRECTORIES
+            \ SUFFIX
+            \ SYMBOLIC
+            \ TARGET_ARCHIVES_MAY_BE_SHARED_LIBS
+            \ TARGET_MESSAGES
+            \ TARGET_SUPPORTS_SHARED_LIBS
+            \ TESTS
+            \ TEST_INCLUDE_FILE
+            \ TEST_INCLUDE_FILES
+            \ TIMEOUT
+            \ TIMEOUT_AFTER_MATCH
+            \ TYPE
+            \ USE_FOLDERS
+            \ VALUE
+            \ VARIABLES
+            \ VERSION
+            \ VISIBILITY_INLINES_HIDDEN
+            \ VS_CONFIGURATION_TYPE
+            \ VS_COPY_TO_OUT_DIR
+            \ VS_DEBUGGER_COMMAND
+            \ VS_DEBUGGER_COMMAND_ARGUMENTS
+            \ VS_DEBUGGER_ENVIRONMENT
+            \ VS_DEBUGGER_WORKING_DIRECTORY
+            \ VS_DEPLOYMENT_CONTENT
+            \ VS_DEPLOYMENT_LOCATION
+            \ VS_DESKTOP_EXTENSIONS_VERSION
+            \ VS_DOTNET_REFERENCES
+            \ VS_DOTNET_REFERENCES_COPY_LOCAL
+            \ VS_DOTNET_TARGET_FRAMEWORK_VERSION
+            \ VS_GLOBAL_KEYWORD
+            \ VS_GLOBAL_PROJECT_TYPES
+            \ VS_GLOBAL_ROOTNAMESPACE
+            \ VS_INCLUDE_IN_VSIX
+            \ VS_IOT_EXTENSIONS_VERSION
+            \ VS_IOT_STARTUP_TASK
+            \ VS_KEYWORD
+            \ VS_MOBILE_EXTENSIONS_VERSION
+            \ VS_RESOURCE_GENERATOR
+            \ VS_SCC_AUXPATH
+            \ VS_SCC_LOCALPATH
+            \ VS_SCC_PROJECTNAME
+            \ VS_SCC_PROVIDER
+            \ VS_SDK_REFERENCES
+            \ VS_SHADER_DISABLE_OPTIMIZATIONS
+            \ VS_SHADER_ENABLE_DEBUG
+            \ VS_SHADER_ENTRYPOINT
+            \ VS_SHADER_FLAGS
+            \ VS_SHADER_MODEL
+            \ VS_SHADER_OBJECT_FILE_NAME
+            \ VS_SHADER_OUTPUT_HEADER_FILE
+            \ VS_SHADER_TYPE
+            \ VS_SHADER_VARIABLE_NAME
+            \ VS_STARTUP_PROJECT
+            \ VS_TOOL_OVERRIDE
+            \ VS_USER_PROPS
+            \ VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
+            \ VS_WINRT_COMPONENT
+            \ VS_WINRT_EXTENSIONS
+            \ VS_WINRT_REFERENCES
+            \ VS_XAML_TYPE
+            \ WILL_FAIL
+            \ WIN32_EXECUTABLE
+            \ WINDOWS_EXPORT_ALL_SYMBOLS
+            \ WORKING_DIRECTORY
+            \ WRAP_EXCLUDE
+            \ XCODE_EMIT_EFFECTIVE_PLATFORM_NAME
+            \ XCODE_EXPLICIT_FILE_TYPE
+            \ XCODE_FILE_ATTRIBUTES
+            \ XCODE_LAST_KNOWN_FILE_TYPE
+            \ XCODE_PRODUCT_TYPE
+            \ XCODE_SCHEME_ADDRESS_SANITIZER
+            \ XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+            \ XCODE_SCHEME_ARGUMENTS
+            \ XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+            \ XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+            \ XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+            \ XCODE_SCHEME_ENVIRONMENT
+            \ XCODE_SCHEME_EXECUTABLE
+            \ XCODE_SCHEME_GUARD_MALLOC
+            \ XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+            \ XCODE_SCHEME_MALLOC_GUARD_EDGES
+            \ XCODE_SCHEME_MALLOC_SCRIBBLE
+            \ XCODE_SCHEME_MALLOC_STACK
+            \ XCODE_SCHEME_THREAD_SANITIZER
+            \ XCODE_SCHEME_THREAD_SANITIZER_STOP
+            \ XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+            \ XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+            \ XCODE_SCHEME_ZOMBIE_OBJECTS
+            \ XCTEST
 
 syn keyword cmakeVariable contained
-            \ ANDROID APPLE BORLAND BUILD_SHARED_LIBS CMAKE_ABSOLUTE_DESTINATION_FILES CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS CMAKE_ANDROID_API CMAKE_ANDROID_API_MIN CMAKE_ANDROID_ARCH CMAKE_ANDROID_ARCH_ABI CMAKE_ANDROID_ARM_MODE CMAKE_ANDROID_ARM_NEON CMAKE_ANDROID_ASSETS_DIRECTORIES CMAKE_ANDROID_GUI CMAKE_ANDROID_JAR_DEPENDENCIES CMAKE_ANDROID_JAR_DIRECTORIES CMAKE_ANDROID_JAVA_SOURCE_DIR CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES CMAKE_ANDROID_NDK CMAKE_ANDROID_NDK_DEPRECATED_HEADERS CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION CMAKE_ANDROID_PROCESS_MAX CMAKE_ANDROID_PROGUARD CMAKE_ANDROID_PROGUARD_CONFIG_PATH CMAKE_ANDROID_SECURE_PROPS_PATH CMAKE_ANDROID_SKIP_ANT_STEP CMAKE_ANDROID_STANDALONE_TOOLCHAIN CMAKE_ANDROID_STL_TYPE CMAKE_APPBUNDLE_PATH CMAKE_AR CMAKE_ARCHIVE_OUTPUT_DIRECTORY CMAKE_ARGC CMAKE_ARGV0 CMAKE_AUTOMOC CMAKE_AUTOMOC_COMPILER_PREDEFINES CMAKE_AUTOMOC_DEPEND_FILTERS CMAKE_AUTOMOC_MACRO_NAMES CMAKE_AUTOMOC_MOC_OPTIONS CMAKE_AUTOMOC_RELAXED_MODE CMAKE_AUTORCC CMAKE_AUTORCC_OPTIONS CMAKE_AUTOUIC CMAKE_AUTOUIC_OPTIONS CMAKE_AUTOUIC_SEARCH_PATHS CMAKE_BACKWARDS_COMPATIBILITY CMAKE_BINARY_DIR CMAKE_BUILD_RPATH CMAKE_BUILD_TOOL CMAKE_BUILD_TYPE CMAKE_BUILD_WITH_INSTALL_NAME_DIR CMAKE_BUILD_WITH_INSTALL_RPATH CMAKE_CACHEFILE_DIR CMAKE_CACHE_MAJOR_VERSION CMAKE_CACHE_MINOR_VERSION CMAKE_CACHE_PATCH_VERSION CMAKE_CFG_INTDIR CMAKE_CL_64 CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES CMAKE_CODELITE_USE_TARGETS CMAKE_COLOR_MAKEFILE CMAKE_COMMAND CMAKE_COMPILER_2005 CMAKE_COMPILER_IS_GNUCC CMAKE_COMPILER_IS_GNUCXX CMAKE_COMPILER_IS_GNUG77 CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY CMAKE_CONFIGURATION_TYPES CMAKE_CROSSCOMPILING CMAKE_CROSSCOMPILING_EMULATOR CMAKE_CTEST_COMMAND CMAKE_CUDA_EXTENSIONS CMAKE_CUDA_HOST_COMPILER CMAKE_CUDA_STANDARD CMAKE_CUDA_STANDARD_REQUIRED CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_LIST_DIR CMAKE_CURRENT_LIST_FILE CMAKE_CURRENT_LIST_LINE CMAKE_CURRENT_SOURCE_DIR CMAKE_CXX_COMPILE_FEATURES CMAKE_CXX_EXTENSIONS CMAKE_CXX_STANDARD CMAKE_CXX_STANDARD_REQUIRED CMAKE_C_COMPILE_FEATURES CMAKE_C_EXTENSIONS CMAKE_C_STANDARD CMAKE_C_STANDARD_REQUIRED CMAKE_DEBUG_POSTFIX CMAKE_DEBUG_TARGET_PROPERTIES CMAKE_DEPENDS_IN_PROJECT_ONLY CMAKE_DIRECTORY_LABELS CMAKE_DL_LIBS CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT CMAKE_ECLIPSE_MAKE_ARGUMENTS CMAKE_ECLIPSE_VERSION CMAKE_EDIT_COMMAND CMAKE_ENABLE_EXPORTS CMAKE_ERROR_DEPRECATED CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION CMAKE_EXECUTABLE_SUFFIX CMAKE_EXE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS_INIT CMAKE_EXPORT_COMPILE_COMMANDS CMAKE_EXPORT_NO_PACKAGE_REGISTRY CMAKE_EXTRA_GENERATOR CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES CMAKE_FIND_APPBUNDLE CMAKE_FIND_FRAMEWORK CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX CMAKE_FIND_LIBRARY_PREFIXES CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_NO_INSTALL_PREFIX CMAKE_FIND_PACKAGE_NAME CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY CMAKE_FIND_PACKAGE_SORT_DIRECTION CMAKE_FIND_PACKAGE_SORT_ORDER CMAKE_FIND_PACKAGE_WARN_NO_MODULE CMAKE_FIND_ROOT_PATH CMAKE_FIND_ROOT_PATH_MODE_INCLUDE CMAKE_FIND_ROOT_PATH_MODE_LIBRARY CMAKE_FIND_ROOT_PATH_MODE_PACKAGE CMAKE_FIND_ROOT_PATH_MODE_PROGRAM CMAKE_FRAMEWORK_PATH CMAKE_Fortran_FORMAT CMAKE_Fortran_MODDIR_DEFAULT CMAKE_Fortran_MODDIR_FLAG CMAKE_Fortran_MODOUT_FLAG CMAKE_Fortran_MODULE_DIRECTORY CMAKE_GENERATOR CMAKE_GENERATOR_INSTANCE CMAKE_GENERATOR_PLATFORM CMAKE_GENERATOR_TOOLSET CMAKE_GNUtoMS CMAKE_HOME_DIRECTORY CMAKE_HOST_APPLE CMAKE_HOST_SOLARIS CMAKE_HOST_SYSTEM CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_PROCESSOR CMAKE_HOST_SYSTEM_VERSION CMAKE_HOST_UNIX CMAKE_HOST_WIN32 CMAKE_IGNORE_PATH CMAKE_IMPORT_LIBRARY_PREFIX CMAKE_IMPORT_LIBRARY_SUFFIX CMAKE_INCLUDE_CURRENT_DIR CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE CMAKE_INCLUDE_DIRECTORIES_BEFORE CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE CMAKE_INCLUDE_PATH CMAKE_INSTALL_DEFAULT_COMPONENT_NAME CMAKE_INSTALL_MESSAGE CMAKE_INSTALL_NAME_DIR CMAKE_INSTALL_PREFIX CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT CMAKE_INSTALL_RPATH CMAKE_INSTALL_RPATH_USE_LINK_PATH CMAKE_INTERNAL_PLATFORM_ABI CMAKE_INTERPROCEDURAL_OPTIMIZATION CMAKE_IOS_INSTALL_COMBINED CMAKE_JOB_POOL_COMPILE CMAKE_JOB_POOL_LINK CMAKE_LIBRARY_ARCHITECTURE CMAKE_LIBRARY_ARCHITECTURE_REGEX CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_LIBRARY_PATH CMAKE_LIBRARY_PATH_FLAG CMAKE_LINK_DEF_FILE_FLAG CMAKE_LINK_DEPENDS_NO_SHARED CMAKE_LINK_INTERFACE_LIBRARIES CMAKE_LINK_LIBRARY_FILE_FLAG CMAKE_LINK_LIBRARY_FLAG CMAKE_LINK_LIBRARY_SUFFIX CMAKE_LINK_SEARCH_END_STATIC CMAKE_LINK_SEARCH_START_STATIC CMAKE_LINK_WHAT_YOU_USE CMAKE_MACOSX_BUNDLE CMAKE_MACOSX_RPATH CMAKE_MAJOR_VERSION CMAKE_MAKE_PROGRAM CMAKE_MATCH_COUNT CMAKE_MFC_FLAG CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_MINOR_VERSION CMAKE_MODULE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS_INIT CMAKE_MODULE_PATH CMAKE_MSVCIDE_RUN_PATH CMAKE_NETRC CMAKE_NETRC_FILE CMAKE_NINJA_OUTPUT_PATH_PREFIX CMAKE_NOT_USING_CONFIG_FLAGS CMAKE_NO_BUILTIN_CHRPATH CMAKE_NO_SYSTEM_FROM_IMPORTED CMAKE_OBJECT_PATH_MAX CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT CMAKE_PARENT_LIST_FILE CMAKE_PATCH_VERSION CMAKE_PDB_OUTPUT_DIRECTORY CMAKE_POSITION_INDEPENDENT_CODE CMAKE_PREFIX_PATH CMAKE_PROGRAM_PATH CMAKE_PROJECT_DESCRIPTION CMAKE_PROJECT_NAME CMAKE_RANLIB CMAKE_ROOT CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_SCRIPT_MODE_FILE CMAKE_SHARED_LIBRARY_PREFIX CMAKE_SHARED_LIBRARY_SUFFIX CMAKE_SHARED_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS_INIT CMAKE_SHARED_MODULE_PREFIX CMAKE_SHARED_MODULE_SUFFIX CMAKE_SIZEOF_VOID_P CMAKE_SKIP_BUILD_RPATH CMAKE_SKIP_INSTALL_ALL_DEPENDENCY CMAKE_SKIP_INSTALL_RPATH CMAKE_SKIP_INSTALL_RULES CMAKE_SKIP_RPATH CMAKE_SOURCE_DIR CMAKE_STAGING_PREFIX CMAKE_STATIC_LIBRARY_PREFIX CMAKE_STATIC_LIBRARY_SUFFIX CMAKE_STATIC_LINKER_FLAGS CMAKE_STATIC_LINKER_FLAGS_INIT CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE CMAKE_SYSROOT CMAKE_SYSROOT_COMPILE CMAKE_SYSROOT_LINK CMAKE_SYSTEM CMAKE_SYSTEM_APPBUNDLE_PATH CMAKE_SYSTEM_FRAMEWORK_PATH CMAKE_SYSTEM_IGNORE_PATH CMAKE_SYSTEM_INCLUDE_PATH CMAKE_SYSTEM_LIBRARY_PATH CMAKE_SYSTEM_NAME CMAKE_SYSTEM_PREFIX_PATH CMAKE_SYSTEM_PROCESSOR CMAKE_SYSTEM_PROGRAM_PATH CMAKE_SYSTEM_VERSION CMAKE_Swift_LANGUAGE_VERSION CMAKE_TOOLCHAIN_FILE CMAKE_TRY_COMPILE_CONFIGURATION CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_TRY_COMPILE_TARGET_TYPE CMAKE_TWEAK_VERSION CMAKE_USER_MAKE_RULES_OVERRIDE CMAKE_USE_RELATIVE_PATHS CMAKE_VERBOSE_MAKEFILE CMAKE_VERSION CMAKE_VISIBILITY_INLINES_HIDDEN CMAKE_VS_DEVENV_COMMAND CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD CMAKE_VS_INTEL_Fortran_PROJECT_VERSION CMAKE_VS_MSBUILD_COMMAND CMAKE_VS_NsightTegra_VERSION CMAKE_VS_PLATFORM_NAME CMAKE_VS_PLATFORM_TOOLSET CMAKE_VS_PLATFORM_TOOLSET_CUDA CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION CMAKE_WARN_DEPRECATED CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION CMAKE_WIN32_EXECUTABLE CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS CMAKE_XCODE_GENERATE_SCHEME CMAKE_XCODE_PLATFORM_TOOLSET CPACK_ABSOLUTE_DESTINATION_FILES CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION CPACK_INCLUDE_TOPLEVEL_DIRECTORY CPACK_INSTALL_SCRIPT CPACK_PACKAGING_INSTALL_PREFIX CPACK_SET_DESTDIR CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION CTEST_BINARY_DIRECTORY CTEST_BUILD_COMMAND CTEST_BUILD_NAME CTEST_BZR_COMMAND CTEST_BZR_UPDATE_OPTIONS CTEST_CHANGE_ID CTEST_CHECKOUT_COMMAND CTEST_CONFIGURATION_TYPE CTEST_CONFIGURE_COMMAND CTEST_COVERAGE_COMMAND CTEST_COVERAGE_EXTRA_FLAGS CTEST_CURL_OPTIONS CTEST_CUSTOM_COVERAGE_EXCLUDE CTEST_CUSTOM_ERROR_EXCEPTION CTEST_CUSTOM_ERROR_MATCH CTEST_CUSTOM_ERROR_POST_CONTEXT CTEST_CUSTOM_ERROR_PRE_CONTEXT CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE CTEST_CUSTOM_MEMCHECK_IGNORE CTEST_CUSTOM_POST_MEMCHECK CTEST_CUSTOM_POST_TEST CTEST_CUSTOM_PRE_MEMCHECK CTEST_CUSTOM_PRE_TEST CTEST_CUSTOM_TEST_IGNORE CTEST_CUSTOM_WARNING_EXCEPTION CTEST_CUSTOM_WARNING_MATCH CTEST_CVS_CHECKOUT CTEST_CVS_COMMAND CTEST_CVS_UPDATE_OPTIONS CTEST_DROP_LOCATION CTEST_DROP_METHOD CTEST_DROP_SITE CTEST_DROP_SITE_CDASH CTEST_DROP_SITE_PASSWORD CTEST_DROP_SITE_USER CTEST_EXTRA_COVERAGE_GLOB CTEST_GIT_COMMAND CTEST_GIT_INIT_SUBMODULES CTEST_GIT_UPDATE_CUSTOM CTEST_GIT_UPDATE_OPTIONS CTEST_HG_COMMAND CTEST_HG_UPDATE_OPTIONS CTEST_LABELS_FOR_SUBPROJECTS CTEST_MEMORYCHECK_COMMAND CTEST_MEMORYCHECK_COMMAND_OPTIONS CTEST_MEMORYCHECK_SANITIZER_OPTIONS CTEST_MEMORYCHECK_SUPPRESSIONS_FILE CTEST_MEMORYCHECK_TYPE CTEST_NIGHTLY_START_TIME CTEST_P4_CLIENT CTEST_P4_COMMAND CTEST_P4_OPTIONS CTEST_P4_UPDATE_OPTIONS CTEST_SCP_COMMAND CTEST_SITE CTEST_SOURCE_DIRECTORY CTEST_SVN_COMMAND CTEST_SVN_OPTIONS CTEST_SVN_UPDATE_OPTIONS CTEST_TEST_LOAD CTEST_TEST_TIMEOUT CTEST_TRIGGER_SITE CTEST_UPDATE_COMMAND CTEST_UPDATE_OPTIONS CTEST_UPDATE_VERSION_ONLY CTEST_USE_LAUNCHERS CYGWIN ENV EXECUTABLE_OUTPUT_PATH GHS-MULTI LIBRARY_OUTPUT_PATH MINGW MSVC MSVC10 MSVC11 MSVC12 MSVC14 MSVC60 MSVC70 MSVC71 MSVC80 MSVC90 MSVC_IDE MSVC_VERSION PROJECT_BINARY_DIR PROJECT_DESCRIPTION PROJECT_NAME PROJECT_SOURCE_DIR PROJECT_VERSION PROJECT_VERSION_MAJOR PROJECT_VERSION_MINOR PROJECT_VERSION_PATCH PROJECT_VERSION_TWEAK UNIX WIN32 WINCE WINDOWS_PHONE WINDOWS_STORE XCODE XCODE_VERSION
+            \ ANDROID
+            \ APPLE
+            \ BORLAND
+            \ BUILD_SHARED_LIBS
+            \ CACHE
+            \ CMAKE_ABSOLUTE_DESTINATION_FILES
+            \ CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS
+            \ CMAKE_ANDROID_API
+            \ CMAKE_ANDROID_API_MIN
+            \ CMAKE_ANDROID_ARCH
+            \ CMAKE_ANDROID_ARCH_ABI
+            \ CMAKE_ANDROID_ARM_MODE
+            \ CMAKE_ANDROID_ARM_NEON
+            \ CMAKE_ANDROID_ASSETS_DIRECTORIES
+            \ CMAKE_ANDROID_GUI
+            \ CMAKE_ANDROID_JAR_DEPENDENCIES
+            \ CMAKE_ANDROID_JAR_DIRECTORIES
+            \ CMAKE_ANDROID_JAVA_SOURCE_DIR
+            \ CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES
+            \ CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES
+            \ CMAKE_ANDROID_NDK
+            \ CMAKE_ANDROID_NDK_DEPRECATED_HEADERS
+            \ CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG
+            \ CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
+            \ CMAKE_ANDROID_PROCESS_MAX
+            \ CMAKE_ANDROID_PROGUARD
+            \ CMAKE_ANDROID_PROGUARD_CONFIG_PATH
+            \ CMAKE_ANDROID_SECURE_PROPS_PATH
+            \ CMAKE_ANDROID_SKIP_ANT_STEP
+            \ CMAKE_ANDROID_STANDALONE_TOOLCHAIN
+            \ CMAKE_ANDROID_STL_TYPE
+            \ CMAKE_APPBUNDLE_PATH
+            \ CMAKE_AR
+            \ CMAKE_ARCHIVE_OUTPUT_DIRECTORY
+            \ CMAKE_ARGC
+            \ CMAKE_ARGV0
+            \ CMAKE_AUTOGEN_PARALLEL
+            \ CMAKE_AUTOGEN_VERBOSE
+            \ CMAKE_AUTOMOC
+            \ CMAKE_AUTOMOC_COMPILER_PREDEFINES
+            \ CMAKE_AUTOMOC_DEPEND_FILTERS
+            \ CMAKE_AUTOMOC_MACRO_NAMES
+            \ CMAKE_AUTOMOC_MOC_OPTIONS
+            \ CMAKE_AUTOMOC_RELAXED_MODE
+            \ CMAKE_AUTORCC
+            \ CMAKE_AUTORCC_OPTIONS
+            \ CMAKE_AUTOUIC
+            \ CMAKE_AUTOUIC_OPTIONS
+            \ CMAKE_AUTOUIC_SEARCH_PATHS
+            \ CMAKE_BACKWARDS_COMPATIBILITY
+            \ CMAKE_BINARY_DIR
+            \ CMAKE_BUILD_RPATH
+            \ CMAKE_BUILD_TOOL
+            \ CMAKE_BUILD_TYPE
+            \ CMAKE_BUILD_WITH_INSTALL_NAME_DIR
+            \ CMAKE_BUILD_WITH_INSTALL_RPATH
+            \ CMAKE_CACHEFILE_DIR
+            \ CMAKE_CACHE_MAJOR_VERSION
+            \ CMAKE_CACHE_MINOR_VERSION
+            \ CMAKE_CACHE_PATCH_VERSION
+            \ CMAKE_CFG_INTDIR
+            \ CMAKE_CL_64
+            \ CMAKE_CODEBLOCKS_COMPILER_ID
+            \ CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES
+            \ CMAKE_CODELITE_USE_TARGETS
+            \ CMAKE_COLOR_MAKEFILE
+            \ CMAKE_COMMAND
+            \ CMAKE_COMPILER_2005
+            \ CMAKE_COMPILER_IS_GNUCC
+            \ CMAKE_COMPILER_IS_GNUCXX
+            \ CMAKE_COMPILER_IS_GNUG77
+            \ CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
+            \ CMAKE_CONFIGURATION_TYPES
+            \ CMAKE_CPACK_COMMAND
+            \ CMAKE_CROSSCOMPILING
+            \ CMAKE_CROSSCOMPILING_EMULATOR
+            \ CMAKE_CTEST_COMMAND
+            \ CMAKE_CUDA_EXTENSIONS
+            \ CMAKE_CUDA_HOST_COMPILER
+            \ CMAKE_CUDA_SEPARABLE_COMPILATION
+            \ CMAKE_CUDA_STANDARD
+            \ CMAKE_CUDA_STANDARD_REQUIRED
+            \ CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES
+            \ CMAKE_CURRENT_BINARY_DIR
+            \ CMAKE_CURRENT_LIST_DIR
+            \ CMAKE_CURRENT_LIST_FILE
+            \ CMAKE_CURRENT_LIST_LINE
+            \ CMAKE_CURRENT_SOURCE_DIR
+            \ CMAKE_CXX_COMPILE_FEATURES
+            \ CMAKE_CXX_EXTENSIONS
+            \ CMAKE_CXX_STANDARD
+            \ CMAKE_CXX_STANDARD_REQUIRED
+            \ CMAKE_C_COMPILE_FEATURES
+            \ CMAKE_C_EXTENSIONS
+            \ CMAKE_C_STANDARD
+            \ CMAKE_C_STANDARD_REQUIRED
+            \ CMAKE_DEBUG_POSTFIX
+            \ CMAKE_DEBUG_TARGET_PROPERTIES
+            \ CMAKE_DEPENDS_IN_PROJECT_ONLY
+            \ CMAKE_DIRECTORY_LABELS
+            \ CMAKE_DL_LIBS
+            \ CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION
+            \ CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
+            \ CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
+            \ CMAKE_ECLIPSE_MAKE_ARGUMENTS
+            \ CMAKE_ECLIPSE_VERSION
+            \ CMAKE_EDIT_COMMAND
+            \ CMAKE_ENABLE_EXPORTS
+            \ CMAKE_ERROR_DEPRECATED
+            \ CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
+            \ CMAKE_EXECUTABLE_SUFFIX
+            \ CMAKE_EXE_LINKER_FLAGS
+            \ CMAKE_EXE_LINKER_FLAGS_INIT
+            \ CMAKE_EXPORT_COMPILE_COMMANDS
+            \ CMAKE_EXPORT_NO_PACKAGE_REGISTRY
+            \ CMAKE_EXTRA_GENERATOR
+            \ CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES
+            \ CMAKE_FIND_APPBUNDLE
+            \ CMAKE_FIND_FRAMEWORK
+            \ CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX
+            \ CMAKE_FIND_LIBRARY_PREFIXES
+            \ CMAKE_FIND_LIBRARY_SUFFIXES
+            \ CMAKE_FIND_NO_INSTALL_PREFIX
+            \ CMAKE_FIND_PACKAGE_NAME
+            \ CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
+            \ CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
+            \ CMAKE_FIND_PACKAGE_SORT_DIRECTION
+            \ CMAKE_FIND_PACKAGE_SORT_ORDER
+            \ CMAKE_FIND_PACKAGE_WARN_NO_MODULE
+            \ CMAKE_FIND_ROOT_PATH
+            \ CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
+            \ CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
+            \ CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
+            \ CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
+            \ CMAKE_FOLDER
+            \ CMAKE_FRAMEWORK_PATH
+            \ CMAKE_Fortran_FORMAT
+            \ CMAKE_Fortran_MODDIR_DEFAULT
+            \ CMAKE_Fortran_MODDIR_FLAG
+            \ CMAKE_Fortran_MODOUT_FLAG
+            \ CMAKE_Fortran_MODULE_DIRECTORY
+            \ CMAKE_GENERATOR
+            \ CMAKE_GENERATOR_INSTANCE
+            \ CMAKE_GENERATOR_PLATFORM
+            \ CMAKE_GENERATOR_TOOLSET
+            \ CMAKE_GNUtoMS
+            \ CMAKE_HOME_DIRECTORY
+            \ CMAKE_HOST_APPLE
+            \ CMAKE_HOST_SOLARIS
+            \ CMAKE_HOST_SYSTEM
+            \ CMAKE_HOST_SYSTEM_NAME
+            \ CMAKE_HOST_SYSTEM_PROCESSOR
+            \ CMAKE_HOST_SYSTEM_VERSION
+            \ CMAKE_HOST_UNIX
+            \ CMAKE_HOST_WIN32
+            \ CMAKE_IGNORE_PATH
+            \ CMAKE_IMPORT_LIBRARY_PREFIX
+            \ CMAKE_IMPORT_LIBRARY_SUFFIX
+            \ CMAKE_INCLUDE_CURRENT_DIR
+            \ CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE
+            \ CMAKE_INCLUDE_DIRECTORIES_BEFORE
+            \ CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE
+            \ CMAKE_INCLUDE_PATH
+            \ CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
+            \ CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+            \ CMAKE_INSTALL_MESSAGE
+            \ CMAKE_INSTALL_NAME_DIR
+            \ CMAKE_INSTALL_PREFIX
+            \ CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
+            \ CMAKE_INSTALL_RPATH
+            \ CMAKE_INSTALL_RPATH_USE_LINK_PATH
+            \ CMAKE_INTERNAL_PLATFORM_ABI
+            \ CMAKE_INTERPROCEDURAL_OPTIMIZATION
+            \ CMAKE_IOS_INSTALL_COMBINED
+            \ CMAKE_JOB_POOLS
+            \ CMAKE_JOB_POOL_COMPILE
+            \ CMAKE_JOB_POOL_LINK
+            \ CMAKE_LIBRARY_ARCHITECTURE
+            \ CMAKE_LIBRARY_ARCHITECTURE_REGEX
+            \ CMAKE_LIBRARY_OUTPUT_DIRECTORY
+            \ CMAKE_LIBRARY_PATH
+            \ CMAKE_LIBRARY_PATH_FLAG
+            \ CMAKE_LINK_DEF_FILE_FLAG
+            \ CMAKE_LINK_DEPENDS_NO_SHARED
+            \ CMAKE_LINK_DIRECTORIES_BEFORE
+            \ CMAKE_LINK_INTERFACE_LIBRARIES
+            \ CMAKE_LINK_LIBRARY_FILE_FLAG
+            \ CMAKE_LINK_LIBRARY_FLAG
+            \ CMAKE_LINK_LIBRARY_SUFFIX
+            \ CMAKE_LINK_SEARCH_END_STATIC
+            \ CMAKE_LINK_SEARCH_START_STATIC
+            \ CMAKE_LINK_WHAT_YOU_USE
+            \ CMAKE_MACOSX_BUNDLE
+            \ CMAKE_MACOSX_RPATH
+            \ CMAKE_MAJOR_VERSION
+            \ CMAKE_MAKE_PROGRAM
+            \ CMAKE_MATCH_COUNT
+            \ CMAKE_MFC_FLAG
+            \ CMAKE_MINIMUM_REQUIRED_VERSION
+            \ CMAKE_MINOR_VERSION
+            \ CMAKE_MODULE_LINKER_FLAGS
+            \ CMAKE_MODULE_LINKER_FLAGS_INIT
+            \ CMAKE_MODULE_PATH
+            \ CMAKE_MSVCIDE_RUN_PATH
+            \ CMAKE_NETRC
+            \ CMAKE_NETRC_FILE
+            \ CMAKE_NINJA_OUTPUT_PATH_PREFIX
+            \ CMAKE_NOT_USING_CONFIG_FLAGS
+            \ CMAKE_NO_BUILTIN_CHRPATH
+            \ CMAKE_NO_SYSTEM_FROM_IMPORTED
+            \ CMAKE_OBJECT_PATH_MAX
+            \ CMAKE_OSX_ARCHITECTURES
+            \ CMAKE_OSX_DEPLOYMENT_TARGET
+            \ CMAKE_OSX_SYSROOT
+            \ CMAKE_PARENT_LIST_FILE
+            \ CMAKE_PATCH_VERSION
+            \ CMAKE_PDB_OUTPUT_DIRECTORY
+            \ CMAKE_POSITION_INDEPENDENT_CODE
+            \ CMAKE_PREFIX_PATH
+            \ CMAKE_PROGRAM_PATH
+            \ CMAKE_PROJECT_DESCRIPTION
+            \ CMAKE_PROJECT_HOMEPAGE_URL
+            \ CMAKE_PROJECT_NAME
+            \ CMAKE_PROJECT_VERSION
+            \ CMAKE_PROJECT_VERSION_MAJOR
+            \ CMAKE_PROJECT_VERSION_MINOR
+            \ CMAKE_PROJECT_VERSION_PATCH
+            \ CMAKE_PROJECT_VERSION_TWEAK
+            \ CMAKE_RANLIB
+            \ CMAKE_ROOT
+            \ CMAKE_RULE_MESSAGES
+            \ CMAKE_RUNTIME_OUTPUT_DIRECTORY
+            \ CMAKE_SCRIPT_MODE_FILE
+            \ CMAKE_SHARED_LIBRARY_PREFIX
+            \ CMAKE_SHARED_LIBRARY_SUFFIX
+            \ CMAKE_SHARED_LINKER_FLAGS
+            \ CMAKE_SHARED_LINKER_FLAGS_INIT
+            \ CMAKE_SHARED_MODULE_PREFIX
+            \ CMAKE_SHARED_MODULE_SUFFIX
+            \ CMAKE_SIZEOF_VOID_P
+            \ CMAKE_SKIP_BUILD_RPATH
+            \ CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
+            \ CMAKE_SKIP_INSTALL_RPATH
+            \ CMAKE_SKIP_INSTALL_RULES
+            \ CMAKE_SKIP_RPATH
+            \ CMAKE_SOURCE_DIR
+            \ CMAKE_STAGING_PREFIX
+            \ CMAKE_STATIC_LIBRARY_PREFIX
+            \ CMAKE_STATIC_LIBRARY_SUFFIX
+            \ CMAKE_STATIC_LINKER_FLAGS
+            \ CMAKE_STATIC_LINKER_FLAGS_INIT
+            \ CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
+            \ CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE
+            \ CMAKE_SUPPRESS_REGENERATION
+            \ CMAKE_SYSROOT
+            \ CMAKE_SYSROOT_COMPILE
+            \ CMAKE_SYSROOT_LINK
+            \ CMAKE_SYSTEM
+            \ CMAKE_SYSTEM_APPBUNDLE_PATH
+            \ CMAKE_SYSTEM_FRAMEWORK_PATH
+            \ CMAKE_SYSTEM_IGNORE_PATH
+            \ CMAKE_SYSTEM_INCLUDE_PATH
+            \ CMAKE_SYSTEM_LIBRARY_PATH
+            \ CMAKE_SYSTEM_NAME
+            \ CMAKE_SYSTEM_PREFIX_PATH
+            \ CMAKE_SYSTEM_PROCESSOR
+            \ CMAKE_SYSTEM_PROGRAM_PATH
+            \ CMAKE_SYSTEM_VERSION
+            \ CMAKE_Swift_LANGUAGE_VERSION
+            \ CMAKE_TOOLCHAIN_FILE
+            \ CMAKE_TRY_COMPILE_CONFIGURATION
+            \ CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
+            \ CMAKE_TRY_COMPILE_TARGET_TYPE
+            \ CMAKE_TWEAK_VERSION
+            \ CMAKE_USER_MAKE_RULES_OVERRIDE
+            \ CMAKE_USE_RELATIVE_PATHS
+            \ CMAKE_VERBOSE_MAKEFILE
+            \ CMAKE_VERSION
+            \ CMAKE_VISIBILITY_INLINES_HIDDEN
+            \ CMAKE_VS_DEVENV_COMMAND
+            \ CMAKE_VS_GLOBALS
+            \ CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
+            \ CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD
+            \ CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
+            \ CMAKE_VS_MSBUILD_COMMAND
+            \ CMAKE_VS_NsightTegra_VERSION
+            \ CMAKE_VS_PLATFORM_NAME
+            \ CMAKE_VS_PLATFORM_TOOLSET
+            \ CMAKE_VS_PLATFORM_TOOLSET_CUDA
+            \ CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
+            \ CMAKE_VS_PLATFORM_TOOLSET_VERSION
+            \ CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
+            \ CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES
+            \ CMAKE_VS_SDK_INCLUDE_DIRECTORIES
+            \ CMAKE_VS_SDK_LIBRARY_DIRECTORIES
+            \ CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES
+            \ CMAKE_VS_SDK_REFERENCE_DIRECTORIES
+            \ CMAKE_VS_SDK_SOURCE_DIRECTORIES
+            \ CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
+            \ CMAKE_VS_WINRT_BY_DEFAULT
+            \ CMAKE_WARN_DEPRECATED
+            \ CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
+            \ CMAKE_WIN32_EXECUTABLE
+            \ CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
+            \ CMAKE_XCODE_GENERATE_SCHEME
+            \ CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
+            \ CMAKE_XCODE_PLATFORM_TOOLSET
+            \ CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER
+            \ CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+            \ CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+            \ CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+            \ CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+            \ CMAKE_XCODE_SCHEME_GUARD_MALLOC
+            \ CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+            \ CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES
+            \ CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE
+            \ CMAKE_XCODE_SCHEME_MALLOC_STACK
+            \ CMAKE_XCODE_SCHEME_THREAD_SANITIZER
+            \ CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP
+            \ CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+            \ CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+            \ CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS
+            \ CPACK_ABSOLUTE_DESTINATION_FILES
+            \ CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY
+            \ CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
+            \ CPACK_INCLUDE_TOPLEVEL_DIRECTORY
+            \ CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+            \ CPACK_INSTALL_SCRIPT
+            \ CPACK_PACKAGING_INSTALL_PREFIX
+            \ CPACK_SET_DESTDIR
+            \ CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
+            \ CTEST_BINARY_DIRECTORY
+            \ CTEST_BUILD_COMMAND
+            \ CTEST_BUILD_NAME
+            \ CTEST_BZR_COMMAND
+            \ CTEST_BZR_UPDATE_OPTIONS
+            \ CTEST_CHANGE_ID
+            \ CTEST_CHECKOUT_COMMAND
+            \ CTEST_CONFIGURATION_TYPE
+            \ CTEST_CONFIGURE_COMMAND
+            \ CTEST_COVERAGE_COMMAND
+            \ CTEST_COVERAGE_EXTRA_FLAGS
+            \ CTEST_CURL_OPTIONS
+            \ CTEST_CUSTOM_COVERAGE_EXCLUDE
+            \ CTEST_CUSTOM_ERROR_EXCEPTION
+            \ CTEST_CUSTOM_ERROR_MATCH
+            \ CTEST_CUSTOM_ERROR_POST_CONTEXT
+            \ CTEST_CUSTOM_ERROR_PRE_CONTEXT
+            \ CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
+            \ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS
+            \ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS
+            \ CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
+            \ CTEST_CUSTOM_MEMCHECK_IGNORE
+            \ CTEST_CUSTOM_POST_MEMCHECK
+            \ CTEST_CUSTOM_POST_TEST
+            \ CTEST_CUSTOM_PRE_MEMCHECK
+            \ CTEST_CUSTOM_PRE_TEST
+            \ CTEST_CUSTOM_TEST_IGNORE
+            \ CTEST_CUSTOM_WARNING_EXCEPTION
+            \ CTEST_CUSTOM_WARNING_MATCH
+            \ CTEST_CVS_CHECKOUT
+            \ CTEST_CVS_COMMAND
+            \ CTEST_CVS_UPDATE_OPTIONS
+            \ CTEST_DROP_LOCATION
+            \ CTEST_DROP_METHOD
+            \ CTEST_DROP_SITE
+            \ CTEST_DROP_SITE_CDASH
+            \ CTEST_DROP_SITE_PASSWORD
+            \ CTEST_DROP_SITE_USER
+            \ CTEST_EXTRA_COVERAGE_GLOB
+            \ CTEST_GIT_COMMAND
+            \ CTEST_GIT_INIT_SUBMODULES
+            \ CTEST_GIT_UPDATE_CUSTOM
+            \ CTEST_GIT_UPDATE_OPTIONS
+            \ CTEST_HG_COMMAND
+            \ CTEST_HG_UPDATE_OPTIONS
+            \ CTEST_LABELS_FOR_SUBPROJECTS
+            \ CTEST_MEMORYCHECK_COMMAND
+            \ CTEST_MEMORYCHECK_COMMAND_OPTIONS
+            \ CTEST_MEMORYCHECK_SANITIZER_OPTIONS
+            \ CTEST_MEMORYCHECK_SUPPRESSIONS_FILE
+            \ CTEST_MEMORYCHECK_TYPE
+            \ CTEST_NIGHTLY_START_TIME
+            \ CTEST_P4_CLIENT
+            \ CTEST_P4_COMMAND
+            \ CTEST_P4_OPTIONS
+            \ CTEST_P4_UPDATE_OPTIONS
+            \ CTEST_RUN_CURRENT_SCRIPT
+            \ CTEST_SCP_COMMAND
+            \ CTEST_SITE
+            \ CTEST_SOURCE_DIRECTORY
+            \ CTEST_SVN_COMMAND
+            \ CTEST_SVN_OPTIONS
+            \ CTEST_SVN_UPDATE_OPTIONS
+            \ CTEST_TEST_LOAD
+            \ CTEST_TEST_TIMEOUT
+            \ CTEST_TRIGGER_SITE
+            \ CTEST_UPDATE_COMMAND
+            \ CTEST_UPDATE_OPTIONS
+            \ CTEST_UPDATE_VERSION_ONLY
+            \ CTEST_USE_LAUNCHERS
+            \ CYGWIN
+            \ ENV
+            \ EXECUTABLE_OUTPUT_PATH
+            \ GHS-MULTI
+            \ LIBRARY_OUTPUT_PATH
+            \ MINGW
+            \ MSVC
+            \ MSVC10
+            \ MSVC11
+            \ MSVC12
+            \ MSVC14
+            \ MSVC60
+            \ MSVC70
+            \ MSVC71
+            \ MSVC80
+            \ MSVC90
+            \ MSVC_IDE
+            \ MSVC_TOOLSET_VERSION
+            \ MSVC_VERSION
+            \ PROJECT_BINARY_DIR
+            \ PROJECT_DESCRIPTION
+            \ PROJECT_HOMEPAGE_URL
+            \ PROJECT_NAME
+            \ PROJECT_SOURCE_DIR
+            \ PROJECT_VERSION
+            \ PROJECT_VERSION_MAJOR
+            \ PROJECT_VERSION_MINOR
+            \ PROJECT_VERSION_PATCH
+            \ PROJECT_VERSION_TWEAK
+            \ UNIX
+            \ WIN32
+            \ WINCE
+            \ WINDOWS_PHONE
+            \ WINDOWS_STORE
+            \ XCODE
+            \ XCODE_VERSION
 
 syn keyword cmakeModule contained
             \ ExternalProject
 
 syn keyword cmakeKWExternalProject contained
-            \ ALGO AWS BINARY_DIR BUILD_ALWAYS BUILD_BYPRODUCTS BUILD_COMMAND BUILD_IN_SOURCE CMAKE_ARGS CMAKE_CACHE_ARGS CMAKE_CACHE_DEFAULT_ARGS CMAKE_TLS_CAINFO CMAKE_TLS_VERIFY COMMENT CONFIGURE_COMMAND CVS CVSROOT CVS_MODULE CVS_REPOSITORY CVS_TAG DEPENDEES DEPENDERS DEPENDS DOWNLOADED_FILE DOWNLOAD_COMMAND DOWNLOAD_DIR DOWNLOAD_NAME DOWNLOAD_NO_EXTRACT DOWNLOAD_NO_PROGRESS EP_BASE EP_INDEPENDENT_STEP_TARGETS EP_PREFIX EP_STEP_TARGETS EP_UPDATE_DISCONNECTED EXCLUDE_FROM_ALL FORCE GIT_CONFIG GIT_PROGRESS GIT_REMOTE_NAME GIT_REPOSITORY GIT_SHALLOW GIT_SUBMODULES GIT_TAG HG_REPOSITORY HG_TAG HTTP_HEADER HTTP_PASSWORD HTTP_USERNAME IGNORED INDEPENDENT_STEP_TARGETS INSTALL_COMMAND INSTALL_DIR JOB_POOLS LIST_SEPARATOR LOG_ LOG_BUILD LOG_CONFIGURE LOG_DOWNLOAD LOG_INSTALL LOG_TEST LOG_UPDATE MAKE_EXE NAMES NETRC NETRC_FILE NOTE NO_DEPENDS OPTIONAL PATCH_COMMAND PREFIX PROPERTY REQUIRED SOURCE_DIR SOURCE_SUBDIR STAMP_DIR STEP_TARGETS STRING SVN_PASSWORD SVN_REPOSITORY SVN_REVISION SVN_TRUST_CERT SVN_USERNAME TEST_AFTER_INSTALL TEST_BEFORE_INSTALL TEST_COMMAND TEST_EXCLUDE_FROM_MAIN TIMEOUT TLS_CAINFO TLS_VERIFY TMP_DIR TRUE UPDATE_COMMAND UPDATE_DISCONNECTED URL URL_HASH USES_TERMINAL_BUILD USES_TERMINAL_CONFIGURE USES_TERMINAL_DOWNLOAD USES_TERMINAL_INSTALL USES_TERMINAL_TEST USES_TERMINAL_UPDATE WORKING_DIRECTORY
+            \ AWS
+            \ BINARY_DIR
+            \ BUILD_ALWAYS
+            \ BUILD_BYPRODUCTS
+            \ BUILD_COMMAND
+            \ BUILD_IN_SOURCE
+            \ CMAKE_ARGS
+            \ CMAKE_CACHE_ARGS
+            \ CMAKE_CACHE_DEFAULT_ARGS
+            \ CMAKE_TLS_CAINFO
+            \ CMAKE_TLS_VERIFY
+            \ COMMENT
+            \ CONFIGURE_COMMAND
+            \ CVS
+            \ CVSROOT
+            \ CVS_MODULE
+            \ CVS_REPOSITORY
+            \ CVS_TAG
+            \ DEPENDEES
+            \ DEPENDERS
+            \ DEPENDS
+            \ DOWNLOADED_FILE
+            \ DOWNLOAD_COMMAND
+            \ DOWNLOAD_DIR
+            \ DOWNLOAD_NAME
+            \ DOWNLOAD_NO_EXTRACT
+            \ DOWNLOAD_NO_PROGRESS
+            \ EP_BASE
+            \ EP_INDEPENDENT_STEP_TARGETS
+            \ EP_PREFIX
+            \ EP_STEP_TARGETS
+            \ EP_UPDATE_DISCONNECTED
+            \ EXCLUDE_FROM_ALL
+            \ FORCE
+            \ GIT_CONFIG
+            \ GIT_PROGRESS
+            \ GIT_REMOTE_NAME
+            \ GIT_REPOSITORY
+            \ GIT_SHALLOW
+            \ GIT_SUBMODULES
+            \ GIT_TAG
+            \ HG_REPOSITORY
+            \ HG_TAG
+            \ HTTP_HEADER
+            \ HTTP_PASSWORD
+            \ HTTP_USERNAME
+            \ IGNORED
+            \ INDEPENDENT_STEP_TARGETS
+            \ INSTALL_COMMAND
+            \ INSTALL_DIR
+            \ JOB_POOLS
+            \ LIST_SEPARATOR
+            \ LOG_
+            \ LOG_BUILD
+            \ LOG_CONFIGURE
+            \ LOG_DOWNLOAD
+            \ LOG_INSTALL
+            \ LOG_TEST
+            \ LOG_UPDATE
+            \ MAKE_EXE
+            \ NAMES
+            \ NETRC
+            \ NETRC_FILE
+            \ NOTE
+            \ NO_DEPENDS
+            \ OPTIONAL
+            \ PATCH_COMMAND
+            \ PREFIX
+            \ PROPERTY
+            \ REQUIRED
+            \ SOURCE_DIR
+            \ SOURCE_SUBDIR
+            \ STAMP_DIR
+            \ STEP_TARGETS
+            \ STRING
+            \ SVN_PASSWORD
+            \ SVN_REPOSITORY
+            \ SVN_REVISION
+            \ SVN_TRUST_CERT
+            \ SVN_USERNAME
+            \ TEST_AFTER_INSTALL
+            \ TEST_BEFORE_INSTALL
+            \ TEST_COMMAND
+            \ TEST_EXCLUDE_FROM_MAIN
+            \ TIMEOUT
+            \ TLS_CAINFO
+            \ TLS_VERIFY
+            \ TMP_DIR
+            \ TRUE
+            \ UPDATE_COMMAND
+            \ UPDATE_DISCONNECTED
+            \ URL
+            \ URL_HASH
+            \ USES_TERMINAL_BUILD
+            \ USES_TERMINAL_CONFIGURE
+            \ USES_TERMINAL_DOWNLOAD
+            \ USES_TERMINAL_INSTALL
+            \ USES_TERMINAL_TEST
+            \ USES_TERMINAL_UPDATE
+            \ WORKING_DIRECTORY
+
+syn keyword cmakeKWadd_compile_definitions contained
+            \ COMPILE_DEFINITIONS
+            \ VAR
 
 syn keyword cmakeKWadd_compile_options contained
             \ COMPILE_OPTIONS
+            \ SHELL
+            \ UNIX_COMMAND
 
 syn keyword cmakeKWadd_custom_command contained
-            \ APPEND ARGS BYPRODUCTS CC COMMAND COMMAND_EXPAND_LISTS COMMENT CROSSCOMPILING_EMULATOR DEPENDS DEPFILE GENERATED IMPLICIT_DEPENDS INCLUDE_DIRECTORIES JOIN MAIN_DEPENDENCY NOT OUTPUT POST_BUILD PRE_BUILD PRE_LINK SYMBOLIC TARGET_FILE TARGET_PROPERTY USES_TERMINAL VERBATIM WORKING_DIRECTORY
+            \ APPEND
+            \ ARGS
+            \ BYPRODUCTS
+            \ CC
+            \ COMMAND
+            \ COMMAND_EXPAND_LISTS
+            \ COMMENT
+            \ CROSSCOMPILING_EMULATOR
+            \ DEPENDS
+            \ DEPFILE
+            \ GENERATED
+            \ IMPLICIT_DEPENDS
+            \ INCLUDE_DIRECTORIES
+            \ JOIN
+            \ MAIN_DEPENDENCY
+            \ NOT
+            \ OUTPUT
+            \ POST_BUILD
+            \ PRE_BUILD
+            \ PRE_LINK
+            \ SYMBOLIC
+            \ TARGET_FILE
+            \ TARGET_PROPERTY
+            \ USES_TERMINAL
+            \ VERBATIM
+            \ WORKING_DIRECTORY
 
 syn keyword cmakeKWadd_custom_target contained
-            \ ALL BYPRODUCTS CC COMMAND COMMAND_EXPAND_LISTS COMMENT CROSSCOMPILING_EMULATOR DEPENDS GENERATED INCLUDE_DIRECTORIES JOIN SOURCES TARGET_PROPERTY USES_TERMINAL VERBATIM WORKING_DIRECTORY
+            \ ALL
+            \ BYPRODUCTS
+            \ CC
+            \ COMMAND
+            \ COMMAND_EXPAND_LISTS
+            \ COMMENT
+            \ CROSSCOMPILING_EMULATOR
+            \ DEPENDS
+            \ GENERATED
+            \ INCLUDE_DIRECTORIES
+            \ JOIN
+            \ SOURCES
+            \ TARGET_PROPERTY
+            \ USES_TERMINAL
+            \ VERBATIM
+            \ WORKING_DIRECTORY
 
 syn keyword cmakeKWadd_definitions contained
             \ COMPILE_DEFINITIONS
 
 syn keyword cmakeKWadd_dependencies contained
-            \ DEPENDS OBJECT_DEPENDS
+            \ DEPENDS
+            \ OBJECT_DEPENDS
 
 syn keyword cmakeKWadd_executable contained
-            \ ALIAS CONFIG EXCLUDE_FROM_ALL GLOBAL HEADER_FILE_ONLY IMPORTED IMPORTED_ IMPORTED_LOCATION IMPORTED_LOCATION_ MACOSX_BUNDLE OUTPUT_NAME RUNTIME_OUTPUT_DIRECTORY TARGET
+            \ ALIAS
+            \ CONFIG
+            \ EXCLUDE_FROM_ALL
+            \ GLOBAL
+            \ HEADER_FILE_ONLY
+            \ IMPORTED
+            \ IMPORTED_
+            \ IMPORTED_LOCATION
+            \ IMPORTED_LOCATION_
+            \ MACOSX_BUNDLE
+            \ OUTPUT_NAME
+            \ RUNTIME_OUTPUT_DIRECTORY
+            \ TARGET
 
 syn keyword cmakeKWadd_library contained
-            \ ALIAS ARCHIVE_OUTPUT_DIRECTORY CLI CONFIG DLL EXCLUDE_FROM_ALL FRAMEWORK GLOBAL HEADER_FILE_ONLY IMPORTED IMPORTED_ IMPORTED_LOCATION IMPORTED_LOCATION_ INTERFACE_ LIBRARY_OUTPUT_DIRECTORY MODULE OBJECT ON OUTPUT_NAME POSITION_INDEPENDENT_CODE POST_BUILD PRE_BUILD PRE_LINK RUNTIME_OUTPUT_DIRECTORY SHARED STATIC TARGET_OBJECTS UNKNOWN
+            \ ALIAS
+            \ ARCHIVE_OUTPUT_DIRECTORY
+            \ CLI
+            \ CONFIG
+            \ DLL
+            \ EXCLUDE_FROM_ALL
+            \ FRAMEWORK
+            \ GLOBAL
+            \ HEADER_FILE_ONLY
+            \ IMPORTED
+            \ IMPORTED_
+            \ IMPORTED_LOCATION
+            \ IMPORTED_LOCATION_
+            \ IMPORTED_OBJECTS
+            \ IMPORTED_OBJECTS_
+            \ INTERFACE_
+            \ LIBRARY_OUTPUT_DIRECTORY
+            \ MODULE
+            \ OBJECT
+            \ ON
+            \ OUTPUT_NAME
+            \ POSITION_INDEPENDENT_CODE
+            \ POST_BUILD
+            \ PRE_BUILD
+            \ PRE_LINK
+            \ RUNTIME_OUTPUT_DIRECTORY
+            \ SHARED
+            \ STATIC
+            \ TARGET_OBJECTS
+            \ UNKNOWN
+
+syn keyword cmakeKWadd_link_options contained
+            \ CMAKE_
+            \ GCC
+            \ GNU
+            \ LANG
+            \ LINKER
+            \ LINK_OPTIONS
+            \ SHELL
+            \ UNIX_COMMAND
+            \ _LINKER_WRAPPER_FLAG
+            \ _LINKER_WRAPPER_FLAG_SEP
 
 syn keyword cmakeKWadd_subdirectory contained
             \ EXCLUDE_FROM_ALL
 
 syn keyword cmakeKWadd_test contained
-            \ BUILD_TESTING COMMAND CONFIGURATIONS FAIL_REGULAR_EXPRESSION NAME PASS_REGULAR_EXPRESSION TARGET_FILE WILL_FAIL WORKING_DIRECTORY
+            \ BUILD_TESTING
+            \ COMMAND
+            \ CONFIGURATIONS
+            \ FAIL_REGULAR_EXPRESSION
+            \ NAME
+            \ PASS_REGULAR_EXPRESSION
+            \ TARGET_FILE
+            \ WILL_FAIL
+            \ WORKING_DIRECTORY
 
 syn keyword cmakeKWbuild_command contained
-            \ CONFIGURATION TARGET
+            \ CONFIGURATION
+            \ TARGET
 
 syn keyword cmakeKWbuild_name contained
             \ CMAKE_CXX_COMPILER
 
 syn keyword cmakeKWcmake_host_system_information contained
-            \ AVAILABLE_PHYSICAL_MEMORY AVAILABLE_VIRTUAL_MEMORY FQDN HAS_FPU HAS_MMX HAS_MMX_PLUS HAS_SERIAL_NUMBER HAS_SSE HAS_SSE_FP HAS_SSE_MMX HOSTNAME ID NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES OS_NAME OS_PLATFORM OS_RELEASE OS_VERSION PROCESSOR_DESCRIPTION PROCESSOR_NAME PROCESSOR_SERIAL_NUMBER QUERY RESULT TOTAL_PHYSICAL_MEMORY TOTAL_VIRTUAL_MEMORY
+            \ AVAILABLE_PHYSICAL_MEMORY
+            \ AVAILABLE_VIRTUAL_MEMORY
+            \ FQDN
+            \ HAS_FPU
+            \ HAS_MMX
+            \ HAS_MMX_PLUS
+            \ HAS_SERIAL_NUMBER
+            \ HAS_SSE
+            \ HAS_SSE_FP
+            \ HAS_SSE_MMX
+            \ HOSTNAME
+            \ ID
+            \ NUMBER_OF_LOGICAL_CORES
+            \ NUMBER_OF_PHYSICAL_CORES
+            \ OS_NAME
+            \ OS_PLATFORM
+            \ OS_RELEASE
+            \ OS_VERSION
+            \ PROCESSOR_DESCRIPTION
+            \ PROCESSOR_NAME
+            \ PROCESSOR_SERIAL_NUMBER
+            \ QUERY
+            \ RESULT
+            \ TOTAL_PHYSICAL_MEMORY
+            \ TOTAL_VIRTUAL_MEMORY
 
 syn keyword cmakeKWcmake_minimum_required contained
-            \ FATAL_ERROR VERSION
+            \ FATAL_ERROR
+            \ VERSION
 
 syn keyword cmakeKWcmake_parse_arguments contained
-            \ ARGN CONFIGURATIONS DESTINATION FALSE FAST FILES MY_INSTALL MY_INSTALL_CONFIGURATIONS MY_INSTALL_DESTINATION MY_INSTALL_FAST MY_INSTALL_OPTIONAL MY_INSTALL_RENAME MY_INSTALL_TARGETS MY_INSTALL_UNPARSED_ARGUMENTS OPTIONAL PARSE_ARGV RENAME TARGETS TRUE UNDEFINED _UNPARSED_ARGUMENTS
+            \ ARGN
+            \ CONFIGURATIONS
+            \ DESTINATION
+            \ FALSE
+            \ FAST
+            \ FILES
+            \ MY_INSTALL
+            \ MY_INSTALL_CONFIGURATIONS
+            \ MY_INSTALL_DESTINATION
+            \ MY_INSTALL_FAST
+            \ MY_INSTALL_OPTIONAL
+            \ MY_INSTALL_RENAME
+            \ MY_INSTALL_TARGETS
+            \ MY_INSTALL_UNPARSED_ARGUMENTS
+            \ OPTIONAL
+            \ PARSE_ARGV
+            \ RENAME
+            \ TARGETS
+            \ TRUE
+            \ UNDEFINED
+            \ _UNPARSED_ARGUMENTS
 
 syn keyword cmakeKWcmake_policy contained
-            \ CMAKE_POLICY_DEFAULT_CMP CMP GET NNNN NO_POLICY_SCOPE OLD POP PUSH SET VERSION
+            \ CMAKE_POLICY_DEFAULT_CMP
+            \ CMP
+            \ GET
+            \ NNNN
+            \ NO_POLICY_SCOPE
+            \ OLD
+            \ POP
+            \ PUSH
+            \ SET
+            \ VERSION
 
 syn keyword cmakeKWconfigure_file contained
-            \ COPYONLY CRLF DOS ESCAPE_QUOTES FOO_ENABLE FOO_STRING LF NEWLINE_STYLE VAR
+            \ COPYONLY
+            \ CRLF
+            \ DOS
+            \ ESCAPE_QUOTES
+            \ FOO_ENABLE
+            \ FOO_STRING
+            \ LF
+            \ NEWLINE_STYLE
+            \ VAR
 
 syn keyword cmakeKWcreate_test_sourcelist contained
-            \ CMAKE_TESTDRIVER_AFTER_TESTMAIN CMAKE_TESTDRIVER_BEFORE_TESTMAIN EXTRA_INCLUDE FUNCTION
+            \ CMAKE_TESTDRIVER_AFTER_TESTMAIN
+            \ CMAKE_TESTDRIVER_BEFORE_TESTMAIN
+            \ EXTRA_INCLUDE
+            \ FUNCTION
 
 syn keyword cmakeKWctest_build contained
-            \ ALL_BUILD APPEND BUILD CAPTURE_CMAKE_ERROR CONFIGURATION CTEST_BUILD_CONFIGURATION CTEST_BUILD_FLAGS CTEST_BUILD_TARGET CTEST_PROJECT_NAME FLAGS NUMBER_ERRORS NUMBER_WARNINGS QUIET RETURN_VALUE TARGET
+            \ ALL_BUILD
+            \ APPEND
+            \ BUILD
+            \ CAPTURE_CMAKE_ERROR
+            \ CONFIGURATION
+            \ CTEST_BUILD_CONFIGURATION
+            \ CTEST_BUILD_FLAGS
+            \ CTEST_BUILD_TARGET
+            \ CTEST_PROJECT_NAME
+            \ FLAGS
+            \ NUMBER_ERRORS
+            \ NUMBER_WARNINGS
+            \ QUIET
+            \ RETURN_VALUE
+            \ TARGET
 
 syn keyword cmakeKWctest_configure contained
-            \ APPEND BUILD CAPTURE_CMAKE_ERROR OPTIONS QUIET RETURN_VALUE SOURCE
+            \ APPEND
+            \ BUILD
+            \ CAPTURE_CMAKE_ERROR
+            \ OPTIONS
+            \ QUIET
+            \ RETURN_VALUE
+            \ SOURCE
 
 syn keyword cmakeKWctest_coverage contained
-            \ APPEND BUILD CAPTURE_CMAKE_ERROR LABELS QUIET RETURN_VALUE
+            \ APPEND
+            \ BUILD
+            \ CAPTURE_CMAKE_ERROR
+            \ LABELS
+            \ QUIET
+            \ RETURN_VALUE
 
 syn keyword cmakeKWctest_memcheck contained
-            \ APPEND BUILD CAPTURE_CMAKE_ERROR DEFECT_COUNT EXCLUDE EXCLUDE_FIXTURE EXCLUDE_FIXTURE_CLEANUP EXCLUDE_FIXTURE_SETUP EXCLUDE_LABEL INCLUDE INCLUDE_LABEL OFF ON PARALLEL_LEVEL QUIET RETURN_VALUE SCHEDULE_RANDOM START STOP_TIME STRIDE TEST_LOAD
+            \ APPEND
+            \ BUILD
+            \ DEFECT_COUNT
+            \ EXCLUDE
+            \ EXCLUDE_FIXTURE
+            \ EXCLUDE_FIXTURE_CLEANUP
+            \ EXCLUDE_FIXTURE_SETUP
+            \ EXCLUDE_LABEL
+            \ INCLUDE
+            \ INCLUDE_LABEL
+            \ OFF
+            \ ON
+            \ PARALLEL_LEVEL
+            \ QUIET
+            \ RETURN_VALUE
+            \ SCHEDULE_RANDOM
+            \ START
+            \ STOP_TIME
+            \ STRIDE
+            \ TEST_LOAD
 
 syn keyword cmakeKWctest_run_script contained
-            \ NEW_PROCESS RETURN_VALUE
+            \ NEW_PROCESS
+            \ RETURN_VALUE
 
 syn keyword cmakeKWctest_start contained
-            \ APPEND QUIET TAG TRACK
+            \ APPEND
+            \ QUIET
+            \ TAG
+            \ TRACK
 
 syn keyword cmakeKWctest_submit contained
-            \ API CAPTURE_CMAKE_ERROR CDASH_UPLOAD CDASH_UPLOAD_TYPE CTEST_EXTRA_SUBMIT_FILES CTEST_NOTES_FILES FILES HTTPHEADER PARTS QUIET RETRY_COUNT RETRY_DELAY RETURN_VALUE
+            \ API
+            \ CAPTURE_CMAKE_ERROR
+            \ CDASH_UPLOAD
+            \ CDASH_UPLOAD_TYPE
+            \ CTEST_EXTRA_SUBMIT_FILES
+            \ CTEST_NOTES_FILES
+            \ FILES
+            \ HTTPHEADER
+            \ PARTS
+            \ QUIET
+            \ RETRY_COUNT
+            \ RETRY_DELAY
+            \ RETURN_VALUE
 
 syn keyword cmakeKWctest_test contained
-            \ APPEND BUILD CAPTURE_CMAKE_ERROR CPU EXCLUDE EXCLUDE_FIXTURE EXCLUDE_FIXTURE_CLEANUP EXCLUDE_FIXTURE_SETUP EXCLUDE_LABEL INCLUDE INCLUDE_LABEL OFF ON PARALLEL_LEVEL QUIET RETURN_VALUE SCHEDULE_RANDOM START STOP_TIME STRIDE TEST_LOAD
+            \ APPEND
+            \ BUILD
+            \ CAPTURE_CMAKE_ERROR
+            \ CPU
+            \ EXCLUDE
+            \ EXCLUDE_FIXTURE
+            \ EXCLUDE_FIXTURE_CLEANUP
+            \ EXCLUDE_FIXTURE_SETUP
+            \ EXCLUDE_LABEL
+            \ INCLUDE
+            \ INCLUDE_LABEL
+            \ OFF
+            \ ON
+            \ PARALLEL_LEVEL
+            \ QUIET
+            \ RETURN_VALUE
+            \ SCHEDULE_RANDOM
+            \ START
+            \ STOP_TIME
+            \ STRIDE
+            \ TEST_LOAD
 
 syn keyword cmakeKWctest_update contained
-            \ CAPTURE_CMAKE_ERROR QUIET RETURN_VALUE SOURCE
+            \ CAPTURE_CMAKE_ERROR
+            \ QUIET
+            \ RETURN_VALUE
+            \ SOURCE
 
 syn keyword cmakeKWctest_upload contained
-            \ CAPTURE_CMAKE_ERROR FILES QUIET
+            \ CAPTURE_CMAKE_ERROR
+            \ FILES
+            \ QUIET
 
 syn keyword cmakeKWdefine_property contained
-            \ BRIEF_DOCS CACHED_VARIABLE DIRECTORY FULL_DOCS GLOBAL INHERITED PROPERTY SOURCE TARGET TEST VARIABLE
+            \ APPEND
+            \ APPEND_STRING
+            \ BRIEF_DOCS
+            \ CACHED_VARIABLE
+            \ DIRECTORY
+            \ FULL_DOCS
+            \ GLOBAL
+            \ INHERITED
+            \ PROPERTY
+            \ SOURCE
+            \ TARGET
+            \ TEST
+            \ VARIABLE
 
 syn keyword cmakeKWenable_language contained
+            \ ASM
+            \ CUDA
             \ OPTIONAL
 
 syn keyword cmakeKWexec_program contained
-            \ ARGS OUTPUT_VARIABLE RETURN_VALUE
+            \ ARGS
+            \ OUTPUT_VARIABLE
+            \ RETURN_VALUE
 
 syn keyword cmakeKWexecute_process contained
-            \ ANSI AUTO COMMAND ENCODING ERROR_FILE ERROR_QUIET ERROR_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE INPUT_FILE NONE OEM OUTPUT_FILE OUTPUT_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE RESULTS_VARIABLE RESULT_VARIABLE TIMEOUT UTF VERBATIM WORKING_DIRECTORY
+            \ ANSI
+            \ AUTO
+            \ COMMAND
+            \ ENCODING
+            \ ERROR_FILE
+            \ ERROR_QUIET
+            \ ERROR_STRIP_TRAILING_WHITESPACE
+            \ ERROR_VARIABLE
+            \ INPUT_FILE
+            \ NONE
+            \ OEM
+            \ OUTPUT_FILE
+            \ OUTPUT_QUIET
+            \ OUTPUT_STRIP_TRAILING_WHITESPACE
+            \ OUTPUT_VARIABLE
+            \ RESULTS_VARIABLE
+            \ RESULT_VARIABLE
+            \ RFC
+            \ TIMEOUT
+            \ UTF
+            \ VERBATIM
+            \ WORKING_DIRECTORY
 
 syn keyword cmakeKWexport contained
-            \ ANDROID_MK APPEND CONFIG EXPORT EXPORT_LINK_INTERFACE_LIBRARIES FILE IMPORTED IMPORTED_ NAMESPACE NDK OLD PACKAGE TARGETS
+            \ ANDROID_MK
+            \ APPEND
+            \ CONFIG
+            \ EXPORT
+            \ EXPORT_LINK_INTERFACE_LIBRARIES
+            \ FILE
+            \ IMPORTED
+            \ IMPORTED_
+            \ NAMESPACE
+            \ NDK
+            \ OLD
+            \ PACKAGE
+            \ TARGETS
 
 syn keyword cmakeKWexport_library_dependencies contained
-            \ APPEND EXPORT INCLUDE LINK_INTERFACE_LIBRARIES SET
+            \ APPEND
+            \ EXPORT
+            \ INCLUDE
+            \ LINK_INTERFACE_LIBRARIES
+            \ SET
 
 syn keyword cmakeKWfile contained
-            \ ALGO APPEND ASCII CMAKE_TLS_CAINFO CMAKE_TLS_VERIFY CONDITION CONFIG CONTENT COPY CR DESTINATION DIRECTORY_PERMISSIONS DOWNLOAD ENCODING EXCLUDE EXPECTED_HASH FILES_MATCHING FILE_PERMISSIONS FOLLOW_SYMLINKS FUNCTION GENERATE GLOB GLOB_RECURSE GUARD HASH HEX HTTPHEADER IGNORED INACTIVITY_TIMEOUT INSTALL LENGTH_MAXIMUM LENGTH_MINIMUM LF LIMIT LIMIT_COUNT LIMIT_INPUT LIMIT_OUTPUT LIST_DIRECTORIES LOCK LOG MAKE_DIRECTORY NETRC NETRC_FILE NEWLINE_CONSUME NO_HEX_CONVERSION NO_SOURCE_PERMISSIONS OFFSET OLD OPTIONAL PATTERN PROCESS READ REGEX RELATIVE RELATIVE_PATH RELEASE REMOVE REMOVE_RECURSE RENAME REQUIRED RESULT_VARIABLE SHOW_PROGRESS SSL STATUS STRINGS TIMESTAMP TLS_CAINFO TLS_VERIFY TO_CMAKE_PATH TO_NATIVE_PATH UPLOAD URL USERPWD USE_SOURCE_PERMISSIONS UTC UTF WRITE
+            \ ALGO
+            \ APPEND
+            \ ASCII
+            \ CMAKE_TLS_CAINFO
+            \ CMAKE_TLS_VERIFY
+            \ CONDITION
+            \ CONFIG
+            \ CONFIGURE_DEPENDS
+            \ CONTENT
+            \ COPY
+            \ DESTINATION
+            \ DIRECTORY_PERMISSIONS
+            \ DOWNLOAD
+            \ ENCODING
+            \ EXCLUDE
+            \ EXPECTED_HASH
+            \ FILES_MATCHING
+            \ FILE_PERMISSIONS
+            \ FOLLOW_SYMLINKS
+            \ FUNCTION
+            \ GENERATE
+            \ GLOB
+            \ GLOB_RECURSE
+            \ GUARD
+            \ HASH
+            \ HEX
+            \ HTTPHEADER
+            \ IGNORED
+            \ INACTIVITY_TIMEOUT
+            \ INSTALL
+            \ LENGTH_MAXIMUM
+            \ LENGTH_MINIMUM
+            \ LF
+            \ LIMIT
+            \ LIMIT_COUNT
+            \ LIMIT_INPUT
+            \ LIMIT_OUTPUT
+            \ LIST_DIRECTORIES
+            \ LOCK
+            \ LOG
+            \ MAKE_DIRECTORY
+            \ NETRC
+            \ NETRC_FILE
+            \ NEWLINE_CONSUME
+            \ NO_HEX_CONVERSION
+            \ NO_SOURCE_PERMISSIONS
+            \ OFFSET
+            \ OLD
+            \ OPTIONAL
+            \ OUTPUT
+            \ PATTERN
+            \ PROCESS
+            \ READ
+            \ REGEX
+            \ RELATIVE_PATH
+            \ RELEASE
+            \ REMOVE
+            \ REMOVE_RECURSE
+            \ RENAME
+            \ REQUIRED
+            \ RESULT_VARIABLE
+            \ SHOW_PROGRESS
+            \ SSL
+            \ STATUS
+            \ STRINGS
+            \ TIMESTAMP
+            \ TLS_CAINFO
+            \ TLS_VERIFY
+            \ TOUCH
+            \ TOUCH_NOCREATE
+            \ TO_CMAKE_PATH
+            \ TO_NATIVE_PATH
+            \ UPLOAD
+            \ URL
+            \ USERPWD
+            \ USE_SOURCE_PERMISSIONS
+            \ UTC
+            \ UTF
+            \ WRITE
 
 syn keyword cmakeKWfind_file contained
-            \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS INCLUDE NAMES NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+            \ CMAKE_FIND_ROOT_PATH_BOTH
+            \ DOC
+            \ DVAR
+            \ HINTS
+            \ INCLUDE
+            \ NAMES
+            \ NO_CMAKE_ENVIRONMENT_PATH
+            \ NO_CMAKE_FIND_ROOT_PATH
+            \ NO_CMAKE_PATH
+            \ NO_CMAKE_SYSTEM_PATH
+            \ NO_DEFAULT_PATH
+            \ NO_PACKAGE_ROOT_PATH
+            \ NO_SYSTEM_ENVIRONMENT_PATH
+            \ ONLY_CMAKE_FIND_ROOT_PATH
+            \ PATHS
+            \ PATH_SUFFIXES
+            \ VAR
 
 syn keyword cmakeKWfind_library contained
-            \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS LIB NAMES NAMES_PER_DIR NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+            \ CMAKE_FIND_ROOT_PATH_BOTH
+            \ DOC
+            \ DVAR
+            \ HINTS
+            \ LIB
+            \ NAMES
+            \ NAMES_PER_DIR
+            \ NO_CMAKE_ENVIRONMENT_PATH
+            \ NO_CMAKE_FIND_ROOT_PATH
+            \ NO_CMAKE_PATH
+            \ NO_CMAKE_SYSTEM_PATH
+            \ NO_DEFAULT_PATH
+            \ NO_PACKAGE_ROOT_PATH
+            \ NO_SYSTEM_ENVIRONMENT_PATH
+            \ ONLY_CMAKE_FIND_ROOT_PATH
+            \ PATHS
+            \ PATH_SUFFIXES
+            \ VAR
 
 syn keyword cmakeKWfind_package contained
-            \ CMAKE_DISABLE_FIND_PACKAGE_ CMAKE_FIND_ROOT_PATH_BOTH COMPONENTS CONFIG CONFIGS DEC DVAR EXACT HINTS MODULE NAMES NATURAL NO_CMAKE_BUILDS_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_PATH NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_MODULE NO_POLICY_SCOPE NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OPTIONAL_COMPONENTS OS PACKAGE_FIND_NAME PACKAGE_FIND_VERSION PACKAGE_FIND_VERSION_COUNT PACKAGE_FIND_VERSION_MAJOR PACKAGE_FIND_VERSION_MINOR PACKAGE_FIND_VERSION_PATCH PACKAGE_FIND_VERSION_TWEAK PACKAGE_VERSION PACKAGE_VERSION_COMPATIBLE PACKAGE_VERSION_EXACT PACKAGE_VERSION_UNSUITABLE PATHS PATH_SUFFIXES QUIET REQUIRED SET TRUE _CONFIG _CONSIDERED_CONFIGS _CONSIDERED_VERSIONS _DIR _FIND_COMPONENTS _FIND_QUIETLY _FIND_REQUIRED _FIND_REQUIRED_ _FIND_VERSION_EXACT _FOUND
+            \ ABI
+            \ CMAKE_DISABLE_FIND_PACKAGE_
+            \ CMAKE_FIND_ROOT_PATH_BOTH
+            \ COMPONENTS
+            \ CONFIG
+            \ CONFIGS
+            \ DEC
+            \ DVAR
+            \ EXACT
+            \ HINTS
+            \ MODULE
+            \ NAMES
+            \ NATURAL
+            \ NO_CMAKE_BUILDS_PATH
+            \ NO_CMAKE_ENVIRONMENT_PATH
+            \ NO_CMAKE_FIND_ROOT_PATH
+            \ NO_CMAKE_PACKAGE_REGISTRY
+            \ NO_CMAKE_PATH
+            \ NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
+            \ NO_CMAKE_SYSTEM_PATH
+            \ NO_DEFAULT_PATH
+            \ NO_MODULE
+            \ NO_PACKAGE_ROOT_PATH
+            \ NO_POLICY_SCOPE
+            \ NO_SYSTEM_ENVIRONMENT_PATH
+            \ ONLY_CMAKE_FIND_ROOT_PATH
+            \ OPTIONAL_COMPONENTS
+            \ PACKAGE_FIND_NAME
+            \ PACKAGE_FIND_VERSION
+            \ PACKAGE_FIND_VERSION_COUNT
+            \ PACKAGE_FIND_VERSION_MAJOR
+            \ PACKAGE_FIND_VERSION_MINOR
+            \ PACKAGE_FIND_VERSION_PATCH
+            \ PACKAGE_FIND_VERSION_TWEAK
+            \ PACKAGE_VERSION
+            \ PACKAGE_VERSION_COMPATIBLE
+            \ PACKAGE_VERSION_EXACT
+            \ PACKAGE_VERSION_UNSUITABLE
+            \ PATHS
+            \ PATH_SUFFIXES
+            \ QUIET
+            \ REQUIRED
+            \ SET
+            \ TRUE
+            \ _CONFIG
+            \ _CONSIDERED_CONFIGS
+            \ _CONSIDERED_VERSIONS
+            \ _DIR
+            \ _FIND_COMPONENTS
+            \ _FIND_QUIETLY
+            \ _FIND_REQUIRED
+            \ _FIND_REQUIRED_
+            \ _FIND_VERSION_EXACT
+            \ _FOUND
 
 syn keyword cmakeKWfind_path contained
-            \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS INCLUDE NAMES NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+            \ CMAKE_FIND_ROOT_PATH_BOTH
+            \ DOC
+            \ DVAR
+            \ HINTS
+            \ INCLUDE
+            \ NAMES
+            \ NO_CMAKE_ENVIRONMENT_PATH
+            \ NO_CMAKE_FIND_ROOT_PATH
+            \ NO_CMAKE_PATH
+            \ NO_CMAKE_SYSTEM_PATH
+            \ NO_DEFAULT_PATH
+            \ NO_PACKAGE_ROOT_PATH
+            \ NO_SYSTEM_ENVIRONMENT_PATH
+            \ ONLY_CMAKE_FIND_ROOT_PATH
+            \ PATHS
+            \ PATH_SUFFIXES
+            \ VAR
 
 syn keyword cmakeKWfind_program contained
-            \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS NAMES NAMES_PER_DIR NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+            \ CMAKE_FIND_ROOT_PATH_BOTH
+            \ DOC
+            \ DVAR
+            \ HINTS
+            \ NAMES
+            \ NAMES_PER_DIR
+            \ NO_CMAKE_ENVIRONMENT_PATH
+            \ NO_CMAKE_FIND_ROOT_PATH
+            \ NO_CMAKE_PATH
+            \ NO_CMAKE_SYSTEM_PATH
+            \ NO_DEFAULT_PATH
+            \ NO_PACKAGE_ROOT_PATH
+            \ NO_SYSTEM_ENVIRONMENT_PATH
+            \ ONLY_CMAKE_FIND_ROOT_PATH
+            \ PATHS
+            \ PATH_SUFFIXES
+            \ VAR
 
 syn keyword cmakeKWfltk_wrap_ui contained
             \ FLTK
 
 syn keyword cmakeKWforeach contained
-            \ ARGS IN ITEMS LISTS RANGE
+            \ ARGS
+            \ IN
+            \ ITEMS
+            \ LISTS
+            \ RANGE
 
 syn keyword cmakeKWfunction contained
-            \ ARGC ARGN ARGS ARGV PARENT_SCOPE
+            \ ARGC
+            \ ARGN
+            \ ARGS
+            \ ARGV
+            \ PARENT_SCOPE
 
 syn keyword cmakeKWget_cmake_property contained
-            \ COMPONENTS GLOBAL MACROS VAR VARIABLES
+            \ COMPONENTS
+            \ GLOBAL
+            \ MACROS
+            \ VAR
+            \ VARIABLES
 
 syn keyword cmakeKWget_directory_property contained
-            \ DEFINITION DIRECTORY
+            \ DEFINITION
+            \ DIRECTORY
+            \ INHERITED
 
 syn keyword cmakeKWget_filename_component contained
-            \ ABSOLUTE ARG_VAR BASE_DIR CACHE COMP DIRECTORY EXT NAME NAME_WE PATH PROGRAM PROGRAM_ARGS REALPATH VAR
+            \ ABSOLUTE
+            \ ARG_VAR
+            \ BASE_DIR
+            \ COMP
+            \ DIRECTORY
+            \ EXT
+            \ NAME
+            \ NAME_WE
+            \ PATH
+            \ PROGRAM
+            \ PROGRAM_ARGS
+            \ REALPATH
+            \ VAR
 
 syn keyword cmakeKWget_property contained
-            \ BRIEF_DOCS CACHE DEFINED DIRECTORY FULL_DOCS GLOBAL INSTALL PROPERTY SET SOURCE TARGET TEST VARIABLE
+            \ BRIEF_DOCS
+            \ DEFINED
+            \ DIRECTORY
+            \ FULL_DOCS
+            \ GLOBAL
+            \ INSTALL
+            \ PROPERTY
+            \ SET
+            \ SOURCE
+            \ TARGET
+            \ TEST
+            \ VARIABLE
 
 syn keyword cmakeKWget_source_file_property contained
-            \ LOCATION VAR
+            \ INHERITED
+            \ LOCATION
+            \ VAR
 
 syn keyword cmakeKWget_target_property contained
+            \ INHERITED
             \ VAR
 
 syn keyword cmakeKWget_test_property contained
+            \ INHERITED
             \ VAR
 
 syn keyword cmakeKWif contained
-            \ ARGS CMAKE_MATCH_ CMP COMMAND DEFINED EQUAL EXISTS FALSE GREATER GREATER_EQUAL IGNORE IN_LIST IS_ABSOLUTE IS_DIRECTORY IS_NEWER_THAN IS_SYMLINK LESS LESS_EQUAL MATCHES NNNN NOT OFF OR POLICY STREQUAL STRGREATER STRGREATER_EQUAL STRLESS STRLESS_EQUAL TARGET TEST THEN TRUE VERSION_EQUAL VERSION_GREATER VERSION_GREATER_EQUAL VERSION_LESS VERSION_LESS_EQUAL YES
+            \ ARGS
+            \ CMAKE_MATCH_
+            \ CMP
+            \ COMMAND
+            \ DEFINED
+            \ EQUAL
+            \ EXISTS
+            \ FALSE
+            \ GREATER
+            \ GREATER_EQUAL
+            \ IGNORE
+            \ IN_LIST
+            \ IS_ABSOLUTE
+            \ IS_DIRECTORY
+            \ IS_NEWER_THAN
+            \ IS_SYMLINK
+            \ LESS
+            \ LESS_EQUAL
+            \ MATCHES
+            \ NNNN
+            \ NOT
+            \ OFF
+            \ OR
+            \ POLICY
+            \ STREQUAL
+            \ STRGREATER
+            \ STRGREATER_EQUAL
+            \ STRLESS
+            \ STRLESS_EQUAL
+            \ TARGET
+            \ TEST
+            \ THEN
+            \ TRUE
+            \ VERSION_EQUAL
+            \ VERSION_GREATER
+            \ VERSION_GREATER_EQUAL
+            \ VERSION_LESS
+            \ VERSION_LESS_EQUAL
+            \ YES
 
 syn keyword cmakeKWinclude contained
-            \ NO_POLICY_SCOPE OPTIONAL RESULT_VARIABLE
+            \ NO_POLICY_SCOPE
+            \ OPTIONAL
+            \ RESULT_VARIABLE
 
 syn keyword cmakeKWinclude_directories contained
-            \ AFTER BEFORE INCLUDE_DIRECTORIES ON SYSTEM
+            \ AFTER
+            \ BEFORE
+            \ INCLUDE_DIRECTORIES
+            \ ON
+            \ SYSTEM
 
 syn keyword cmakeKWinclude_external_msproject contained
-            \ GUID MAP_IMPORTED_CONFIG_ PLATFORM TYPE WIX
+            \ GUID
+            \ MAP_IMPORTED_CONFIG_
+            \ PLATFORM
+            \ TYPE
+            \ WIX
 
 syn keyword cmakeKWinclude_guard contained
-            \ DIRECTORY GLOBAL TRUE __CURRENT_FILE_VAR__
+            \ DIRECTORY
+            \ GLOBAL
+            \ TRUE
+            \ __CURRENT_FILE_VAR__
 
 syn keyword cmakeKWinstall contained
-            \ ARCHIVE BUNDLE CODE COMPONENT CONFIGURATIONS CVS DESTDIR DESTINATION DIRECTORY DIRECTORY_PERMISSIONS DLL EXCLUDE_FROM_ALL EXPORT EXPORT_ANDROID_MK EXPORT_LINK_INTERFACE_LIBRARIES FILES FILES_MATCHING FILE_PERMISSIONS FRAMEWORK GROUP_EXECUTE GROUP_READ GROUP_WRITE IMPORTED_ INCLUDES INSTALL_PREFIX INTERFACE_INCLUDE_DIRECTORIES LIBRARY MACOSX_BUNDLE MESSAGE_NEVER NAMELINK_ONLY NAMELINK_SKIP NAMESPACE NDK OBJECTS OPTIONAL OWNER_EXECUTE OWNER_READ OWNER_WRITE PATTERN PERMISSIONS POST_INSTALL_SCRIPT PRE_INSTALL_SCRIPT PRIVATE_HEADER PROGRAMS PUBLIC_HEADER REGEX RENAME RESOURCE RUNTIME SCRIPT SETGID SETUID SOVERSION TARGETS TRUE USE_SOURCE_PERMISSIONS VERSION WORLD_EXECUTE WORLD_READ WORLD_WRITE
+            \ AFTER
+            \ APT
+            \ ARCHIVE
+            \ BEFORE
+            \ BUILD_TYPE
+            \ BUNDLE
+            \ CODE
+            \ COMPONENT
+            \ CONFIGURATIONS
+            \ CVS
+            \ DBUILD_TYPE
+            \ DCOMPONENT
+            \ DESTDIR
+            \ DESTINATION
+            \ DIRECTORY
+            \ DIRECTORY_PERMISSIONS
+            \ DLL
+            \ EXCLUDE_FROM_ALL
+            \ EXPORT
+            \ EXPORT_ANDROID_MK
+            \ EXPORT_LINK_INTERFACE_LIBRARIES
+            \ FILES
+            \ FILES_MATCHING
+            \ FILE_PERMISSIONS
+            \ FRAMEWORK
+            \ GROUP_EXECUTE
+            \ GROUP_READ
+            \ GROUP_WRITE
+            \ IMPORTED_
+            \ INCLUDES
+            \ INSTALL_PREFIX
+            \ INTERFACE_INCLUDE_DIRECTORIES
+            \ LIBRARY
+            \ MACOSX_BUNDLE
+            \ MESSAGE_NEVER
+            \ NAMELINK_COMPONENT
+            \ NAMELINK_ONLY
+            \ NAMELINK_SKIP
+            \ NAMESPACE
+            \ NDK
+            \ OBJECTS
+            \ OPTIONAL
+            \ OWNER_EXECUTE
+            \ OWNER_READ
+            \ OWNER_WRITE
+            \ PATTERN
+            \ PERMISSIONS
+            \ POST_INSTALL_SCRIPT
+            \ PRE_INSTALL_SCRIPT
+            \ PRIVATE_HEADER
+            \ PROGRAMS
+            \ PUBLIC_HEADER
+            \ REGEX
+            \ RENAME
+            \ RESOURCE
+            \ RPM
+            \ RUNTIME
+            \ SCRIPT
+            \ SETGID
+            \ SETUID
+            \ SOVERSION
+            \ TARGETS
+            \ TRUE
+            \ USE_SOURCE_PERMISSIONS
+            \ VERSION
+            \ WORLD_EXECUTE
+            \ WORLD_READ
+            \ WORLD_WRITE
 
 syn keyword cmakeKWinstall_files contained
-            \ FILES GLOB
+            \ FILES
+            \ GLOB
 
 syn keyword cmakeKWinstall_programs contained
-            \ FILES GLOB PROGRAMS TARGETS
+            \ FILES
+            \ GLOB
+            \ PROGRAMS
+            \ TARGETS
 
 syn keyword cmakeKWinstall_targets contained
-            \ DLL RUNTIME_DIRECTORY TARGETS
+            \ DLL
+            \ RUNTIME_DIRECTORY
+            \ TARGETS
+
+syn keyword cmakeKWlink_directories contained
+            \ AFTER
+            \ BEFORE
+            \ LINK_DIRECTORIES
+            \ ON
+            \ ORIGIN
+            \ RPATH
 
 syn keyword cmakeKWlist contained
-            \ APPEND CACHE EXCLUDE FILTER FIND GET INCLUDE INSERT INTERNAL LENGTH LIST NOTES PARENT_SCOPE REGEX REMOVE_AT REMOVE_DUPLICATES REMOVE_ITEM REVERSE SORT
+            \ ACTION
+            \ APPEND
+            \ ASCENDING
+            \ CASE
+            \ COMPARE
+            \ DESCENDING
+            \ EXCLUDE
+            \ FILE_BASENAME
+            \ FILTER
+            \ FIND
+            \ GENEX_STRIP
+            \ GET
+            \ INCLUDE
+            \ INSENSITIVE
+            \ INSERT
+            \ INTERNAL
+            \ JOIN
+            \ LENGTH
+            \ ORDER
+            \ OUTPUT_VARIABLE
+            \ PARENT_SCOPE
+            \ PREPEND
+            \ REGEX
+            \ REMOVE_AT
+            \ REMOVE_DUPLICATES
+            \ REMOVE_ITEM
+            \ REPLACE
+            \ REVERSE
+            \ SELECTOR
+            \ SENSITIVE
+            \ SORT
+            \ STRING
+            \ STRIP
+            \ SUBLIST
+            \ TOLOWER
+            \ TOUPPER
+            \ TRANSFORM
 
 syn keyword cmakeKWload_cache contained
-            \ EXCLUDE INCLUDE_INTERNALS READ_WITH_PREFIX
+            \ EXCLUDE
+            \ INCLUDE_INTERNALS
+            \ READ_WITH_PREFIX
 
 syn keyword cmakeKWload_command contained
-            \ CMAKE_LOADED_COMMAND_ COMMAND_NAME
+            \ CMAKE_LOADED_COMMAND_
+            \ COMMAND_NAME
 
 syn keyword cmakeKWmacro contained
-            \ ARGC ARGN ARGS ARGV DEFINED GREATER LISTS NOT _BAR _FOO
+            \ ARGC
+            \ ARGN
+            \ ARGS
+            \ ARGV
+            \ DEFINED
+            \ GREATER
+            \ LISTS
+            \ NOT
+            \ _BAR
+            \ _FOO
 
 syn keyword cmakeKWmake_directory contained
             \ MAKE_DIRECTORY
 
 syn keyword cmakeKWmark_as_advanced contained
-            \ CLEAR FORCE VAR
+            \ CLEAR
+            \ FORCE
+            \ VAR
 
 syn keyword cmakeKWmath contained
             \ EXPR
+            \ HEXADECIMAL
+            \ OUTPUT_FORMAT
 
 syn keyword cmakeKWmessage contained
-            \ AUTHOR_WARNING DEPRECATION FATAL_ERROR GUI SEND_ERROR STATUS WARNING
+            \ AUTHOR_WARNING
+            \ DEPRECATION
+            \ FATAL_ERROR
+            \ GUI
+            \ SEND_ERROR
+            \ STATUS
+            \ WARNING
 
 syn keyword cmakeKWoption contained
-            \ OFF ON
+            \ OFF
+            \ ON
 
 syn keyword cmakeKWproject contained
-            \ CMAKE_PROJECT_ DESCRIPTION LANGUAGES NAME NONE PROJECT VERSION _BINARY_DIR _INCLUDE _SOURCE_DIR _VERSION _VERSION_MAJOR _VERSION_MINOR _VERSION_PATCH _VERSION_TWEAK
+            \ ASM
+            \ CMAKE_PROJECT_
+            \ CUDA
+            \ DESCRIPTION
+            \ HOMEPAGE_URL
+            \ LANGUAGES
+            \ NAME
+            \ NONE
+            \ PROJECT
+            \ VERSION
+            \ _BINARY_DIR
+            \ _DESCRIPTION
+            \ _HOMEPAGE_URL
+            \ _INCLUDE
+            \ _SOURCE_DIR
+            \ _VERSION
+            \ _VERSION_MAJOR
+            \ _VERSION_MINOR
+            \ _VERSION_PATCH
+            \ _VERSION_TWEAK
 
 syn keyword cmakeKWremove contained
-            \ REMOVE_ITEM VALUE VAR
+            \ REMOVE_ITEM
+            \ VALUE
+            \ VAR
 
 syn keyword cmakeKWseparate_arguments contained
-            \ MSDN NATIVE NATIVE_COMMAND UNIX_COMMAND WINDOWS WINDOWS_COMMAND _COMMAND
+            \ MSDN
+            \ NATIVE
+            \ NATIVE_COMMAND
+            \ UNIX_COMMAND
+            \ WINDOWS
+            \ WINDOWS_COMMAND
+            \ _COMMAND
 
 syn keyword cmakeKWset contained
-            \ BOOL CACHE FILEPATH FORCE INTERNAL OFF ON PARENT_SCOPE STRING STRINGS
+            \ BOOL
+            \ FILEPATH
+            \ FORCE
+            \ INTERNAL
+            \ OFF
+            \ ON
+            \ PARENT_SCOPE
+            \ STRING
+            \ STRINGS
 
 syn keyword cmakeKWset_directory_properties contained
             \ PROPERTIES
 
 syn keyword cmakeKWset_property contained
-            \ APPEND APPEND_STRING CACHE DIRECTORY GLOBAL INSTALL PROPERTY SOURCE TARGET TEST WIX
+            \ APPEND
+            \ APPEND_STRING
+            \ DIRECTORY
+            \ GLOBAL
+            \ INHERITED
+            \ INSTALL
+            \ PROPERTY
+            \ SOURCE
+            \ TARGET
+            \ TEST
+            \ WIX
 
 syn keyword cmakeKWset_source_files_properties contained
             \ PROPERTIES
 
 syn keyword cmakeKWset_target_properties contained
             \ PROPERTIES
+            \ TARGET
 
 syn keyword cmakeKWset_tests_properties contained
             \ PROPERTIES
 
 syn keyword cmakeKWsource_group contained
-            \ FILES PREFIX REGULAR_EXPRESSION TREE
+            \ FILES
+            \ PREFIX
+            \ REGULAR_EXPRESSION
+            \ TREE
 
 syn keyword cmakeKWstring contained
-            \ ALPHABET APPEND ASCII CMAKE_MATCH_ COMPARE CONCAT CONFIGURE EQUAL ESCAPE_QUOTES FIND GENEX_STRIP GREATER GREATER_EQUAL GUID HASH LENGTH LESS LESS_EQUAL MAKE_C_IDENTIFIER MATCH MATCHALL MATCHES NAMESPACE NOTEQUAL ONLY PREPEND RANDOM RANDOM_SEED REGEX REPLACE REVERSE RFC SHA SOURCE_DATE_EPOCH STRIP SUBSTRING SZ TIMESTAMP TOLOWER TOUPPER TYPE US UTC UUID
+            \ ALPHABET
+            \ APPEND
+            \ ASCII
+            \ CMAKE_MATCH_
+            \ COMPARE
+            \ CONCAT
+            \ CONFIGURE
+            \ EQUAL
+            \ ESCAPE_QUOTES
+            \ FIND
+            \ GENEX_STRIP
+            \ GREATER
+            \ GREATER_EQUAL
+            \ GUID
+            \ HASH
+            \ JOIN
+            \ LENGTH
+            \ LESS
+            \ LESS_EQUAL
+            \ MAKE_C_IDENTIFIER
+            \ MATCH
+            \ MATCHALL
+            \ MATCHES
+            \ NAMESPACE
+            \ NOTEQUAL
+            \ ONLY
+            \ PREPEND
+            \ RANDOM
+            \ RANDOM_SEED
+            \ REGEX
+            \ REPLACE
+            \ REVERSE
+            \ RFC
+            \ SHA
+            \ SOURCE_DATE_EPOCH
+            \ STRIP
+            \ SUBSTRING
+            \ SZ
+            \ TIMESTAMP
+            \ TOLOWER
+            \ TOUPPER
+            \ TYPE
+            \ US
+            \ UTC
+            \ UUID
 
 syn keyword cmakeKWsubdirs contained
-            \ EXCLUDE_FROM_ALL PREORDER
+            \ EXCLUDE_FROM_ALL
+            \ PREORDER
 
 syn keyword cmakeKWtarget_compile_definitions contained
-            \ ALIAS COMPILE_DEFINITIONS IMPORTED INTERFACE INTERFACE_COMPILE_DEFINITIONS PRIVATE PUBLIC
+            \ ALIAS
+            \ COMPILE_DEFINITIONS
+            \ FOO
+            \ IMPORTED
+            \ INTERFACE
+            \ INTERFACE_COMPILE_DEFINITIONS
+            \ PRIVATE
+            \ PUBLIC
 
 syn keyword cmakeKWtarget_compile_features contained
-            \ ALIAS COMPILE_FEATURES IMPORTED INTERFACE INTERFACE_COMPILE_FEATURES PRIVATE PUBLIC
+            \ ALIAS
+            \ COMPILE_FEATURES
+            \ IMPORTED
+            \ INTERFACE
+            \ INTERFACE_COMPILE_FEATURES
+            \ PRIVATE
+            \ PUBLIC
 
 syn keyword cmakeKWtarget_compile_options contained
-            \ ALIAS BEFORE COMPILE_OPTIONS IMPORTED INTERFACE INTERFACE_COMPILE_OPTIONS PRIVATE PUBLIC
+            \ ALIAS
+            \ BEFORE
+            \ COMPILE_OPTIONS
+            \ IMPORTED
+            \ INTERFACE
+            \ INTERFACE_COMPILE_OPTIONS
+            \ PRIVATE
+            \ PUBLIC
+            \ SHELL
+            \ UNIX_COMMAND
 
 syn keyword cmakeKWtarget_include_directories contained
-            \ ALIAS BEFORE BUILD_INTERFACE IMPORTED INCLUDE_DIRECTORIES INSTALL_INTERFACE INTERFACE INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES PRIVATE PUBLIC SYSTEM
+            \ ALIAS
+            \ BEFORE
+            \ BUILD_INTERFACE
+            \ IMPORTED
+            \ INCLUDE_DIRECTORIES
+            \ INSTALL_INTERFACE
+            \ INTERFACE
+            \ INTERFACE_INCLUDE_DIRECTORIES
+            \ INTERFACE_LINK_LIBRARIES
+            \ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
+            \ PRIVATE
+            \ PUBLIC
+            \ SYSTEM
+
+syn keyword cmakeKWtarget_link_directories contained
+            \ ALIAS
+            \ BEFORE
+            \ IMPORTED
+            \ INTERFACE
+            \ INTERFACE_LINK_DIRECTORIES
+            \ LINK_DIRECTORIES
+            \ ORIGIN
+            \ PRIVATE
+            \ PUBLIC
+            \ RPATH
 
 syn keyword cmakeKWtarget_link_libraries contained
-            \ ALIAS DAG DEBUG_CONFIGURATIONS IMPORTED IMPORTED_NO_SONAME INTERFACE INTERFACE_LINK_LIBRARIES LINK_FLAGS LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_DEBUG LINK_INTERFACE_MULTIPLICITY LINK_PRIVATE LINK_PUBLIC OLD OSX PRIVATE PUBLIC STATIC
+            \ ALIAS
+            \ DA
+            \ DAG
+            \ DEBUG_CONFIGURATIONS
+            \ DOBJ
+            \ IMPORTED
+            \ IMPORTED_NO_SONAME
+            \ INTERFACE
+            \ INTERFACE_LINK_LIBRARIES
+            \ LINK_INTERFACE_LIBRARIES
+            \ LINK_INTERFACE_LIBRARIES_DEBUG
+            \ LINK_INTERFACE_MULTIPLICITY
+            \ LINK_OPTIONS
+            \ LINK_PRIVATE
+            \ LINK_PUBLIC
+            \ OBJECT
+            \ OLD
+            \ OSX
+            \ PRIVATE
+            \ PUBLIC
+            \ SHARED
+            \ STATIC
+
+syn keyword cmakeKWtarget_link_options contained
+            \ ALIAS
+            \ BEFORE
+            \ CMAKE_
+            \ GCC
+            \ GNU
+            \ IMPORTED
+            \ INTERFACE
+            \ INTERFACE_LINK_OPTIONS
+            \ LANG
+            \ LINKER
+            \ LINK_OPTIONS
+            \ PRIVATE
+            \ PUBLIC
+            \ SHELL
+            \ UNIX_COMMAND
+            \ _LINKER_WRAPPER_FLAG
+            \ _LINKER_WRAPPER_FLAG_SEP
 
 syn keyword cmakeKWtarget_sources contained
-            \ ALIAS IMPORTED INTERFACE INTERFACE_SOURCES PRIVATE PUBLIC SOURCES
+            \ ALIAS
+            \ IMPORTED
+            \ INTERFACE
+            \ INTERFACE_SOURCES
+            \ PRIVATE
+            \ PUBLIC
+            \ SOURCES
 
 syn keyword cmakeKWtry_compile contained
-            \ ALL_BUILD CMAKE_FLAGS COMPILE_DEFINITIONS COPY_FILE COPY_FILE_ERROR CUDA_EXTENSIONS CUDA_STANDARD CUDA_STANDARD_REQUIRED CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED DEFINED DLINK_LIBRARIES DVAR FALSE INCLUDE_DIRECTORIES LANG LINK_DIRECTORIES LINK_LIBRARIES NOT OUTPUT_VARIABLE RESULT_VAR SOURCES TRUE TYPE VALUE _EXTENSIONS _STANDARD _STANDARD_REQUIRED
+            \ ALL_BUILD
+            \ CMAKE_FLAGS
+            \ COMPILE_DEFINITIONS
+            \ COPY_FILE
+            \ COPY_FILE_ERROR
+            \ CUDA_EXTENSIONS
+            \ CUDA_STANDARD
+            \ CUDA_STANDARD_REQUIRED
+            \ CXX_EXTENSIONS
+            \ CXX_STANDARD
+            \ CXX_STANDARD_REQUIRED
+            \ C_EXTENSIONS
+            \ C_STANDARD
+            \ C_STANDARD_REQUIRED
+            \ DEFINED
+            \ DLINK_LIBRARIES
+            \ DVAR
+            \ FALSE
+            \ INCLUDE_DIRECTORIES
+            \ LANG
+            \ LINK_DIRECTORIES
+            \ LINK_LIBRARIES
+            \ NOT
+            \ OUTPUT_VARIABLE
+            \ RESULT_VAR
+            \ SOURCES
+            \ TRUE
+            \ TYPE
+            \ VALUE
+            \ _EXTENSIONS
+            \ _STANDARD
+            \ _STANDARD_REQUIRED
 
 syn keyword cmakeKWtry_run contained
-            \ ARGS CMAKE_FLAGS COMPILE_DEFINITIONS COMPILE_OUTPUT_VARIABLE COMPILE_RESULT_VAR DLINK_LIBRARIES DVAR FAILED_TO_RUN FALSE INCLUDE_DIRECTORIES LINK_DIRECTORIES LINK_LIBRARIES RUN_OUTPUT_VARIABLE RUN_RESULT_VAR TRUE TYPE VALUE __TRYRUN_OUTPUT
+            \ ARGS
+            \ CMAKE_FLAGS
+            \ COMPILE_DEFINITIONS
+            \ COMPILE_OUTPUT_VARIABLE
+            \ COMPILE_RESULT_VAR
+            \ DLINK_LIBRARIES
+            \ DVAR
+            \ FAILED_TO_RUN
+            \ FALSE
+            \ INCLUDE_DIRECTORIES
+            \ LINK_DIRECTORIES
+            \ LINK_LIBRARIES
+            \ RUN_OUTPUT_VARIABLE
+            \ RUN_RESULT_VAR
+            \ TRUE
+            \ TYPE
+            \ VALUE
+            \ __TRYRUN_OUTPUT
 
 syn keyword cmakeKWunset contained
-            \ CACHE LD_LIBRARY_PATH PARENT_SCOPE
+            \ LD_LIBRARY_PATH
+            \ PARENT_SCOPE
+            \ VAR
 
 syn keyword cmakeKWuse_mangled_mesa contained
-            \ GL OUTPUT_DIRECTORY PATH_TO_MESA
+            \ GL
+            \ OUTPUT_DIRECTORY
+            \ PATH_TO_MESA
 
 syn keyword cmakeKWvariable_requires contained
-            \ RESULT_VARIABLE TEST_VARIABLE
+            \ RESULT_VARIABLE
+            \ TEST_VARIABLE
 
 syn keyword cmakeKWvariable_watch contained
             \ COMMAND
@@ -326,28 +2175,231 @@
             \ ARGS
 
 syn keyword cmakeKWwrite_file contained
-            \ APPEND CONFIGURE_FILE NOTE WRITE
+            \ APPEND
+            \ CONFIGURE_FILE
+            \ NOTE
+            \ WRITE
 
 
 syn keyword cmakeGeneratorExpressions contained
-            \ LINK_LIBRARIES INCLUDE_DIRECTORIES COMPILE_DEFINITIONS CONFIG DEBUG_MODE BOOL AND NOT IF STREQUAL MAP_IMPORTED_CONFIG_ PLATFORM_ID C_COMPILER_ID CXX_COMPILER_ID VERSION_LESS VERSION_GREATER VERSION_EQUAL VERSION_LESS_EQUAL VERSION_GREATER_EQUAL C_COMPILER_VERSION CXX_COMPILER_VERSION TARGET_POLICY COMPILE_FEATURES C_STANDARD CXX_STANDARD COMPILE_LANGUAGE PRIVATE PUBLIC COMPILING_CXX GNU OLD_COMPILER CMAKE_CXX_COMPILER_VERSION CONFIGURATION TARGET_FILE TARGET_FILE_NAME TARGET_FILE_DIR TARGET_LINKER_FILE TARGET_LINKER_FILE_NAME TARGET_LINKER_FILE_DIR TARGET_SONAME_FILE TARGET_SONAME_FILE_NAME TARGET_SONAME_FILE_DIR TARGET_PDB_FILE PDB_NAME PDB_OUTPUT_DIRECTORY PDB_NAME_ PDB_OUTPUT_DIRECTORY_ TARGET_PDB_FILE_NAME TARGET_PDB_FILE_DIR TARGET_BUNDLE_DIR TARGET_BUNDLE_CONTENT_DIR SDK TARGET_PROPERTY INSTALL_PREFIX EXPORT JOIN ANGLE COMMA SEMICOLON TARGET_NAME LINK_ONLY INTERFACE_LINK_LIBRARIES INSTALL_INTERFACE BUILD_INTERFACE LOWER_CASE UPPER_CASE MAKE_C_IDENTIFIER TARGET_OBJECTS OBJECT_LIBRARY SHELL_PATH MSYS
+            \ AND
+            \ ANGLE
+            \ BOOL
+            \ BUILD_INTERFACE
+            \ CMAKE_
+            \ CMAKE_CXX_COMPILER_VERSION
+            \ COMMA
+            \ COMMAND
+            \ COMPILE_DEFINITIONS
+            \ COMPILE_FEATURES
+            \ COMPILE_LANGUAGE
+            \ COMPILING_CUDA
+            \ COMPILING_CXX
+            \ CONFIG
+            \ CONFIGURATION
+            \ CUDA
+            \ CUSTOM_KEYS
+            \ CXX_COMPILER_ID
+            \ CXX_COMPILER_VERSION
+            \ CXX_STANDARD
+            \ C_COMPILER_ID
+            \ C_COMPILER_VERSION
+            \ C_STANDARD
+            \ DEBUG_MODE
+            \ EXPORT
+            \ FOO_EXTRA_THINGS
+            \ GENEX_EVAL
+            \ GNU
+            \ IF
+            \ INCLUDE_DIRECTORIES
+            \ INSTALL_INTERFACE
+            \ INSTALL_PREFIX
+            \ INTERFACE_LINK_LIBRARIES
+            \ IN_LIST
+            \ JOIN
+            \ LANG
+            \ LINK_LIBRARIES
+            \ LINK_ONLY
+            \ LOWER_CASE
+            \ MAKE_C_IDENTIFIER
+            \ MAP_IMPORTED_CONFIG_
+            \ MSYS
+            \ NOT
+            \ OBJECT_LIBRARY
+            \ OLD_COMPILER
+            \ PDB_NAME
+            \ PDB_NAME_
+            \ PDB_OUTPUT_DIRECTORY
+            \ PDB_OUTPUT_DIRECTORY_
+            \ PLATFORM_ID
+            \ PRIVATE
+            \ PUBLIC
+            \ SDK
+            \ SEMICOLON
+            \ SHELL_PATH
+            \ STREQUAL
+            \ TARGET_BUNDLE_CONTENT_DIR
+            \ TARGET_BUNDLE_DIR
+            \ TARGET_EXISTS
+            \ TARGET_FILE
+            \ TARGET_FILE_DIR
+            \ TARGET_FILE_NAME
+            \ TARGET_GENEX_EVAL
+            \ TARGET_LINKER_FILE
+            \ TARGET_LINKER_FILE_DIR
+            \ TARGET_LINKER_FILE_NAME
+            \ TARGET_NAME
+            \ TARGET_NAME_IF_EXISTS
+            \ TARGET_OBJECTS
+            \ TARGET_PDB_FILE
+            \ TARGET_PDB_FILE_DIR
+            \ TARGET_PDB_FILE_NAME
+            \ TARGET_POLICY
+            \ TARGET_PROPERTY
+            \ TARGET_SONAME_FILE
+            \ TARGET_SONAME_FILE_DIR
+            \ TARGET_SONAME_FILE_NAME
+            \ UPPER_CASE
+            \ VERSION_EQUAL
+            \ VERSION_GREATER
+            \ VERSION_GREATER_EQUAL
+            \ VERSION_LESS
+            \ VERSION_LESS_EQUAL
 
 syn case ignore
 
 syn keyword cmakeCommand
-            \ add_compile_options add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory break build_command cmake_host_system_information cmake_minimum_required cmake_parse_arguments cmake_policy configure_file continue create_test_sourcelist ctest_build ctest_configure ctest_coverage ctest_empty_binary_directory ctest_memcheck ctest_read_custom_files ctest_run_script ctest_sleep ctest_start ctest_submit ctest_test ctest_update ctest_upload define_property enable_language enable_testing endfunction endmacro execute_process export file find_file find_library find_package find_path find_program fltk_wrap_ui function get_cmake_property get_directory_property get_filename_component get_property get_source_file_property get_target_property get_test_property include include_directories include_external_msproject include_guard include_regular_expression install link_directories list load_cache load_command macro mark_as_advanced math message option project qt_wrap_cpp qt_wrap_ui remove_definitions return separate_arguments set set_directory_properties set_property set_source_files_properties set_target_properties set_tests_properties site_name source_group string target_compile_definitions target_compile_features target_compile_options target_include_directories target_link_libraries target_sources try_compile try_run unset variable_watch
+            \ add_compile_definitions
+            \ add_compile_options
+            \ add_custom_command
+            \ add_custom_target
+            \ add_definitions
+            \ add_dependencies
+            \ add_executable
+            \ add_library
+            \ add_link_options
+            \ add_subdirectory
+            \ add_test
+            \ aux_source_directory
+            \ break
+            \ build_command
+            \ cmake_host_system_information
+            \ cmake_minimum_required
+            \ cmake_parse_arguments
+            \ cmake_policy
+            \ configure_file
+            \ continue
+            \ create_test_sourcelist
+            \ ctest_build
+            \ ctest_configure
+            \ ctest_coverage
+            \ ctest_empty_binary_directory
+            \ ctest_memcheck
+            \ ctest_read_custom_files
+            \ ctest_run_script
+            \ ctest_sleep
+            \ ctest_start
+            \ ctest_submit
+            \ ctest_test
+            \ ctest_update
+            \ ctest_upload
+            \ define_property
+            \ enable_language
+            \ enable_testing
+            \ endfunction
+            \ endmacro
+            \ execute_process
+            \ export
+            \ file
+            \ find_file
+            \ find_library
+            \ find_package
+            \ find_path
+            \ find_program
+            \ fltk_wrap_ui
+            \ function
+            \ get_cmake_property
+            \ get_directory_property
+            \ get_filename_component
+            \ get_property
+            \ get_source_file_property
+            \ get_target_property
+            \ get_test_property
+            \ include
+            \ include_directories
+            \ include_external_msproject
+            \ include_guard
+            \ include_regular_expression
+            \ install
+            \ link_directories
+            \ list
+            \ load_cache
+            \ load_command
+            \ macro
+            \ mark_as_advanced
+            \ math
+            \ message
+            \ option
+            \ project
+            \ qt_wrap_cpp
+            \ qt_wrap_ui
+            \ remove_definitions
+            \ return
+            \ separate_arguments
+            \ set
+            \ set_directory_properties
+            \ set_property
+            \ set_source_files_properties
+            \ set_target_properties
+            \ set_tests_properties
+            \ site_name
+            \ source_group
+            \ string
+            \ target_compile_definitions
+            \ target_compile_features
+            \ target_compile_options
+            \ target_include_directories
+            \ target_link_directories
+            \ target_link_libraries
+            \ target_link_options
+            \ target_sources
+            \ try_compile
+            \ try_run
+            \ unset
+            \ variable_watch
             \ nextgroup=cmakeArguments
 
 syn keyword cmakeCommandConditional
-            \ else elseif endif if
+            \ else
+            \ elseif
+            \ endif
+            \ if
             \ nextgroup=cmakeArguments
 
 syn keyword cmakeCommandRepeat
-            \ endforeach endwhile foreach while
+            \ endforeach
+            \ endwhile
+            \ foreach
+            \ while
             \ nextgroup=cmakeArguments
 
 syn keyword cmakeCommandDeprecated
-            \ build_name exec_program export_library_dependencies install_files install_programs install_targets link_libraries make_directory output_required_files remove subdir_depends subdirs use_mangled_mesa utility_source variable_requires write_file
+            \ build_name
+            \ exec_program
+            \ export_library_dependencies
+            \ install_files
+            \ install_programs
+            \ install_targets
+            \ link_libraries
+            \ make_directory
+            \ output_required_files
+            \ remove
+            \ subdir_depends
+            \ subdirs
+            \ use_mangled_mesa
+            \ utility_source
+            \ variable_requires
+            \ write_file
             \ nextgroup=cmakeArguments
 
 syn case match
@@ -356,6 +2408,8 @@
             \ TODO FIXME XXX
             \ contained
 
+hi def link cmakeBracketArgument String
+hi def link cmakeBracketComment Comment
 hi def link cmakeCommand Function
 hi def link cmakeCommandConditional Conditional
 hi def link cmakeCommandDeprecated WarningMsg
@@ -365,7 +2419,6 @@
 hi def link cmakeEscaped Special
 hi def link cmakeGeneratorExpression WarningMsg
 hi def link cmakeGeneratorExpressions Constant
-hi def link cmakeLuaComment Comment
 hi def link cmakeModule Include
 hi def link cmakeProperty Constant
 hi def link cmakeRegistry Underlined
@@ -375,6 +2428,7 @@
 hi def link cmakeVariable Identifier
 
 hi def link cmakeKWExternalProject ModeMsg
+hi def link cmakeKWadd_compile_definitions ModeMsg
 hi def link cmakeKWadd_compile_options ModeMsg
 hi def link cmakeKWadd_custom_command ModeMsg
 hi def link cmakeKWadd_custom_target ModeMsg
@@ -382,6 +2436,7 @@
 hi def link cmakeKWadd_dependencies ModeMsg
 hi def link cmakeKWadd_executable ModeMsg
 hi def link cmakeKWadd_library ModeMsg
+hi def link cmakeKWadd_link_options ModeMsg
 hi def link cmakeKWadd_subdirectory ModeMsg
 hi def link cmakeKWadd_test ModeMsg
 hi def link cmakeKWbuild_command ModeMsg
@@ -433,6 +2488,7 @@
 hi def link cmakeKWinstall_files ModeMsg
 hi def link cmakeKWinstall_programs ModeMsg
 hi def link cmakeKWinstall_targets ModeMsg
+hi def link cmakeKWlink_directories ModeMsg
 hi def link cmakeKWlist ModeMsg
 hi def link cmakeKWload_cache ModeMsg
 hi def link cmakeKWload_command ModeMsg
@@ -458,7 +2514,9 @@
 hi def link cmakeKWtarget_compile_features ModeMsg
 hi def link cmakeKWtarget_compile_options ModeMsg
 hi def link cmakeKWtarget_include_directories ModeMsg
+hi def link cmakeKWtarget_link_directories ModeMsg
 hi def link cmakeKWtarget_link_libraries ModeMsg
+hi def link cmakeKWtarget_link_options ModeMsg
 hi def link cmakeKWtarget_sources ModeMsg
 hi def link cmakeKWtry_compile ModeMsg
 hi def link cmakeKWtry_run ModeMsg
@@ -469,6 +2527,30 @@
 hi def link cmakeKWwhile ModeMsg
 hi def link cmakeKWwrite_file ModeMsg
 
+" Manually added - difficult to parse out of documentation
+syn case ignore
+
+syn keyword cmakeCommandManuallyAdded
+            \ configure_package_config_file write_basic_package_version_file
+            \ nextgroup=cmakeArguments
+
+syn case match
+
+syn keyword cmakeKWconfigure_package_config_file contained
+            \ INSTALL_DESTINATION PATH_VARS NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO INSTALL_PREFIX
+
+syn keyword cmakeKWconfigure_package_config_file_constants contained
+            \ AnyNewerVersion SameMajorVersion SameMinorVersion ExactVersion
+
+syn keyword cmakeKWwrite_basic_package_version_file contained
+            \ VERSION COMPATIBILITY
+
+hi def link cmakeCommandManuallyAdded Function
+
+hi def link cmakeKWconfigure_package_config_file ModeMsg
+hi def link cmakeKWwrite_basic_package_version_file ModeMsg
+hi def link cmakeKWconfigure_package_config_file_constants Constant
+
 let b:current_syntax = "cmake"
 
 let &cpo = s:keepcpo
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e88e925..998db15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -410,7 +410,6 @@
     set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
     set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
     set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
-    add_definitions(-DCURL_STATICLIB)
     set(CMAKE_CURL_INCLUDES)
     set(CMAKE_CURL_LIBRARIES cmcurl)
     if(CMAKE_TESTS_CDASH_SERVER)
@@ -792,9 +791,10 @@
   endif()
 endif()
 
-# add a test
-add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
-  --system-information  -G "${CMAKE_GENERATOR}" )
+if(BUILD_TESTING)
+  add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
+    --system-information  -G "${CMAKE_GENERATOR}" )
+endif()
 
 if(NOT CMake_TEST_EXTERNAL_CMAKE)
   # Install license file as it requires.
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index b486b79..3ad571c 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -1,7 +1,16 @@
 find_package
 ------------
 
-Load settings for an external project.
+.. only:: html
+
+   .. contents::
+
+Find an external project, and load its settings.
+
+.. _`basic signature`:
+
+Basic Signature and Module Mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 ::
 
@@ -15,7 +24,6 @@
 package is found package-specific information is provided through
 variables and :ref:`Imported Targets` documented by the package itself.  The
 ``QUIET`` option disables messages if the package cannot be found.  The
-``MODULE`` option disables the second signature documented below.  The
 ``REQUIRED`` option stops processing with an error message if the package
 cannot be found.
 
@@ -33,25 +41,32 @@
 inside a find-module, the corresponding arguments are forwarded
 automatically from the outer call (including the ``EXACT`` flag for
 ``[version]``).  Version support is currently provided only on a
-package-by-package basis (details below).
+package-by-package basis (see the `Version Selection`_ section below).
 
-User code should generally look for packages using the above simple
-signature.  The remainder of this command documentation specifies the
+See the :command:`cmake_policy` command documentation for discussion
+of the ``NO_POLICY_SCOPE`` option.
+
+The command has two modes by which it searches for packages: "Module"
+mode and "Config" mode.  The above signature selects Module mode.
+If no module is found the command falls back to Config mode, described
+below. This fall back is disabled if the ``MODULE`` option is given.
+
+In Module mode, CMake searches for a file called ``Find<PackageName>.cmake``
+in the :variable:`CMAKE_MODULE_PATH` followed by the CMake installation.
+If the file is found, it is read and processed by CMake.  It is responsible
+for finding the package, checking the version, and producing any needed
+messages.  Some find-modules provide limited or no support for versioning;
+check the module documentation.
+
+Full Signature and Config Mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+User code should generally look for packages using the above `basic
+signature`_.  The remainder of this command documentation specifies the
 full command signature and details of the search process.  Project
 maintainers wishing to provide a package to be found by this command
 are encouraged to read on.
 
-The command has two modes by which it searches for packages: "Module"
-mode and "Config" mode.  Module mode is available when the command is
-invoked with the above reduced signature.  CMake searches for a file
-called ``Find<PackageName>.cmake`` in the :variable:`CMAKE_MODULE_PATH`
-followed by the CMake installation.  If the file is found, it is read
-and processed by CMake.  It is responsible for finding the package,
-checking the version, and producing any needed messages.  Many
-find-modules provide limited or no support for versioning; check
-the module documentation.  If no module is found and the ``MODULE``
-option is not given the command proceeds to Config mode.
-
 The complete Config mode command signature is::
 
   find_package(<PackageName> [version] [EXACT] [QUIET]
@@ -76,12 +91,12 @@
                 ONLY_CMAKE_FIND_ROOT_PATH |
                 NO_CMAKE_FIND_ROOT_PATH])
 
-The ``CONFIG`` option may be used to skip Module mode explicitly and
-switch to Config mode.  It is synonymous to using ``NO_MODULE``.  Config
-mode is also implied by use of options not specified in the reduced
-signature.
+The ``CONFIG`` option, the synonymous ``NO_MODULE`` option, or the use
+of options not specified in the `basic signature`_ all enforce pure Config
+mode.  In pure Config mode, the command skips Module mode search and
+proceeds at once with Config mode search.
 
-Config mode attempts to locate a configuration file provided by the
+Config mode search attempts to locate a configuration file provided by the
 package to be found.  A cache entry called ``<PackageName>_DIR`` is created to
 hold the directory containing the file.  By default the command
 searches for a package with the name ``<PackageName>``.  If the ``NAMES`` option
@@ -107,6 +122,13 @@
 ``<PackageName>_DIR`` has been set to a directory not containing a
 configuration file CMake will ignore it and search from scratch.
 
+Package maintainers providing CMake package configuration files are
+encouraged to name and install them such that the `Search Procedure`_
+outlined below will find them without requiring use of additional options.
+
+Version Selection
+^^^^^^^^^^^^^^^^^
+
 When the ``[version]`` argument is given Config mode will only find a
 version of the package that claims compatibility with the requested
 version (format is ``major[.minor[.patch[.tweak]]]``).  If the ``EXACT``
@@ -187,17 +209,8 @@
 
 before calling ``find_package``.
 
-Config mode provides an elaborate interface and search procedure.
-Much of the interface is provided for completeness and for use
-internally by find-modules loaded by Module mode.  Most user code
-should simply call::
-
-  find_package(<PackageName> [major[.minor]] [EXACT] [REQUIRED|QUIET])
-
-in order to find a package.  Package maintainers providing CMake
-package configuration files are encouraged to name and install them
-such that the procedure outlined below will find them without
-requiring use of additional options.
+Search Procedure
+^^^^^^^^^^^^^^^^
 
 CMake constructs a set of possible installation prefixes for the
 package.  Under each prefix several directories are searched for a
@@ -339,6 +352,9 @@
 Every non-REQUIRED ``find_package`` call can be disabled by setting the
 :variable:`CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` variable to ``TRUE``.
 
+Package File Interface Variables
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
 When loading a find module or package configuration file ``find_package``
 defines variables to provide information about the call arguments (and
 restores their original state before returning):
@@ -377,6 +393,3 @@
 for the package.  The package configuration file may set
 ``<PackageName>_FOUND`` to false to tell ``find_package`` that component
 requirements are not satisfied.
-
-See the :command:`cmake_policy` command documentation for discussion
-of the ``NO_POLICY_SCOPE`` option.
diff --git a/Help/command/install.rst b/Help/command/install.rst
index 08c5718..98074d0 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -442,10 +442,6 @@
 
 will print a message during installation.
 
-The contents of ``SCRIPT`` or ``CODE`` may use "generator expressions" with
-the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
-manual for available expressions.
-
 Installing Exports
 ^^^^^^^^^^^^^^^^^^
 
diff --git a/Help/command/list.rst b/Help/command/list.rst
index ad2c428..2357a9b 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -256,20 +256,24 @@
   list(SORT <list> [COMPARE <compare>] [CASE <case>] [ORDER <order>])
 
 Sorts the list in-place alphabetically.
-Use the option ``<compare>`` to select the compare type for sorting.
-The ``<compare>`` option may be one of:
+Use the ``COMPARE`` keyword to select the comparison method for sorting.
+The ``<compare>`` option should be one of:
 
-* ``STRING``: Sorts a list of strings alphabetically.
-* ``FILE_BASENAME``: Sort a list of pathnames of files by their basenames.
+* ``STRING``: Sorts a list of strings alphabetically.  This is the
+  default behavior if the ``COMPARE`` option is not given.
+* ``FILE_BASENAME``: Sorts a list of pathnames of files by their basenames.
 
-Use the option ``<case>`` to select a case sensitive or case insensitive sort mode.
-The ``<case>`` option may be one of:
+Use the ``CASE`` keyword to select a case sensitive or case insensitive
+sort mode.  The ``<case>`` option should be one of:
 
-* ``SENSITIVE``: Sorts the list alphabetically.
-* ``INSENSITIVE``: Sorts the list alphabetically in descending order.
+* ``SENSITIVE``: List items are sorted in a case-sensitive manner.  This is
+  the default behavior if the ``CASE`` option is not given.
+* ``INSENSITIVE``: List items are sorted case insensitively.  The order of
+  items which differ only by upper/lowercase is not specified.
 
-Use the option ``<order>`` to select a case sensitive or case insensitive sort mode.
-The ``<order>`` option may be one of:
+To control the sort order, the ``ORDER`` keyword can be given.
+The ``<order>`` option should be one of:
 
-* ``ASCENDING``: Sorts the list in ascending order.
+* ``ASCENDING``: Sorts the list in ascending order.  This is the default
+  behavior when the ``ORDER`` option is not given.
 * ``DESCENDING``: Sorts the list in descending order.
diff --git a/Help/command/project.rst b/Help/command/project.rst
index c1de057..bd8b4ef 100644
--- a/Help/command/project.rst
+++ b/Help/command/project.rst
@@ -44,6 +44,7 @@
 
 If the optional ``DESCRIPTION`` is given, then :variable:`PROJECT_DESCRIPTION`
 and :variable:`<PROJECT-NAME>_DESCRIPTION` will be set to its argument.
+These variables will be cleared if ``DESCRIPTION`` is not given.
 The description is expected to be a relatively short string, usually no more
 than a few words.
 
@@ -51,6 +52,7 @@
 :variable:`PROJECT_HOMEPAGE_URL` and :variable:`<PROJECT-NAME>_HOMEPAGE_URL`.
 When this option is given, the URL provided should be the canonical home for
 the project.
+These variables will be cleared if ``HOMEPAGE_URL`` is not given.
 
 Note that the description and homepage URL may be used as defaults for
 things like packaging meta-data, documentation, etc.
diff --git a/Help/command/string.rst b/Help/command/string.rst
index 29a153a..cc18069 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -121,6 +121,11 @@
   Matches at end of input
 ``.``
   Matches any single character
+``\<char>``
+  Matches the single character specified by ``<char>``.  Use this to
+  match special regex characters, e.g. ``\.`` for a literal ``.``
+  or ``\\`` for a literal backslash ``\``.  Escaping a non-special
+  character is unnecessary but allowed, e.g. ``\a`` matches ``a``.
 ``[ ]``
   Matches any character(s) inside the brackets
 ``[^ ]``
@@ -151,12 +156,9 @@
 expression ``^ab+d$`` matches ``abbd`` but not ``ababd``, and the regular
 expression ``^(ab|cd)$`` matches ``ab`` but not ``abd``.
 
-Backslash (``\``) characters in regular expressions are interpreted
-literally and do not escape anything or represent placeholders.
-However, CMake language :ref:`Escape Sequences` such as ``\t``,
-``\r``, ``\n``, and ``\\`` may be used to construct literal tabs,
-carriage returns, newlines, and backslashes (respectively) to pass
-in a regex.  For example:
+CMake language :ref:`Escape Sequences` such as ``\t``, ``\r``, ``\n``,
+and ``\\`` may be used to construct literal tabs, carriage returns,
+newlines, and backslashes (respectively) to pass in a regex.  For example:
 
 * The quoted argument ``"[ \t\r\n]"`` specifies a regex that matches
   any single whitespace character.
@@ -164,6 +166,11 @@
   a single forward slash ``/`` or backslash ``\``.
 * The quoted argument ``"[A-Za-z0-9_]"`` specifies a regex that matches
   any single "word" character in the C locale.
+* The quoted argument ``"\\(\\a\\+b\\)"`` specifies a regex that matches
+  the exact string ``(a+b)``.  Each ``\\`` is parsed in a quoted argument
+  as just ``\``, so the regex itself is actually ``\(\a\+\b\)``.  This
+  can alternatively be specified in a :ref:`bracket argument` without
+  having to escape the backslashes, e.g. ``[[\(\a\+\b\)]]``.
 
 Manipulation
 ^^^^^^^^^^^^
diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst
index e1c374e..58f312e 100644
--- a/Help/command/target_link_libraries.rst
+++ b/Help/command/target_link_libraries.rst
@@ -43,6 +43,9 @@
   the library instead of using the full path
   (e.g. ``/usr/lib/libfoo.so`` becomes ``-lfoo``).
 
+  The full path to the target's artifact will be quoted/escaped for
+  the shell automatically.
+
 * **A full path to a library file**: The generated link line will
   normally preserve the full path to the file. The buildsystem will
   have a dependency to re-link ``<target>`` if the library file changes.
@@ -62,9 +65,15 @@
   imported into generated project files.  This is not supported by other
   generators.
 
+  The full path to the library file will be quoted/escaped for
+  the shell automatically.
+
 * **A plain library name**: The generated link line will ask the linker
   to search for the library (e.g. ``foo`` becomes ``-lfoo`` or ``foo.lib``).
 
+  The library name/flag is treated as a command-line string fragment and
+  will be used with no extra quoting or escaping.
+
 * **A link flag**: Item names starting with ``-``, but not ``-l`` or
   ``-framework``, are treated as linker flags.  Note that such flags will
   be treated like any other library link item for purposes of transitive
@@ -78,6 +87,23 @@
   flags explicitly. The flags will then be placed at the toolchain-defined
   flag position in the link command.
 
+  The link flag is treated as a command-line string fragment and
+  will be used with no extra quoting or escaping.
+
+* **A generator expression**: A ``$<...>`` :manual:`generator expression
+  <cmake-generator-expressions(7)>` may evaluate to any of the above
+  items or to a :ref:`;-list <CMake Language Lists>` of them.
+  If the ``...`` contains any ``;`` characters, e.g. after evaluation
+  of a ``${list}`` variable, be sure to use an explicitly quoted
+  argument ``"$<...>"`` so that this command receives it as a
+  single ``<item>``.
+
+  Additionally, a generator expression may be used as a fragment of
+  any of the above items, e.g. ``foo$<1:_d>``.
+
+  Note that generator expressions will not be used in OLD handling of
+  policy :policy:`CMP0003` or policy :policy:`CMP0004`.
+
 * A ``debug``, ``optimized``, or ``general`` keyword immediately followed
   by another ``<item>``.  The item following such a keyword will be used
   only for the corresponding build configuration.  The ``debug`` keyword
@@ -88,18 +114,16 @@
   optional.  Higher granularity may be achieved for per-configuration
   rules by creating and linking to
   :ref:`IMPORTED library targets <Imported Targets>`.
+  These keywords are interpreted immediately by this command and therefore
+  have no special meaning when produced by a generator expression.
 
 Items containing ``::``, such as ``Foo::Bar``, are assumed to be
 :ref:`IMPORTED <Imported Targets>` or :ref:`ALIAS <Alias Targets>` library
 target names and will cause an error if no such target exists.
 See policy :policy:`CMP0028`.
 
-Arguments to ``target_link_libraries`` may use "generator expressions"
-with the syntax ``$<...>``.  Note however, that generator expressions
-will not be used in OLD handling of :policy:`CMP0003` or :policy:`CMP0004`.
-See the :manual:`cmake-generator-expressions(7)` manual for available
-expressions.  See the :manual:`cmake-buildsystem(7)` manual for more on
-defining buildsystem properties.
+See the :manual:`cmake-buildsystem(7)` manual for more on defining
+buildsystem properties.
 
 Libraries for a Target and/or its Dependents
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/envvar/CTEST_PROGRESS_OUTPUT.rst b/Help/envvar/CTEST_PROGRESS_OUTPUT.rst
new file mode 100644
index 0000000..a8e15bc
--- /dev/null
+++ b/Help/envvar/CTEST_PROGRESS_OUTPUT.rst
@@ -0,0 +1,14 @@
+CTEST_PROGRESS_OUTPUT
+---------------------
+
+Boolean environment variable that affects how :manual:`ctest <ctest(1)>`
+command output reports overall progress.  When set to 1, TRUE, ON or anything
+else that evaluates to boolean true, progress is reported by repeatedly
+updating the same line.  This greatly reduces the overall verbosity, but is
+only supported when output is sent directly to a terminal.  If the environment
+variable is not set or has a value that evaluates to false, output is reported
+normally with each test having its own start and end lines logged to the
+output.
+
+The ``--progress`` option to :manual:`ctest <ctest(1)>` overrides this
+environment variable if both are given.
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
index 42aeabc..31aa723 100644
--- a/Help/manual/cmake-env-variables.7.rst
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -53,5 +53,6 @@
    /envvar/CTEST_INTERACTIVE_DEBUG_MODE
    /envvar/CTEST_OUTPUT_ON_FAILURE
    /envvar/CTEST_PARALLEL_LEVEL
+   /envvar/CTEST_PROGRESS_OUTPUT
    /envvar/CTEST_USE_LAUNCHERS_DEFAULT
    /envvar/DASHBOARD_TEST_FROM_CTEST
diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst
index 591f73d..71649ba 100644
--- a/Help/manual/cmake-language.7.rst
+++ b/Help/manual/cmake-language.7.rst
@@ -391,8 +391,9 @@
 
 Literal variable references may consist of alphanumeric characters,
 the characters ``/_.+-``, and `Escape Sequences`_.  Nested references
-may be used to evaluate variables of any name.  (See also policy
-:policy:`CMP0053` documentation for historical considerations.)
+may be used to evaluate variables of any name.  See also policy
+:policy:`CMP0053` documentation for historical considerations and reasons why
+the ``$`` is also technically permitted but is discouraged.
 
 The `Variables`_ section documents the scope of variable names
 and how their values are set.
diff --git a/Help/manual/cmake-server.7.rst b/Help/manual/cmake-server.7.rst
index b4c1436..25d364c 100644
--- a/Help/manual/cmake-server.7.rst
+++ b/Help/manual/cmake-server.7.rst
@@ -308,9 +308,6 @@
 
 indicating that the server is ready for action.
 
-Protocol version 1.3 introduces an optional flag on the target filegroup
-that indicates if the filegroup represents :prop_tgt:`INTERFACE_SOURCES`.
-
 
 Type "globalSettings"
 ^^^^^^^^^^^^^^^^^^^^^
@@ -527,8 +524,6 @@
 
 Each fileGroup object may contain the following keys:
 
-"isInterfaceSources"
-  true if the fileGroup represents :prop_tgt:`INTERFACE_SOURCES`.
 "language"
   contains the programming language used by all files in the group.
 "compileFlags"
@@ -543,8 +538,6 @@
 "defines"
   with a list of defines in the form "SOMEVALUE" or "SOMEVALUE=42". This
   value is encoded in the system's native shell format.
-"isGenerated"
-  true if the files were generated.
 "sources"
   with a list of source files.
 
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 9553d15..e24b10d 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -35,6 +35,19 @@
  which one should be tested.  Example configurations are "Debug" and
  "Release".
 
+``--progress``
+ Enable short progress output from tests.
+
+ When the output of ``ctest`` is being sent directly to a terminal, the
+ progress through the set of tests is reported by updating the same line
+ rather than printing start and end messages for each test on new lines.
+ This can significantly reduce the verbosity of the test output.
+ Test completion messages are still output on their own line for failed
+ tests and the final test summary will also still be logged.
+
+ This option can also be enabled by setting the environment variable
+ :envvar:`CTEST_PROGRESS_OUTPUT`.
+
 ``-V,--verbose``
  Enable verbose output from tests.
 
@@ -55,8 +68,8 @@
 
 ``--output-on-failure``
  Output anything outputted by the test program if the test should fail.
- This option can also be enabled by setting the environment variable
- ``CTEST_OUTPUT_ON_FAILURE``.
+ This option can also be enabled by setting the
+ :envvar:`CTEST_OUTPUT_ON_FAILURE` environment variable
 
 ``-F``
  Enable failover.
@@ -70,7 +83,7 @@
 
  This option tells CTest to run the tests in parallel using given
  number of jobs. This option can also be set by setting the
- environment variable ``CTEST_PARALLEL_LEVEL``.
+ :envvar:`CTEST_PARALLEL_LEVEL` environment variable.
 
  This option can be used with the :prop_test:`PROCESSORS` test property.
 
@@ -867,7 +880,7 @@
 
   * `CTest Script`_ variable: :variable:`CTEST_CONFIGURATION_TYPE`
   * :module:`CTest` module variable: ``DEFAULT_CTEST_CONFIGURATION_TYPE``,
-    initialized by the ``CMAKE_CONFIG_TYPE`` environment variable
+    initialized by the :envvar:`CMAKE_CONFIG_TYPE` environment variable
 
 ``LabelsForSubprojects``
   Specify a semicolon-separated list of labels that will be treated as
diff --git a/Help/policy/CMP0053.rst b/Help/policy/CMP0053.rst
index 2620a60..032b3e5 100644
--- a/Help/policy/CMP0053.rst
+++ b/Help/policy/CMP0053.rst
@@ -16,6 +16,10 @@
 * Literal ``${VAR}`` reference syntax may contain only
   alphanumeric characters (``A-Z``, ``a-z``, ``0-9``) and
   the characters ``_``, ``.``, ``/``, ``-``, and ``+``.
+  Note that ``$`` is technically allowed in the ``NEW`` behavior, but is
+  invalid for ``OLD`` behavior.  This is due to an oversight during the
+  implementation of :policy:`CMP0053` and its use as a literal variable
+  reference is discouraged for this reason.
   Variables with other characters in their name may still
   be referenced indirectly, e.g.
 
diff --git a/Help/policy/CMP0077.rst b/Help/policy/CMP0077.rst
index 8efe198..44797b6 100644
--- a/Help/policy/CMP0077.rst
+++ b/Help/policy/CMP0077.rst
@@ -3,10 +3,46 @@
 
 :command:`option` honors normal variables.
 
-The ``OLD`` behavior for this policy is to clear any existing normal variables
-with the same name.  The ``NEW`` behavior for this policy is to not create
-a cache entry or modify any existing normal variables if a normal variable
-with the same name already exists.
+The :command:`option` command is typically used to create a cache entry
+to allow users to set the option.  However, there are cases in which a
+normal (non-cached) variable of the same name as the option may be
+defined by the project prior to calling the :command:`option` command.
+For example, a project that embeds another project as a subdirectory
+may want to hard-code options of the subproject to build the way it needs.
+
+For historical reasons in CMake 3.12 and below the :command:`option`
+command *removes* a normal (non-cached) variable of the same name when:
+
+* a cache entry of the specified name does not exist at all, or
+* a cache entry of the specified name exists but has not been given
+  a type (e.g. via ``-D<name>=ON`` on the command line).
+
+In both of these cases (typically on the first run in a new build tree),
+the :command:`option` command gives the cache entry type ``BOOL`` and
+removes any normal (non-cached) variable of the same name.  In the
+remaining case that the cache entry of the specified name already
+exists and has a type (typically on later runs in a build tree), the
+:command:`option` command changes nothing and any normal variable of
+the same name remains set.
+
+In CMake 3.13 and above the :command:`option` command prefers to
+do nothing when a normal variable of the given name already exists.
+It does not create or update a cache entry or remove the normal variable.
+The new behavior is consistent between the first and later runs in a
+build tree.  This policy provides compatibility with projects that have
+not been updated to expect the new behavior.
+
+When the :command:`option` command sees a normal variable of the given
+name:
+
+* The ``OLD`` behavior for this policy is to proceed even when a normal
+  variable of the same name exists.  If the cache entry does not already
+  exist and have a type then it is created and/or given a type and the
+  normal variable is removed.
+
+* The ``NEW`` behavior for this policy is to do nothing when a normal
+  variable of the same name exists.  The normal variable is not removed.
+  The cache entry is not created or updated and is ignored if it exists.
 
 This policy was introduced in CMake version 3.13.  CMake version
 |release| warns when the policy is not set and uses ``OLD`` behavior.
diff --git a/Help/release/3.13.rst b/Help/release/3.13.rst
index b08f21d..f547556 100644
--- a/Help/release/3.13.rst
+++ b/Help/release/3.13.rst
@@ -20,7 +20,7 @@
 * The :generator:`Xcode` generator learned to configure more Xcode Scheme
   fields.  See the :variable:`CMAKE_XCODE_GENERATE_SCHEME` variable.
 
-* The :generator:`Green Hills MULTI` generator has been udpated:
+* The :generator:`Green Hills MULTI` generator has been updated:
 
   - Added support for architecture selection through
     :variable:`CMAKE_GENERATOR_PLATFORM`:
@@ -61,9 +61,6 @@
 * The :command:`add_link_options` command was created to add link
   options in the current directory.
 
-* The :command:`install(CODE)` and :command:`install(SCRIPT)` commands
-  learned to support generator expressions.
-
 * The :command:`install(TARGETS)` command learned to install targets
   created outside the current directory.
 
@@ -157,6 +154,10 @@
 * The :module:`FindPkgConfig` module gained an option to create imported
   targets in global scope.
 
+* The :module:`FindPkgConfig` module gained support for ``<`` and ``>``
+  operators for version checks in addition to the already supported
+  operators ``>=``, ``<=``, and ``=``.
+
 * Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
   gain capability to control order of resource lookup on macOS (Framework) and
   Windows (Registry).
@@ -203,8 +204,13 @@
 Other Changes
 =============
 
-* The :command:`option` command now honors existing normal variables instead
-  of replacing them with a cache entry. See policy :policy:`CMP0077`.
+* The precompiled binaries provided on ``cmake.org`` now include
+  qthelp-format documentation.
+
+* The :command:`option` command now honors an existing normal variable
+  of the same name and does nothing instead of possibly creating a cache
+  entry (or setting its type) and removing the normal variable.
+  See policy :policy:`CMP0077`.
 
 * The :ref:`Makefile Generators` learned to remove custom command and
   custom target byproducts during ``make clean``.
diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst
deleted file mode 100644
index e4cc01e..0000000
--- a/Help/release/dev/0-sample-topic.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-0-sample-topic
---------------
-
-* This is a sample release note for the change in a topic.
-  Developers should add similar notes for each topic branch
-  making a noteworthy change.  Each document should be named
-  and titled to match the topic name to avoid merge conflicts.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 7ef3a8e..fbe4cf6 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -7,8 +7,6 @@
   This file should include the adjacent "dev.txt" file
   in development versions but not in release versions.
 
-.. include:: dev.txt
-
 Releases
 ========
 
diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
index 513276e..a1fa1ff 100644
--- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
+++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
@@ -5,10 +5,19 @@
 
 This variable can be populated with a list of properties to generate
 debug output for when evaluating target properties.  Currently it can
-only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`,
-:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`,
-:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`COMPILE_FEATURES`,
-:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property
-listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other
-``COMPATIBLE_INTERFACE_`` properties.  It outputs an origin for each entry in
-the target property.  Default is unset.
+only be used when evaluating:
+
+* :prop_tgt:`AUTOUIC_OPTIONS`
+* :prop_tgt:`COMPILE_DEFINITIONS`
+* :prop_tgt:`COMPILE_FEATURES`
+* :prop_tgt:`COMPILE_OPTIONS`
+* :prop_tgt:`INCLUDE_DIRECTORIES`
+* :prop_tgt:`LINK_DIRECTORIES`
+* :prop_tgt:`LINK_OPTIONS`
+* :prop_tgt:`POSITION_INDEPENDENT_CODE`
+* :prop_tgt:`SOURCES`
+
+target properties and any other property listed in
+:prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other
+``COMPATIBLE_INTERFACE_`` properties.  It outputs an origin for each entry
+in the target property.  Default is unset.
diff --git a/Help/variable/CMAKE_OSX_VARIABLE.txt b/Help/variable/CMAKE_OSX_VARIABLE.txt
index 5b84726..16f3c1a 100644
--- a/Help/variable/CMAKE_OSX_VARIABLE.txt
+++ b/Help/variable/CMAKE_OSX_VARIABLE.txt
@@ -2,6 +2,8 @@
 :command:`project` or :command:`enable_language` command invocation
 because it may influence configuration of the toolchain and flags.
 It is intended to be set locally by the user creating a build tree.
+This variable should be set as a ``CACHE`` entry (or else CMake may
+remove it while initializing a cache entry of the same name).
 
 Despite the ``OSX`` part in the variable name(s) they apply also to
 other SDKs than macOS like iOS, tvOS, or watchOS.
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index 31db25a..613ba1a 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -224,17 +224,21 @@
 external file causes this function to fail the verification.
 #]=======================================================================]
 
+function(_warn_cmp0080)
+  message(AUTHOR_WARNING
+    "Policy CMP0080 is not set: BundleUtilities prefers not to be included at configure time. "
+    "Run \"cmake --help-policy CMP0080\" for policy details. "
+    "Use the cmake_policy command to set the policy and suppress this warning."
+    )
+endfunction()
+
 # Do not include this module at configure time!
 if(DEFINED CMAKE_GENERATOR)
   cmake_policy(GET CMP0080 _BundleUtilities_CMP0080)
   if(_BundleUtilities_CMP0080 STREQUAL "NEW")
     message(FATAL_ERROR "BundleUtilities cannot be included at configure time!")
-  elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD")
-    message(AUTHOR_WARNING
-      "Policy CMP0080 is not set: BundleUtilities prefers not to be included at configure time. "
-      "Run \"cmake --help-policy CMP0080\" for policy details. "
-      "Use the cmake_policy command to set the policy and suppress this warning."
-      )
+  elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD" AND NOT _CMP0080_SUPPRESS_WARNING)
+    _warn_cmp0080()
   endif()
 endif()
 
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index 1653b55..e23470b 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -33,6 +33,14 @@
     set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ")
     set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP)
 
+    if(CMAKE_${lang}_COMPILER_TARGET)
+      if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0)
+        list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-target" "${CMAKE_${lang}_COMPILER_TARGET}")
+      else()
+        list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
+      endif()
+    endif()
+
     set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
     set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
 
diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake
index e758f3a..c69cd38 100644
--- a/Modules/DeployQt4.cmake
+++ b/Modules/DeployQt4.cmake
@@ -1,388 +1,400 @@
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
 # file Copyright.txt or https://cmake.org/licensing for details.
 
-#.rst:
-# DeployQt4
-# ---------
-#
-# Functions to help assemble a standalone Qt4 executable.
-#
-# A collection of CMake utility functions useful for deploying Qt4
-# executables.
-#
-# The following functions are provided by this module:
-#
-# ::
-#
-#    write_qt4_conf
-#    resolve_qt4_paths
-#    fixup_qt4_executable
-#    install_qt4_plugin_path
-#    install_qt4_plugin
-#    install_qt4_executable
-#
-# Requires CMake 2.6 or greater because it uses function and
-# PARENT_SCOPE.  Also depends on BundleUtilities.cmake.
-#
-# ::
-#
-#   WRITE_QT4_CONF(<qt_conf_dir> <qt_conf_contents>)
-#
-# Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>.
-#
-# ::
-#
-#   RESOLVE_QT4_PATHS(<paths_var> [<executable_path>])
-#
-# Loop through <paths_var> list and if any don't exist resolve them
-# relative to the <executable_path> (if supplied) or the
-# CMAKE_INSTALL_PREFIX.
-#
-# ::
-#
-#   FIXUP_QT4_EXECUTABLE(<executable>
-#     [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>])
-#
-# Copies Qt plugins, writes a Qt configuration file (if needed) and
-# fixes up a Qt4 executable using BundleUtilities so it is standalone
-# and can be drag-and-drop copied to another machine as long as all of
-# the system libraries are compatible.
-#
-# <executable> should point to the executable to be fixed-up.
-#
-# <qtplugins> should contain a list of the names or paths of any Qt
-# plugins to be installed.
-#
-# <libs> will be passed to BundleUtilities and should be a list of any
-# already installed plugins, libraries or executables to also be
-# fixed-up.
-#
-# <dirs> will be passed to BundleUtilities and should contain and
-# directories to be searched to find library dependencies.
-#
-# <plugins_dir> allows an custom plugins directory to be used.
-#
-# <request_qt_conf> will force a qt.conf file to be written even if not
-# needed.
-#
-# ::
-#
-#   INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var
-#                           <plugins_dir> <component> <configurations>)
-#
-# Install (or copy) a resolved <plugin> to the default plugins directory
-# (or <plugins_dir>) relative to <executable> and store the result in
-# <installed_plugin_path_var>.
-#
-# If <copy> is set to TRUE then the plugins will be copied rather than
-# installed.  This is to allow this module to be used at CMake time
-# rather than install time.
-#
-# If <component> is set then anything installed will use this COMPONENT.
-#
-# ::
-#
-#   INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var
-#                      <plugins_dir> <component>)
-#
-# Install (or copy) an unresolved <plugin> to the default plugins
-# directory (or <plugins_dir>) relative to <executable> and store the
-# result in <installed_plugin_path_var>.  See documentation of
-# INSTALL_QT4_PLUGIN_PATH.
-#
-# ::
-#
-#   INSTALL_QT4_EXECUTABLE(<executable>
-#     [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>])
-#
-# Installs Qt plugins, writes a Qt configuration file (if needed) and
-# fixes up a Qt4 executable using BundleUtilities so it is standalone
-# and can be drag-and-drop copied to another machine as long as all of
-# the system libraries are compatible.  The executable will be fixed-up
-# at install time.  <component> is the COMPONENT used for bundle fixup
-# and plugin installation.  See documentation of FIXUP_QT4_BUNDLE.
+#[=======================================================================[.rst:
+DeployQt4
+---------
+
+Functions to help assemble a standalone Qt4 executable.
+
+A collection of CMake utility functions useful for deploying Qt4
+executables.
+
+The following functions are provided by this module:
+
+::
+
+   write_qt4_conf
+   resolve_qt4_paths
+   fixup_qt4_executable
+   install_qt4_plugin_path
+   install_qt4_plugin
+   install_qt4_executable
+
+Requires CMake 2.6 or greater because it uses function and
+PARENT_SCOPE.  Also depends on BundleUtilities.cmake.
+
+::
+
+  WRITE_QT4_CONF(<qt_conf_dir> <qt_conf_contents>)
+
+Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>.
+
+::
+
+  RESOLVE_QT4_PATHS(<paths_var> [<executable_path>])
+
+Loop through <paths_var> list and if any don't exist resolve them
+relative to the <executable_path> (if supplied) or the
+CMAKE_INSTALL_PREFIX.
+
+::
+
+  FIXUP_QT4_EXECUTABLE(<executable>
+    [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>])
+
+Copies Qt plugins, writes a Qt configuration file (if needed) and
+fixes up a Qt4 executable using BundleUtilities so it is standalone
+and can be drag-and-drop copied to another machine as long as all of
+the system libraries are compatible.
+
+<executable> should point to the executable to be fixed-up.
+
+<qtplugins> should contain a list of the names or paths of any Qt
+plugins to be installed.
+
+<libs> will be passed to BundleUtilities and should be a list of any
+already installed plugins, libraries or executables to also be
+fixed-up.
+
+<dirs> will be passed to BundleUtilities and should contain and
+directories to be searched to find library dependencies.
+
+<plugins_dir> allows an custom plugins directory to be used.
+
+<request_qt_conf> will force a qt.conf file to be written even if not
+needed.
+
+::
+
+  INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var
+                          <plugins_dir> <component> <configurations>)
+
+Install (or copy) a resolved <plugin> to the default plugins directory
+(or <plugins_dir>) relative to <executable> and store the result in
+<installed_plugin_path_var>.
+
+If <copy> is set to TRUE then the plugins will be copied rather than
+installed.  This is to allow this module to be used at CMake time
+rather than install time.
+
+If <component> is set then anything installed will use this COMPONENT.
+
+::
+
+  INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var
+                     <plugins_dir> <component>)
+
+Install (or copy) an unresolved <plugin> to the default plugins
+directory (or <plugins_dir>) relative to <executable> and store the
+result in <installed_plugin_path_var>.  See documentation of
+INSTALL_QT4_PLUGIN_PATH.
+
+::
+
+  INSTALL_QT4_EXECUTABLE(<executable>
+    [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>])
+
+Installs Qt plugins, writes a Qt configuration file (if needed) and
+fixes up a Qt4 executable using BundleUtilities so it is standalone
+and can be drag-and-drop copied to another machine as long as all of
+the system libraries are compatible.  The executable will be fixed-up
+at install time.  <component> is the COMPONENT used for bundle fixup
+and plugin installation.  See documentation of FIXUP_QT4_BUNDLE.
+#]=======================================================================]
 
 # The functions defined in this file depend on the fixup_bundle function
 # (and others) found in BundleUtilities.cmake
 
-include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake")
 set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
 set(DeployQt4_apple_plugins_dir "PlugIns")
 
 function(write_qt4_conf qt_conf_dir qt_conf_contents)
-        set(qt_conf_path "${qt_conf_dir}/qt.conf")
-        message(STATUS "Writing ${qt_conf_path}")
-        file(WRITE "${qt_conf_path}" "${qt_conf_contents}")
+  set(qt_conf_path "${qt_conf_dir}/qt.conf")
+  message(STATUS "Writing ${qt_conf_path}")
+  file(WRITE "${qt_conf_path}" "${qt_conf_contents}")
 endfunction()
 
 function(resolve_qt4_paths paths_var)
-        unset(executable_path)
-        if(ARGC GREATER 1)
-                set(executable_path ${ARGV1})
-        endif()
+  unset(executable_path)
+  if(ARGC GREATER 1)
+    set(executable_path ${ARGV1})
+  endif()
 
-        set(paths_resolved)
-        foreach(path ${${paths_var}})
-                if(EXISTS "${path}")
-                        list(APPEND paths_resolved "${path}")
-                else()
-                        if(${executable_path})
-                                list(APPEND paths_resolved "${executable_path}/${path}")
-                        else()
-                                list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}")
-                        endif()
-                endif()
-        endforeach()
-        set(${paths_var} ${paths_resolved} PARENT_SCOPE)
+  set(paths_resolved)
+  foreach(path ${${paths_var}})
+    if(EXISTS "${path}")
+      list(APPEND paths_resolved "${path}")
+    else()
+      if(${executable_path})
+        list(APPEND paths_resolved "${executable_path}/${path}")
+      else()
+        list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}")
+      endif()
+    endif()
+  endforeach()
+  set(${paths_var} ${paths_resolved} PARENT_SCOPE)
 endfunction()
 
-function(fixup_qt4_executable executable)
-        unset(qtplugins)
-        if(ARGC GREATER 1)
-                set(qtplugins ${ARGV1})
-        endif()
-        unset(libs)
-        if(ARGC GREATER 2)
-                set(libs ${ARGV2})
-        endif()
-        unset(dirs)
-        if(ARGC GREATER 3)
-                set(dirs ${ARGV3})
-        endif()
-        unset(plugins_dir)
-        if(ARGC GREATER 4)
-                set(plugins_dir ${ARGV4})
-        endif()
-        unset(request_qt_conf)
-        if(ARGC GREATER 5)
-                set(request_qt_conf ${ARGV5})
-        endif()
+cmake_policy(GET CMP0080 _cmp0080_value)
+if(NOT DEFINED CMAKE_GENERATOR OR NOT _cmp0080_value STREQUAL "NEW")
+  set(_CMP0080_SUPPRESS_WARNING TRUE)
+  include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake")
+  unset(_CMP0080_SUPPRESS_WARNING)
 
-        message(STATUS "fixup_qt4_executable")
-        message(STATUS "  executable='${executable}'")
-        message(STATUS "  qtplugins='${qtplugins}'")
-        message(STATUS "  libs='${libs}'")
-        message(STATUS "  dirs='${dirs}'")
-        message(STATUS "  plugins_dir='${plugins_dir}'")
-        message(STATUS "  request_qt_conf='${request_qt_conf}'")
+  function(fixup_qt4_executable executable)
+    cmake_policy(GET CMP0080 _cmp0080_value)
+    if(_cmp0080_value STREQUAL "" AND DEFINED CMAKE_GENERATOR)
+      _warn_cmp0080()
+    endif()
 
-        if(QT_LIBRARY_DIR)
-                list(APPEND dirs "${QT_LIBRARY_DIR}")
-        endif()
-        if(QT_BINARY_DIR)
-                list(APPEND dirs "${QT_BINARY_DIR}")
-        endif()
+    unset(qtplugins)
+    if(ARGC GREATER 1)
+      set(qtplugins ${ARGV1})
+    endif()
+    unset(libs)
+    if(ARGC GREATER 2)
+      set(libs ${ARGV2})
+    endif()
+    unset(dirs)
+    if(ARGC GREATER 3)
+      set(dirs ${ARGV3})
+    endif()
+    unset(plugins_dir)
+    if(ARGC GREATER 4)
+      set(plugins_dir ${ARGV4})
+    endif()
+    unset(request_qt_conf)
+    if(ARGC GREATER 5)
+      set(request_qt_conf ${ARGV5})
+    endif()
 
-        if(APPLE)
-                set(qt_conf_dir "${executable}/Contents/Resources")
-                set(executable_path "${executable}")
-                set(write_qt_conf TRUE)
-                if(NOT DEFINED plugins_dir)
-                        set(plugins_dir "${DeployQt4_apple_plugins_dir}")
-                endif()
-        else()
-                get_filename_component(executable_path "${executable}" PATH)
-                if(NOT executable_path)
-                        set(executable_path ".")
-                endif()
-                set(qt_conf_dir "${executable_path}")
-                set(write_qt_conf ${request_qt_conf})
-        endif()
+    message(STATUS "fixup_qt4_executable")
+    message(STATUS "  executable='${executable}'")
+    message(STATUS "  qtplugins='${qtplugins}'")
+    message(STATUS "  libs='${libs}'")
+    message(STATUS "  dirs='${dirs}'")
+    message(STATUS "  plugins_dir='${plugins_dir}'")
+    message(STATUS "  request_qt_conf='${request_qt_conf}'")
 
-        foreach(plugin ${qtplugins})
-                set(installed_plugin_path "")
-                install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
-                list(APPEND libs ${installed_plugin_path})
-        endforeach()
+    if(QT_LIBRARY_DIR)
+      list(APPEND dirs "${QT_LIBRARY_DIR}")
+    endif()
+    if(QT_BINARY_DIR)
+      list(APPEND dirs "${QT_BINARY_DIR}")
+    endif()
 
-        foreach(lib ${libs})
-                if(NOT EXISTS "${lib}")
-                        message(FATAL_ERROR "Library does not exist: ${lib}")
-                endif()
-        endforeach()
+    if(APPLE)
+      set(qt_conf_dir "${executable}/Contents/Resources")
+      set(executable_path "${executable}")
+      set(write_qt_conf TRUE)
+      if(NOT DEFINED plugins_dir)
+        set(plugins_dir "${DeployQt4_apple_plugins_dir}")
+      endif()
+    else()
+      get_filename_component(executable_path "${executable}" PATH)
+      if(NOT executable_path)
+        set(executable_path ".")
+      endif()
+      set(qt_conf_dir "${executable_path}")
+      set(write_qt_conf ${request_qt_conf})
+    endif()
 
-        resolve_qt4_paths(libs "${executable_path}")
+    foreach(plugin ${qtplugins})
+      set(installed_plugin_path "")
+      install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
+      list(APPEND libs ${installed_plugin_path})
+    endforeach()
 
-        if(write_qt_conf)
-                set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
-                write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}")
-        endif()
+    foreach(lib ${libs})
+      if(NOT EXISTS "${lib}")
+        message(FATAL_ERROR "Library does not exist: ${lib}")
+      endif()
+    endforeach()
 
-        fixup_bundle("${executable}" "${libs}" "${dirs}")
-endfunction()
+    resolve_qt4_paths(libs "${executable_path}")
+
+    if(write_qt_conf)
+      set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
+      write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}")
+    endif()
+
+    fixup_bundle("${executable}" "${libs}" "${dirs}")
+  endfunction()
+endif()
 
 function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var)
-        unset(plugins_dir)
-        if(ARGC GREATER 4)
-                set(plugins_dir ${ARGV4})
-        endif()
-        unset(component)
-        if(ARGC GREATER 5)
-                set(component ${ARGV5})
-        endif()
+  unset(plugins_dir)
+  if(ARGC GREATER 4)
+    set(plugins_dir ${ARGV4})
+  endif()
+  unset(component)
+  if(ARGC GREATER 5)
+    set(component ${ARGV5})
+  endif()
+  unset(configurations)
+  if(ARGC GREATER 6)
+    set(configurations ${ARGV6})
+  endif()
+
+  if(EXISTS "${plugin}")
+    if(APPLE)
+      if(NOT plugins_dir)
+        set(plugins_dir "${DeployQt4_apple_plugins_dir}")
+      endif()
+      set(plugins_path "${executable}/Contents/${plugins_dir}")
+    else()
+      get_filename_component(plugins_path "${executable}" PATH)
+      if(NOT plugins_path)
+        set(plugins_path ".")
+      endif()
+      if(plugins_dir)
+        string(APPEND plugins_path "/${plugins_dir}")
+      endif()
+    endif()
+
+    set(plugin_group "")
+
+    get_filename_component(plugin_path "${plugin}" PATH)
+    get_filename_component(plugin_parent_path "${plugin_path}" PATH)
+    get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME)
+    get_filename_component(plugin_name "${plugin}" NAME)
+    string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name)
+
+    if("${plugin_parent_dir_name}" STREQUAL "plugins")
+      get_filename_component(plugin_group "${plugin_path}" NAME)
+      set(${plugin_group_var} "${plugin_group}")
+    endif()
+    string(APPEND plugins_path "/${plugin_group}")
+
+    if(${copy})
+      file(MAKE_DIRECTORY "${plugins_path}")
+      file(COPY "${plugin}" DESTINATION "${plugins_path}")
+    else()
+      get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+      if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE))
+        set(configurations CONFIGURATIONS ${configurations})
+      else()
         unset(configurations)
-        if(ARGC GREATER 6)
-                set(configurations ${ARGV6})
-        endif()
-
-        if(EXISTS "${plugin}")
-                if(APPLE)
-                        if(NOT plugins_dir)
-                                set(plugins_dir "${DeployQt4_apple_plugins_dir}")
-                        endif()
-                        set(plugins_path "${executable}/Contents/${plugins_dir}")
-                else()
-                        get_filename_component(plugins_path "${executable}" PATH)
-                        if(NOT plugins_path)
-                                set(plugins_path ".")
-                        endif()
-                        if(plugins_dir)
-                                string(APPEND plugins_path "/${plugins_dir}")
-                        endif()
-                endif()
-
-                set(plugin_group "")
-
-                get_filename_component(plugin_path "${plugin}" PATH)
-                get_filename_component(plugin_parent_path "${plugin_path}" PATH)
-                get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME)
-                get_filename_component(plugin_name "${plugin}" NAME)
-                string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name)
-
-                if("${plugin_parent_dir_name}" STREQUAL "plugins")
-                        get_filename_component(plugin_group "${plugin_path}" NAME)
-                        set(${plugin_group_var} "${plugin_group}")
-                endif()
-                string(APPEND plugins_path "/${plugin_group}")
-
-                if(${copy})
-                        file(MAKE_DIRECTORY "${plugins_path}")
-                        file(COPY "${plugin}" DESTINATION "${plugins_path}")
-                else()
-                        get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
-                        if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE))
-                                set(configurations CONFIGURATIONS ${configurations})
-                        else()
-                                unset(configurations)
-                        endif()
-                        install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
-                endif()
-                set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
-        endif()
+      endif()
+      install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
+    endif()
+    set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
+  endif()
 endfunction()
 
 function(install_qt4_plugin plugin executable copy installed_plugin_path_var)
-        unset(plugins_dir)
-        if(ARGC GREATER 4)
-                set(plugins_dir ${ARGV4})
-        endif()
-        unset(component)
-        if(ARGC GREATER 5)
-                set(component ${ARGV5})
-        endif()
+  unset(plugins_dir)
+  if(ARGC GREATER 4)
+    set(plugins_dir ${ARGV4})
+  endif()
+  unset(component)
+  if(ARGC GREATER 5)
+    set(component ${ARGV5})
+  endif()
 
-        if(EXISTS "${plugin}")
-                install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
-        else()
-                string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
-                set(plugin_release_var "${plugin_var}_RELEASE")
-                set(plugin_debug_var "${plugin_var}_DEBUG")
-                set(plugin_release "${${plugin_release_var}}")
-                set(plugin_debug "${${plugin_debug_var}}")
-                if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}")
-                        message(WARNING "Qt plugin \"${plugin}\" not recognized or found.")
-                endif()
-                if(NOT EXISTS "${${plugin_debug_var}}")
-                        set(plugin_debug "${plugin_release}")
-                endif()
+  if(EXISTS "${plugin}")
+    install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
+  else()
+    string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
+    set(plugin_release_var "${plugin_var}_RELEASE")
+    set(plugin_debug_var "${plugin_var}_DEBUG")
+    set(plugin_release "${${plugin_release_var}}")
+    set(plugin_debug "${${plugin_debug_var}}")
+    if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}")
+      message(WARNING "Qt plugin \"${plugin}\" not recognized or found.")
+    endif()
+    if(NOT EXISTS "${${plugin_debug_var}}")
+      set(plugin_debug "${plugin_release}")
+    endif()
 
-                get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
-                if(_isMultiConfig OR CMAKE_BUILD_TYPE)
-                        set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}")
-                        if (_RELEASE_CONFIGS)
-                            list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]")
-                        endif()
-                        string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}")
-                        install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}")
-                        install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")
-                        unset(_RELEASE_CONFIGS)
+    get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+    if(_isMultiConfig OR CMAKE_BUILD_TYPE)
+      set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}")
+      if (_RELEASE_CONFIGS)
+        list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]")
+      endif()
+      string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}")
+      install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}")
+      install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")
+      unset(_RELEASE_CONFIGS)
 
-                        if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
-                                set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug})
-                        else()
-                                set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release})
-                        endif()
-                else()
-                        install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
-                endif()
-        endif()
-        set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE)
+      if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
+        set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug})
+      else()
+        set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release})
+      endif()
+    else()
+      install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
+    endif()
+  endif()
+  set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE)
 endfunction()
 
 function(install_qt4_executable executable)
-        unset(qtplugins)
-        if(ARGC GREATER 1)
-                set(qtplugins ${ARGV1})
-        endif()
-        unset(libs)
-        if(ARGC GREATER 2)
-                set(libs ${ARGV2})
-        endif()
-        unset(dirs)
-        if(ARGC GREATER 3)
-                set(dirs ${ARGV3})
-        endif()
-        unset(plugins_dir)
-        if(ARGC GREATER 4)
-                set(plugins_dir ${ARGV4})
-        endif()
-        unset(request_qt_conf)
-        if(ARGC GREATER 5)
-                set(request_qt_conf ${ARGV5})
-        endif()
-        unset(component)
-        if(ARGC GREATER 6)
-                set(component ${ARGV6})
-        endif()
+  unset(qtplugins)
+  if(ARGC GREATER 1)
+    set(qtplugins ${ARGV1})
+  endif()
+  unset(libs)
+  if(ARGC GREATER 2)
+    set(libs ${ARGV2})
+  endif()
+  unset(dirs)
+  if(ARGC GREATER 3)
+    set(dirs ${ARGV3})
+  endif()
+  unset(plugins_dir)
+  if(ARGC GREATER 4)
+    set(plugins_dir ${ARGV4})
+  endif()
+  unset(request_qt_conf)
+  if(ARGC GREATER 5)
+    set(request_qt_conf ${ARGV5})
+  endif()
+  unset(component)
+  if(ARGC GREATER 6)
+    set(component ${ARGV6})
+  endif()
 
-        if(QT_LIBRARY_DIR)
-                list(APPEND dirs "${QT_LIBRARY_DIR}")
-        endif()
-        if(QT_BINARY_DIR)
-                list(APPEND dirs "${QT_BINARY_DIR}")
-        endif()
-        if(component)
-                set(component COMPONENT ${component})
-        else()
-                unset(component)
-        endif()
+  if(QT_LIBRARY_DIR)
+    list(APPEND dirs "${QT_LIBRARY_DIR}")
+  endif()
+  if(QT_BINARY_DIR)
+    list(APPEND dirs "${QT_BINARY_DIR}")
+  endif()
+  if(component)
+    set(component COMPONENT ${component})
+  else()
+    unset(component)
+  endif()
 
-        get_filename_component(executable_absolute "${executable}" ABSOLUTE)
-        if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
-            gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
-        elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
-            gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type)
-        endif()
-        if(qtcore_type STREQUAL "system")
-                set(qt_plugins_dir "")
-        endif()
+  get_filename_component(executable_absolute "${executable}" ABSOLUTE)
+  if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
+    gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
+  elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
+    gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type)
+  endif()
+  if(qtcore_type STREQUAL "system")
+    set(qt_plugins_dir "")
+  endif()
 
-        if(QT_IS_STATIC)
-                message(WARNING "Qt built statically: not installing plugins.")
-        else()
-                foreach(plugin ${qtplugins})
-                        set(installed_plugin_paths "")
-                        install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
-                        list(APPEND libs ${installed_plugin_paths})
-                endforeach()
-        endif()
+  if(QT_IS_STATIC)
+    message(WARNING "Qt built statically: not installing plugins.")
+  else()
+    foreach(plugin ${qtplugins})
+      set(installed_plugin_paths "")
+      install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
+      list(APPEND libs ${installed_plugin_paths})
+    endforeach()
+  endif()
 
-        resolve_qt4_paths(libs "")
+  resolve_qt4_paths(libs "")
 
-        install(CODE
-  "include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\")
-  set(BU_CHMOD_BUNDLE_ITEMS TRUE)
-  FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")"
-                ${component}
-        )
+  install(CODE
+"include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\")
+set(BU_CHMOD_BUNDLE_ITEMS TRUE)
+FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")"
+          ${component}
+  )
 endfunction()
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index d684ccd..2000f7f 100644
--- a/Modules/FindBISON.cmake
+++ b/Modules/FindBISON.cmake
@@ -149,17 +149,25 @@
       set(BISON_TARGET_verbose_file "${ReportFile}")
       list(APPEND BISON_TARGET_cmdopt "--report-file=${BISON_TARGET_verbose_file}")
     endif()
+    if(NOT IS_ABSOLUTE "${BISON_TARGET_verbose_file}")
+      set(BISON_TARGET_verbose_file "${CMAKE_CURRENT_SOURCE_DIR}/${BISON_TARGET_verbose_file}")
+    endif()
   endmacro()
 
   # internal macro
   # adds a custom command and sets
-  #   BISON_TARGET_cmdopt, BISON_TARGET_verbose_file, BISON_TARGET_extraoutputs
+  #   BISON_TARGET_cmdopt, BISON_TARGET_extraoutputs
   macro(BISON_TARGET_option_verbose Name BisonOutput filename)
     list(APPEND BISON_TARGET_cmdopt "--verbose")
-    list(APPEND BISON_TARGET_extraoutputs
+    list(APPEND BISON_TARGET_outputs
       "${BISON_TARGET_verbose_file}")
     if (NOT "${filename}" STREQUAL "")
-      add_custom_command(OUTPUT ${filename}
+      if(IS_ABSOLUTE "${filename}")
+        set(BISON_TARGET_verbose_extra_file "${filename}")
+      else()
+        set(BISON_TARGET_verbose_extra_file "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
+      endif()
+      add_custom_command(OUTPUT ${BISON_TARGET_verbose_extra_file}
         COMMAND ${CMAKE_COMMAND} -E copy
         "${BISON_TARGET_verbose_file}"
         "${filename}"
@@ -167,10 +175,10 @@
         DEPENDS
         "${BISON_TARGET_verbose_file}"
         COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}"
-        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-      set(BISON_${Name}_VERBOSE_FILE ${filename})
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
       list(APPEND BISON_TARGET_extraoutputs
-        "${filename}")
+        "${BISON_TARGET_verbose_extra_file}")
+      unset(BISON_TARGET_verbose_extra_file)
     endif()
   endmacro()
 
@@ -226,7 +234,6 @@
       list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}")
 
       add_custom_command(OUTPUT ${BISON_TARGET_outputs}
-        ${BISON_TARGET_extraoutputs}
         COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput}
         VERBATIM
         DEPENDS ${BisonInput}
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 39b9b74..e955bc2 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -53,8 +53,10 @@
 # * SGIMATH
 # * IBMESSL
 # * Intel10_32 (intel mkl v10 32 bit)
-# * Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model)
-# * Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)
+# * Intel10_64lp (intel mkl v10+ 64 bit, threaded code, lp64 model)
+# * Intel10_64lp_seq (intel mkl v10+ 64 bit, sequential code, lp64 model)
+# * Intel10_64ilp (intel mkl v10+ 64 bit, threaded code, ilp64 model)
+# * Intel10_64ilp_seq (intel mkl v10+ 64 bit, sequential code, ilp64 model)
 # * Intel (older versions of mkl 32 and 64 bit)
 # * ACML
 # * ACML_MP
@@ -199,9 +201,14 @@
   endif()
 endif ()
 
-#BLAS in intel mkl 10 library? (em64t 64bit)
+#BLAS in intel mkl 10+ library? (em64t 64bit)
 if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
   if (NOT BLAS_LIBRARIES)
+    if (BLA_VENDOR MATCHES "_64ilp")
+      set(BLAS_mkl_ILP_MODE "ilp64")
+    else ()
+      set(BLAS_mkl_ILP_MODE "lp64")
+    endif ()
     if (NOT WIN32)
       set(LM "-lm")
     endif ()
@@ -230,9 +237,9 @@
             list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
               "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
           endif()
-          if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
+          if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
             list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
-              "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}")
+              "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
           endif ()
 
           # Add threading/sequential libs
@@ -262,23 +269,23 @@
             list(APPEND BLAS_SEARCH_LIBS
               "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide")
           endif ()
-          if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
+          if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
             # old version
             list(APPEND BLAS_SEARCH_LIBS
-              "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide")
+              "mkl_blas95 mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide")
 
             # mkl >= 10.3
             if (CMAKE_C_COMPILER MATCHES ".+gcc")
               list(APPEND BLAS_SEARCH_LIBS
-                "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
+                "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp")
             else ()
               list(APPEND BLAS_SEARCH_LIBS
-                "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
+                "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5")
             endif ()
           endif ()
-          if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
+          if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
             list(APPEND BLAS_SEARCH_LIBS
-              "mkl_intel_lp64 mkl_sequential mkl_core")
+              "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core")
           endif ()
         endif ()
       else ()
@@ -297,9 +304,9 @@
             list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
               "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
           endif()
-          if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
+          if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
             list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
-              "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}")
+              "mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
           endif ()
 
           # Add threading/sequential libs
@@ -329,24 +336,24 @@
             list(APPEND BLAS_SEARCH_LIBS
               "mkl_intel mkl_intel_thread mkl_core guide")
           endif ()
-          if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
+          if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
 
             # old version
             list(APPEND BLAS_SEARCH_LIBS
-              "mkl_intel_lp64 mkl_intel_thread mkl_core guide")
+              "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide")
 
             # mkl >= 10.3
             if (CMAKE_C_COMPILER MATCHES ".+gcc")
               list(APPEND BLAS_SEARCH_LIBS
-                "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
+                "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp")
             else ()
               list(APPEND BLAS_SEARCH_LIBS
-                "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
+                "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5")
             endif ()
           endif ()
-          if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
+          if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
             list(APPEND BLAS_SEARCH_LIBS
-              "mkl_intel_lp64 mkl_sequential mkl_core")
+              "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core")
           endif ()
 
           #older vesions of intel mkl libs
@@ -376,6 +383,7 @@
       endforeach ()
 
     endif ()
+    unset(BLAS_mkl_ILP_MODE)
   endif ()
 endif ()
 
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index cc66532..da3d443 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -1755,6 +1755,7 @@
     list(APPEND _boost_RELEASE_NAMES
       ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
       ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
+      ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}
       ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} )
     if(_boost_STATIC_RUNTIME_WORKAROUND)
       set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index a3c87f8..7ca9950 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -278,6 +278,12 @@
       find_package(Threads REQUIRED)
     endif()
 
+    if (BLA_VENDOR MATCHES "_64ilp")
+      set(BLAS_mkl_ILP_MODE "ilp64")
+    else ()
+      set(BLAS_mkl_ILP_MODE "lp64")
+    endif ()
+
     set(LAPACK_SEARCH_LIBS "")
 
     if (BLA_F95)
@@ -292,7 +298,7 @@
       list(APPEND LAPACK_SEARCH_LIBS
         "mkl_intel_c")
       list(APPEND LAPACK_SEARCH_LIBS
-        "mkl_intel_lp64")
+        "mkl_intel_${BLAS_mkl_ILP_MODE}")
     else()
       set(LAPACK_mkl_SEARCH_SYMBOL "cheev")
       set(_LIBRARIES LAPACK_LIBRARIES)
@@ -303,7 +309,7 @@
         "mkl_lapack")
       # new >= 10.3
       list(APPEND LAPACK_SEARCH_LIBS
-        "mkl_gf_lp64")
+        "mkl_gf_${BLAS_mkl_ILP_MODE}")
     endif()
 
     # First try empty lapack libs
@@ -332,6 +338,8 @@
           )
       endif ()
     endforeach ()
+
+    unset(BLAS_mkl_ILP_MODE)
   endif ()
 endif()
 else()
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 3934867..06beb7d 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -397,7 +397,7 @@
       set(_pkg_check_modules_exist_query)
 
       # check whether version is given
-      if (_pkg_check_modules_pkg MATCHES "(.*[^><])(>=|=|<=)(.*)")
+      if (_pkg_check_modules_pkg MATCHES "(.*[^><])(=|[><]=?)(.*)")
         set(_pkg_check_modules_pkg_name "${CMAKE_MATCH_1}")
         set(_pkg_check_modules_pkg_op "${CMAKE_MATCH_2}")
         set(_pkg_check_modules_pkg_ver "${CMAKE_MATCH_3}")
@@ -415,9 +415,11 @@
       list(APPEND _pkg_check_modules_packages    "${_pkg_check_modules_pkg_name}")
 
       # create the final query which is of the format:
+      # * <pkg-name> > <version>
       # * <pkg-name> >= <version>
       # * <pkg-name> = <version>
       # * <pkg-name> <= <version>
+      # * <pkg-name> < <version>
       # * --exists <pkg-name>
       list(APPEND _pkg_check_modules_exist_query --print-errors --short-errors)
       if (_pkg_check_modules_pkg_op)
@@ -538,12 +540,15 @@
   :command:`target_link_libraries`. The ``GLOBAL`` argument will make the
   imported target available in global scope.
 
-  Each ``<moduleSpec>`` must be in one of the following formats::
+  Each ``<moduleSpec>`` can be either a bare module name or it can be a
+  module name with a version constraint (operators ``=``, ``<``, ``>``,
+  ``<=`` and ``>=`` are supported).  The following are examples for a module
+  named ``foo`` with various constraints::
 
-    {moduleName}            ... matches any version
-    {moduleName}>={version} ... at least version <version> is required
-    {moduleName}={version}  ... exactly version <version> is required
-    {moduleName}<={version} ... modules must not be newer than <version>
+    foo           # Any version matches
+    foo<2         # Only match versions before 2
+    foo>=3.1      # Match any version from 3.1 or later
+    foo=1.2.3     # Foo must be exactly version 1.2.3
 
   The following variables may be set upon return.  Two sets of values exist,
   one for the common case (``<XXX> = <prefix>``) and another for the
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index a8a73a7..5b1ed4b 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -230,7 +230,7 @@
   endif()
 endif()
 
-# Anaconda distribution: define which architectures can be used
+# Python and Anaconda distributions: define which architectures can be used
 if (CMAKE_SIZEOF_VOID_P)
   # In this case, search only for 64bit or 32bit
   math (EXPR _${_PYTHON_PREFIX}_ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
@@ -336,9 +336,13 @@
                     NAMES_PER_DIR
                     HINTS ${_${_PYTHON_PREFIX}_HINTS}
                     PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                           [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
@@ -393,9 +397,13 @@
                           ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
                     NAMES_PER_DIR
                     PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                           [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
@@ -463,6 +471,23 @@
   endif()
 
   if (${_PYTHON_PREFIX}_Interpreter_FOUND)
+    if (NOT CMAKE_SIZEOF_VOID_P)
+      # determine interpreter architecture
+      execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)"
+                       RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+                       OUTPUT_VARIABLE ${_PYTHON_PREFIX}_IS64BIT
+                       ERROR_VARIABLE ${_PYTHON_PREFIX}_IS64BIT)
+      if (NOT _${_PYTHON_PREFIX}_RESULT)
+        if (${_PYTHON_PREFIX}_IS64BIT)
+          set (_${_PYTHON_PREFIX}_ARCH 64)
+          set (_${_PYTHON_PREFIX}_ARCH2 64)
+        else()
+          set (_${_PYTHON_PREFIX}_ARCH 32)
+          set (_${_PYTHON_PREFIX}_ARCH2 32)
+        endif()
+      endif()
+    endif()
+
     # retrieve interpreter identity
     execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -V
                      RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
@@ -769,9 +794,15 @@
 
       set (_${_PYTHON_PREFIX}_REGISTRY_PATHS
         [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+        [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+        [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
         [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+        [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
         [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath])
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath])
 
       if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
         find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 3ac1ce2..6da87a8 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -121,6 +121,34 @@
 unset(_PYTHON2_VERSIONS)
 unset(_PYTHON3_VERSIONS)
 
+# Python distribution: define which architectures can be used
+if (CMAKE_SIZEOF_VOID_P)
+  # In this case, search only for 64bit or 32bit
+  math (EXPR _PYTHON_ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
+  set (_PYTHON_ARCH2 _PYTHON_PREFIX_ARCH})
+else()
+  if (PYTHON_EXECUTABLE)
+    # determine interpreter architecture
+    execute_process (COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)"
+                     RESULT_VARIABLE _PYTHON_RESULT
+                     OUTPUT_VARIABLE _PYTHON_IS64BIT
+                     ERROR_VARIABLE _PYTHON_IS64BIT)
+      if (NOT _PYTHON_RESULT)
+        if (_PYTHON_IS64BIT)
+          set (_PYTHON_ARCH 64)
+          set (_PYTHON_ARCH2 64)
+        else()
+          set (_PYTHON_ARCH 32)
+          set (_PYTHON_ARCH2 32)
+        endif()
+      endif()
+  else()
+    # architecture unknown, search for both 64bit and 32bit
+    set (_PYTHON_ARCH 64)
+    set (_PYTHON_ARCH2 32)
+  endif()
+endif()
+
 foreach(_CURRENT_VERSION ${_Python_VERSIONS})
   string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
   if(WIN32)
@@ -130,9 +158,17 @@
       HINTS ${_Python_LIBRARY_PATH_HINT}
       PATHS
       [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug
       [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug
       [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
       [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
       )
   endif()
 
@@ -156,7 +192,11 @@
     PATHS
       ${PYTHON_FRAMEWORK_LIBRARIES}
       [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
       [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
   )
   # Look for the static library in the Python config directory
   find_library(PYTHON_LIBRARY
@@ -201,7 +241,11 @@
       PATHS
         ${PYTHON_FRAMEWORK_INCLUDES}
         [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include
         [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
+        [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include
+        [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include
       PATH_SUFFIXES
         python${_CURRENT_VERSION}mu
         python${_CURRENT_VERSION}m
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index a0148dd..75e83ea 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -208,7 +208,9 @@
   add_library(Threads::Threads INTERFACE IMPORTED)
 
   if(THREADS_HAVE_PTHREAD_ARG)
-    set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
+    set_property(TARGET Threads::Threads
+                 PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler -pthread>"
+                                                    "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-pthread>")
   endif()
 
   if(CMAKE_THREAD_LIBS_INIT)
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index 9dd464c..3dfcf8c 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
@@ -276,7 +276,7 @@
 _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}"
   "Read-only architecture-independent data (DATAROOTDIR)")
 
-if(CMAKE_SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$")
+if(CMAKE_SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$")
   _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_INFODIR "info"
     "Info documentation (info)")
   _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_MANDIR "man"
diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake
index 36dd0a0..4ecba05 100644
--- a/Modules/InstallRequiredSystemLibraries.cmake
+++ b/Modules/InstallRequiredSystemLibraries.cmake
@@ -362,7 +362,7 @@
           )
       endif()
 
-      # include the language dll's for vs8 as well as the actuall dll's
+      # include the language dll's for vs8 as well as the actual dll's
       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC")
       # Install the manifest that allows DLLs to be loaded from the
       # directory containing the executable.
@@ -406,7 +406,7 @@
           )
       endif()
 
-      # include the language dll's for vs9 as well as the actuall dll's
+      # include the language dll's for vs9 as well as the actual dll's
       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC")
       # Install the manifest that allows DLLs to be loaded from the
       # directory containing the executable.
@@ -487,7 +487,7 @@
         endif()
       endif()
 
-      # include the language dll's as well as the actuall dll's
+      # include the language dll's as well as the actual dll's
       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFCLOC")
       set(__install__libs ${__install__libs}
         "${MSVC_MFCLOC_DIR}/mfc${v}chs.dll"
diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake
index 3bd5147..2de71ee 100644
--- a/Modules/Internal/CPack/CPackRPM.cmake
+++ b/Modules/Internal/CPack/CPackRPM.cmake
@@ -491,7 +491,7 @@
           list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT)
           list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT)
         else()
-          # location pointed to is ouside WDR so it should be treated as a permanent symlink
+          # location pointed to is outside WDR so it should be treated as a permanent symlink
           set(SYMLINK_POINT_WD_ "${SYMLINK_POINT_}")
 
           unset(SYMLINK_RELOCATIONS)
diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in
index 9001888..f75ae78 100644
--- a/Modules/NSIS.template.in
+++ b/Modules/NSIS.template.in
@@ -847,7 +847,7 @@
 @CPACK_NSIS_DELETE_ICONS@
 @CPACK_NSIS_DELETE_ICONS_EXTRA@
 
-  ;Delete empty start menu parent diretories
+  ;Delete empty start menu parent directories
   StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
 
   startMenuDeleteLoop:
@@ -866,7 +866,7 @@
   Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
 @CPACK_NSIS_DELETE_ICONS_EXTRA@
 
-  ;Delete empty start menu parent diretories
+  ;Delete empty start menu parent directories
   StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
 
   secondStartMenuDeleteLoop:
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
index f739ab1..9ed1e01 100644
--- a/Modules/Platform/Android-Clang.cmake
+++ b/Modules/Platform/Android-Clang.cmake
@@ -40,5 +40,6 @@
   endif()
   if(NOT CMAKE_${lang}_COMPILER_TARGET)
     set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
+    list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
   endif()
 endmacro()
diff --git a/Modules/Platform/GNU.cmake b/Modules/Platform/GNU.cmake
index e8c3b65..fac29a8 100644
--- a/Modules/Platform/GNU.cmake
+++ b/Modules/Platform/GNU.cmake
@@ -8,6 +8,33 @@
 set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
 set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
 
+# Debian policy requires that shared libraries be installed without
+# executable permission.  Fedora policy requires that shared libraries
+# be installed with the executable permission.  Since the native tools
+# create shared libraries with execute permission in the first place a
+# reasonable policy seems to be to install with execute permission by
+# default.  In order to support debian packages we provide an option
+# here.  The option default is based on the current distribution, but
+# packagers can set it explicitly on the command line.
+if(DEFINED CMAKE_INSTALL_SO_NO_EXE)
+  # Store the decision variable in the cache.  This preserves any
+  # setting the user provides on the command line.
+  set(CMAKE_INSTALL_SO_NO_EXE "${CMAKE_INSTALL_SO_NO_EXE}" CACHE INTERNAL
+    "Install .so files without execute permission.")
+else()
+  # Store the decision variable as an internal cache entry to avoid
+  # checking the platform every time.  This option is advanced enough
+  # that only package maintainers should need to adjust it.  They are
+  # capable of providing a setting on the command line.
+  if(EXISTS "/etc/debian_version")
+    set(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
+      "Install .so files without execute permission.")
+  else()
+    set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
+      "Install .so files without execute permission.")
+  endif()
+endif()
+
 set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-gnu[a-z0-9_]*")
 
 include(Platform/UnixPaths)
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index dc4febc..f20a53b 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -500,6 +500,10 @@
   get_property (compile_options SOURCE "${infile}" PROPERTY GENERATED_COMPILE_OPTIONS)
   set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_OPTIONS $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_COMPILE_OPTIONS>> ${compile_options})
 
+  if (SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG MATCHES "php")
+    set_property (SOURCE "${swig_generated_file_fullname}" APPEND PROPERTY INCLUDE_DIRECTORIES "${outdir}")
+  endif()
+
   set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files} PARENT_SCOPE)
 
   # legacy support
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 129c6fb..626dbb8 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
-set(CMake_VERSION_MINOR 12)
-set(CMake_VERSION_PATCH 20181003)
-#set(CMake_VERSION_RC 1)
+set(CMake_VERSION_MINOR 13)
+set(CMake_VERSION_PATCH 0)
+set(CMake_VERSION_RC 1)
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 6b62bb4..a87473d 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -563,7 +563,7 @@
 
   // now that we have done most of the error checking finally run the
   // dashboard, we may be asked to repeatedly run this dashboard, such as
-  // for a continuous, do we ned to run it more than once?
+  // for a continuous, do we need to run it more than once?
   if (this->ContinuousDuration >= 0) {
     this->UpdateElapsedTime();
     auto ending_time =
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index 822363d..83dde3f 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -160,7 +160,7 @@
 {
   // this method parses lines from the .mcov file
   // each line has ^COVERAGE(...) in it, and there
-  // are several varients of coverage lines:
+  // are several variants of coverage lines:
   //
   // ^COVERAGE("DIC11","PR1",0)="2:0:0:0"
   //          ( file  , entry, line ) = "number_executed:timing_info"
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 4aa52c3..da3daf8 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -878,12 +878,13 @@
                                          const std::string& projectName,
                                          bool dryRun)
 {
-  std::string buildDir = cmSystemTools::ConvertToOutputPath(bindir);
-  std::string sln = buildDir + "\\" + projectName + ".sln";
+  std::string sln = bindir + "/" + projectName + ".sln";
 
   if (dryRun) {
     return cmSystemTools::FileExists(sln, true);
   }
 
+  sln = cmSystemTools::ConvertToOutputPath(sln);
+
   return std::async(std::launch::async, OpenSolution, sln).get();
 }
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index 3a90f4c..f7e6e44 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmInstallScriptGenerator.h"
 
-#include "cmGeneratorExpression.h"
 #include "cmScriptGenerator.h"
 
 #include <ostream>
@@ -17,47 +16,24 @@
   , Script(script)
   , Code(code)
 {
-  // We need per-config actions if the script has generator expressions.
-  if (cmGeneratorExpression::Find(Script) != std::string::npos) {
-    this->ActionsPerConfig = true;
-  }
 }
 
 cmInstallScriptGenerator::~cmInstallScriptGenerator()
 {
 }
 
-void cmInstallScriptGenerator::Compute(cmLocalGenerator* lg)
+void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
 {
-  this->LocalGenerator = lg;
-}
+  Indent indent;
+  std::string component_test =
+    this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
+  os << indent << "if(" << component_test << ")\n";
 
-void cmInstallScriptGenerator::AddScriptInstallRule(std::ostream& os,
-                                                    Indent indent,
-                                                    std::string const& script)
-{
   if (this->Code) {
-    os << indent.Next() << script << "\n";
+    os << indent.Next() << this->Script << "\n";
   } else {
-    os << indent.Next() << "include(\"" << script << "\")\n";
+    os << indent.Next() << "include(\"" << this->Script << "\")\n";
   }
-}
 
-void cmInstallScriptGenerator::GenerateScriptActions(std::ostream& os,
-                                                     Indent indent)
-{
-  if (this->ActionsPerConfig) {
-    this->cmInstallGenerator::GenerateScriptActions(os, indent);
-  } else {
-    this->AddScriptInstallRule(os, indent, this->Script);
-  }
-}
-
-void cmInstallScriptGenerator::GenerateScriptForConfig(
-  std::ostream& os, const std::string& config, Indent indent)
-{
-  cmGeneratorExpression ge;
-  std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(this->Script);
-  this->AddScriptInstallRule(os, indent,
-                             cge->Evaluate(this->LocalGenerator, config));
+  os << indent << "endif()\n\n";
 }
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index 534bc1d..fe0f7c6 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -6,13 +6,10 @@
 #include "cmConfigure.h" // IWYU pragma: keep
 
 #include "cmInstallGenerator.h"
-#include "cmScriptGenerator.h"
 
 #include <iosfwd>
 #include <string>
 
-class cmLocalGenerator;
-
 /** \class cmInstallScriptGenerator
  * \brief Generate target installation rules.
  */
@@ -23,18 +20,10 @@
                            const char* component, bool exclude_from_all);
   ~cmInstallScriptGenerator() override;
 
-  void Compute(cmLocalGenerator* lg) override;
-
 protected:
-  void GenerateScriptActions(std::ostream& os, Indent indent) override;
-  void GenerateScriptForConfig(std::ostream& os, const std::string& config,
-                               Indent indent) override;
-  void AddScriptInstallRule(std::ostream& os, Indent indent,
-                            std::string const& script);
-
+  void GenerateScript(std::ostream& os) override;
   std::string Script;
   bool Code;
-  cmLocalGenerator* LocalGenerator;
 };
 
 #endif
diff --git a/Source/cmJsonObjectDictionary.h b/Source/cmJsonObjectDictionary.h
index a4d41f3..8a2b529 100644
--- a/Source/cmJsonObjectDictionary.h
+++ b/Source/cmJsonObjectDictionary.h
@@ -43,4 +43,3 @@
 static const std::string kCTEST_INFO = "ctestInfo";
 static const std::string kMINIMUM_CMAKE_VERSION = "minimumCMakeVersion";
 static const std::string kIS_GENERATOR_PROVIDED_KEY = "isGeneratorProvided";
-static const std::string kIS_INTERFACE_SOURCES_KEY = "isInterfaceSources";
diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx
index a7db75f..4148894 100644
--- a/Source/cmJsonObjects.cxx
+++ b/Source/cmJsonObjects.cxx
@@ -150,8 +150,6 @@
   return array;
 }
 
-const std::string kInterfaceSourcesLanguageDataKey =
-  "INTERFACE_SOURCES_LD_KEY";
 class LanguageData
 {
 public:
@@ -184,12 +182,6 @@
   Defines = std::move(result);
 }
 
-struct FileGroupSources
-{
-  bool IsInterfaceSources;
-  std::vector<std::string> Files;
-};
-
 namespace std {
 
 template <>
@@ -217,35 +209,31 @@
 } // namespace std
 
 static Json::Value DumpSourceFileGroup(const LanguageData& data,
-                                       bool isInterfaceSource,
                                        const std::vector<std::string>& files,
                                        const std::string& baseDir)
 {
   Json::Value result = Json::objectValue;
 
-  if (isInterfaceSource) {
-    result[kIS_INTERFACE_SOURCES_KEY] = true;
-  }
   if (!data.Language.empty()) {
     result[kLANGUAGE_KEY] = data.Language;
-  }
-  if (!data.Flags.empty()) {
-    result[kCOMPILE_FLAGS_KEY] = data.Flags;
-  }
-  if (!data.IncludePathList.empty()) {
-    Json::Value includes = Json::arrayValue;
-    for (auto const& i : data.IncludePathList) {
-      Json::Value tmp = Json::objectValue;
-      tmp[kPATH_KEY] = i.first;
-      if (i.second) {
-        tmp[kIS_SYSTEM_KEY] = i.second;
-      }
-      includes.append(tmp);
+    if (!data.Flags.empty()) {
+      result[kCOMPILE_FLAGS_KEY] = data.Flags;
     }
-    result[kINCLUDE_PATH_KEY] = includes;
-  }
-  if (!data.Defines.empty()) {
-    result[kDEFINES_KEY] = fromStringList(data.Defines);
+    if (!data.IncludePathList.empty()) {
+      Json::Value includes = Json::arrayValue;
+      for (auto const& i : data.IncludePathList) {
+        Json::Value tmp = Json::objectValue;
+        tmp[kPATH_KEY] = i.first;
+        if (i.second) {
+          tmp[kIS_SYSTEM_KEY] = i.second;
+        }
+        includes.append(tmp);
+      }
+      result[kINCLUDE_PATH_KEY] = includes;
+    }
+    if (!data.Defines.empty()) {
+      result[kDEFINES_KEY] = fromStringList(data.Defines);
+    }
   }
 
   result[kIS_GENERATED_KEY] = data.IsGenerated;
@@ -260,19 +248,21 @@
   return result;
 }
 
-static void PopulateFileGroupData(
-  cmGeneratorTarget* target, bool isInterfaceSources,
-  const std::vector<cmSourceFile*>& files, const std::string& config,
-  const std::map<std::string, LanguageData>& languageDataMap,
-  std::unordered_map<LanguageData, FileGroupSources>& fileGroups)
+static Json::Value DumpSourceFilesList(
+  cmGeneratorTarget* target, const std::string& config,
+  const std::map<std::string, LanguageData>& languageDataMap)
 {
+  // Collect sourcefile groups:
+
+  std::vector<cmSourceFile*> files;
+  target->GetSourceFiles(files, config);
+
+  std::unordered_map<LanguageData, std::vector<std::string>> fileGroups;
   for (cmSourceFile* file : files) {
     LanguageData fileData;
     fileData.Language = file->GetLanguage();
-    if (!fileData.Language.empty() || isInterfaceSources) {
-      const LanguageData& ld = isInterfaceSources
-        ? languageDataMap.at(kInterfaceSourcesLanguageDataKey)
-        : languageDataMap.at(fileData.Language);
+    if (!fileData.Language.empty()) {
+      const LanguageData& ld = languageDataMap.at(fileData.Language);
       cmLocalGenerator* lg = target->GetLocalGenerator();
       cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
                                                         fileData.Language);
@@ -300,14 +290,10 @@
         lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file);
 
         for (const auto& include : includes) {
-          // INTERFACE_LIBRARY targets do not support the
-          // IsSystemIncludeDirectory call so just set it to false.
-          const bool isSystemInclude = isInterfaceSources
-            ? false
-            : target->IsSystemIncludeDirectory(include, config,
-                                               fileData.Language);
           fileData.IncludePathList.push_back(
-            std::make_pair(include, isSystemInclude));
+            std::make_pair(include,
+                           target->IsSystemIncludeDirectory(
+                             include, config, fileData.Language)));
         }
       }
 
@@ -336,71 +322,14 @@
     }
 
     fileData.IsGenerated = file->GetPropertyAsBool("GENERATED");
-    FileGroupSources& groupFileList = fileGroups[fileData];
-    groupFileList.IsInterfaceSources = isInterfaceSources;
-    groupFileList.Files.push_back(file->GetFullPath());
-  }
-}
-
-static Json::Value DumpSourceFilesList(
-  cmGeneratorTarget* target, const std::string& config,
-  const std::map<std::string, LanguageData>& languageDataMap)
-{
-  const cmStateEnums::TargetType type = target->GetType();
-  std::unordered_map<LanguageData, FileGroupSources> fileGroups;
-
-  // Collect sourcefile groups:
-
-  std::vector<cmSourceFile*> files;
-  if (type == cmStateEnums::INTERFACE_LIBRARY) {
-    // INTERFACE_LIBRARY targets do not create all the data structures
-    // associated with regular targets. If properties are explicitly specified
-    // for files in INTERFACE_SOURCES then we can get them through the Makefile
-    // rather than the target.
-    files = target->Makefile->GetSourceFiles();
-  } else {
-    target->GetSourceFiles(files, config);
-    PopulateFileGroupData(target, false /* isInterfaceSources */, files,
-                          config, languageDataMap, fileGroups);
-  }
-
-  // Collect interface sourcefile groups:
-
-  auto targetProp = target->Target->GetProperty("INTERFACE_SOURCES");
-  if (targetProp != nullptr) {
-    cmGeneratorExpressionInterpreter genexInterpreter(
-      target->GetLocalGenerator(), config, target);
-
-    auto evaluatedSources = cmsys::SystemTools::SplitString(
-      genexInterpreter.Evaluate(targetProp, "INTERFACE_SOURCES"), ';');
-
-    std::map<std::string, cmSourceFile*> filesMap;
-    for (auto file : files) {
-      filesMap[file->GetFullPath()] = file;
-    }
-
-    std::vector<cmSourceFile*> interfaceSourceFiles;
-    for (const std::string& interfaceSourceFilePath : evaluatedSources) {
-      auto entry = filesMap.find(interfaceSourceFilePath);
-      if (entry != filesMap.end()) {
-        // use what we have since it has all the associated properties
-        interfaceSourceFiles.push_back(entry->second);
-      } else {
-        interfaceSourceFiles.push_back(
-          new cmSourceFile(target->Makefile, interfaceSourceFilePath));
-      }
-    }
-
-    PopulateFileGroupData(target, true /* isInterfaceSources */,
-                          interfaceSourceFiles, config, languageDataMap,
-                          fileGroups);
+    std::vector<std::string>& groupFileList = fileGroups[fileData];
+    groupFileList.push_back(file->GetFullPath());
   }
 
   const std::string& baseDir = target->Makefile->GetCurrentSourceDirectory();
   Json::Value result = Json::arrayValue;
   for (auto const& it : fileGroups) {
-    Json::Value group = DumpSourceFileGroup(
-      it.first, it.second.IsInterfaceSources, it.second.Files, baseDir);
+    Json::Value group = DumpSourceFileGroup(it.first, it.second, baseDir);
     if (!group.isNull()) {
       result.append(group);
     }
@@ -517,58 +446,6 @@
   return result;
 }
 
-static void GetTargetProperty(
-  cmGeneratorExpressionInterpreter& genexInterpreter,
-  cmGeneratorTarget* target, const char* propertyName,
-  std::vector<std::string>& propertyValue)
-{
-  auto targetProp = target->Target->GetProperty(propertyName);
-  if (targetProp != nullptr) {
-    propertyValue = cmsys::SystemTools::SplitString(
-      genexInterpreter.Evaluate(targetProp, propertyName), ';');
-  }
-}
-
-static void CreateInterfaceSourcesEntry(
-  cmLocalGenerator* lg, cmGeneratorTarget* target, const std::string& config,
-  std::map<std::string, LanguageData>& languageDataMap)
-{
-  LanguageData& ld = languageDataMap[kInterfaceSourcesLanguageDataKey];
-  ld.Language = "";
-
-  cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target);
-  std::vector<std::string> propertyValue;
-  GetTargetProperty(genexInterpreter, target, "INTERFACE_INCLUDE_DIRECTORIES",
-                    propertyValue);
-  for (std::string const& i : propertyValue) {
-    ld.IncludePathList.push_back(
-      std::make_pair(i, false /* isSystemInclude */));
-  }
-
-  propertyValue.clear();
-  GetTargetProperty(genexInterpreter, target,
-                    "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", propertyValue);
-  for (std::string const& i : propertyValue) {
-    ld.IncludePathList.push_back(
-      std::make_pair(i, true /* isSystemInclude */));
-  }
-
-  propertyValue.clear();
-  GetTargetProperty(genexInterpreter, target, "INTERFACE_COMPILE_OPTIONS",
-                    propertyValue);
-  for (const auto& s : propertyValue) {
-    ld.Flags += " " + s;
-  }
-
-  propertyValue.clear();
-  GetTargetProperty(genexInterpreter, target, "INTERFACE_COMPILE_DEFINITIONS",
-                    propertyValue);
-  if (!propertyValue.empty()) {
-    std::set<std::string> defines(propertyValue.begin(), propertyValue.end());
-    ld.SetDefines(defines);
-  }
-}
-
 static Json::Value DumpTarget(cmGeneratorTarget* target,
                               const std::string& config)
 {
@@ -598,6 +475,11 @@
   result[kTYPE_KEY] = typeName;
   result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory();
   result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory();
+
+  if (type == cmStateEnums::INTERFACE_LIBRARY) {
+    return result;
+  }
+
   result[kFULL_NAME_KEY] = target->GetFullName(config);
 
   if (target->Target->GetHaveInstallRule()) {
@@ -684,21 +566,8 @@
   }
 
   std::set<std::string> languages;
+  target->GetLanguages(languages, config);
   std::map<std::string, LanguageData> languageDataMap;
-  if (type == cmStateEnums::INTERFACE_LIBRARY) {
-    // INTERFACE_LIBRARY targets do not create all the data structures
-    // associated with regular targets. If properties are explicitly specified
-    // for files in INTERFACE_SOURCES then we can get them through the Makefile
-    // rather than the target.
-    for (auto file : target->Makefile->GetSourceFiles()) {
-      const std::string& language = file->GetLanguage();
-      if (!language.empty()) {
-        languages.insert(language);
-      }
-    }
-  } else {
-    target->GetLanguages(languages, config);
-  }
 
   for (std::string const& lang : languages) {
     LanguageData& ld = languageDataMap[lang];
@@ -715,11 +584,6 @@
     }
   }
 
-  if (target->Target->GetProperty("INTERFACE_SOURCES") != nullptr) {
-    // Create an entry in the languageDataMap for interface sources.
-    CreateInterfaceSourcesEntry(lg, target, config, languageDataMap);
-  }
-
   Json::Value sourceGroupsValue =
     DumpSourceFilesList(target, config, languageDataMap);
   if (!sourceGroupsValue.empty()) {
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index c9bbde1..025c6e4 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -25,6 +25,23 @@
 {
 }
 
+static bool cmLinkItemValidForDevice(std::string const& item)
+{
+  // Valid items are:
+  // * Non-flags (does not start in '-')
+  // * Specific flags --library, --library-path, -l, -L
+  // For example:
+  // * 'cublas_device' => pass-along
+  // * '--library pthread' => pass-along
+  // * '-lpthread' => pass-along
+  // * '-pthread' => drop
+  // * '-a' => drop
+  return (!cmHasLiteralPrefix(item, "-") || //
+          cmHasLiteralPrefix(item, "-l") || //
+          cmHasLiteralPrefix(item, "-L") || //
+          cmHasLiteralPrefix(item, "--library"));
+}
+
 std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
   cmComputeLinkInformation& cli, std::string const& stdLibString)
 {
@@ -69,7 +86,7 @@
       }
       out +=
         this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value));
-    } else {
+    } else if (cmLinkItemValidForDevice(item.Value)) {
       out += item.Value;
     }
 
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 305c7a6..8f565c8 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -300,19 +300,15 @@
     }
   }
 
-  if (haveDescription) {
-    this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description.c_str());
-    this->Makefile->AddDefinition(projectName + "_DESCRIPTION",
-                                  description.c_str());
-    TopLevelCMakeVarCondSet("CMAKE_PROJECT_DESCRIPTION", description.c_str());
-  }
+  this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description.c_str());
+  this->Makefile->AddDefinition(projectName + "_DESCRIPTION",
+                                description.c_str());
+  TopLevelCMakeVarCondSet("CMAKE_PROJECT_DESCRIPTION", description.c_str());
 
-  if (haveHomepage) {
-    this->Makefile->AddDefinition("PROJECT_HOMEPAGE_URL", homepage.c_str());
-    this->Makefile->AddDefinition(projectName + "_HOMEPAGE_URL",
-                                  homepage.c_str());
-    TopLevelCMakeVarCondSet("CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str());
-  }
+  this->Makefile->AddDefinition("PROJECT_HOMEPAGE_URL", homepage.c_str());
+  this->Makefile->AddDefinition(projectName + "_HOMEPAGE_URL",
+                                homepage.c_str());
+  TopLevelCMakeVarCondSet("CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str());
 
   if (languages.empty()) {
     // if no language is specified do c and c++
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index f75a5ce..f051fd9 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -164,12 +164,7 @@
 
 std::pair<int, int> cmServerProtocol1::ProtocolVersion() const
 {
-  // Revision history
-  // 1, 1 - Report backtraces in codemodel response
-  // 1, 2 - Add target install destinations to codemodel
-  // 1, 3 - Add a flag to target filegroups indicating whether or not the
-  // filegroup is for INTERFACE_SOURCES
-  return std::make_pair(1, 3);
+  return std::make_pair(1, 2);
 }
 
 static void setErrorMessage(std::string* errorMessage, const std::string& text)
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 8339aac..568ee82 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1733,6 +1733,32 @@
   fflush(out);
 }
 
+bool la_diagnostic(struct archive* ar, __LA_SSIZE_T r)
+{
+  // See archive.h definition of ARCHIVE_OK for return values.
+
+  if (r >= ARCHIVE_OK) {
+    return true;
+  }
+
+  if (r >= ARCHIVE_WARN) {
+    const char* warn = archive_error_string(ar);
+    if (!warn) {
+      warn = "unknown warning";
+    }
+    std::cerr << "cmake -E tar: warning: " << warn << '\n';
+    return true;
+  }
+
+  // Error.
+  const char* err = archive_error_string(ar);
+  if (!err) {
+    err = "unknown error";
+  }
+  std::cerr << "cmake -E tar: error: " << err << '\n';
+  return false;
+}
+
 // Return 'true' on success
 bool copy_data(struct archive* ar, struct archive* aw)
 {
@@ -1746,24 +1772,17 @@
 #  endif
 
   for (;;) {
-    // Return value:
-    // * ARCHIVE_OK - read succeed
-    // * ARCHIVE_EOF - no more data to read left
+    // See archive.h definition of ARCHIVE_OK for return values.
     r = archive_read_data_block(ar, &buff, &size, &offset);
     if (r == ARCHIVE_EOF) {
       return true;
     }
-    if (r != ARCHIVE_OK) {
+    if (!la_diagnostic(ar, r)) {
       return false;
     }
-    // Return value:
-    // * >= ARCHIVE_OK - write succeed
-    // * < ARCHIVE_OK - write failed
-    const __LA_SSIZE_T w_size =
-      archive_write_data_block(aw, buff, size, offset);
-    if (w_size < ARCHIVE_OK) {
-      cmSystemTools::Message("archive_write_data_block()",
-                             archive_error_string(aw));
+    // See archive.h definition of ARCHIVE_OK for return values.
+    __LA_SSIZE_T const w = archive_write_data_block(aw, buff, size, offset);
+    if (!la_diagnostic(ar, w)) {
       return false;
     }
   }
@@ -1822,7 +1841,6 @@
       r = archive_write_header(ext, entry);
       if (r == ARCHIVE_OK) {
         if (!copy_data(a, ext)) {
-          cmSystemTools::Error("Problem with copy_data");
           break;
         }
         r = archive_write_finish_entry(ext);
@@ -2826,11 +2844,11 @@
         // contain the location of the linker map, however on MIPS the
         // .dynamic section is always read-only so this is not possible. MIPS
         // objects instead contain a DT_MIPS_RLD_MAP tag which contains the
-        // address where the dyanmic linker will write to (an indirect
+        // address where the dynamic linker will write to (an indirect
         // version of DT_DEBUG). Since this doesn't work when using PIE, a
         // relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this
         // version contains a relative offset, moving it changes the
-        // calculated address. This may cause the dyanmic linker to write
+        // calculated address. This may cause the dynamic linker to write
         // into memory it should not be changing.
         //
         // To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 14cf6e9..da5d21e 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -96,7 +96,7 @@
   // From Linux timegm() manpage.
 
   std::string tz_old;
-  cmSystemTools::GetEnv("TZ", tz_old);
+  bool const tz_was_set = cmSystemTools::GetEnv("TZ", tz_old);
   tz_old = "TZ=" + tz_old;
 
   // The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC.
@@ -109,7 +109,17 @@
 
   time_t result = mktime(&tm);
 
+#  ifdef CMAKE_BUILD_WITH_CMAKE
+  if (tz_was_set) {
+    cmSystemTools::PutEnv(tz_old);
+  } else {
+    cmSystemTools::UnsetEnv("TZ");
+  }
+#  else
+  // No UnsetEnv during bootstrap.  This is good enough for CMake itself.
   cmSystemTools::PutEnv(tz_old);
+  static_cast<void>(tz_was_set);
+#  endif
 
   tzset();
 
diff --git a/Source/cmVS10CSharpFlagTable.h b/Source/cmVS10CSharpFlagTable.h
index 18d587c..6ac7a76 100644
--- a/Source/cmVS10CSharpFlagTable.h
+++ b/Source/cmVS10CSharpFlagTable.h
@@ -21,8 +21,8 @@
   { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
   { "", "link", "", "", 0 },
 
-  { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
-  { "ApplicationIcon", "win32icon", "", "",
+  { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired },
+  { "ApplicationIcon", "win32icon:", "", "",
     cmIDEFlagTable::UserValueRequired },
 
   { "ApplicationManifest", "win32manifest:", "", "",
diff --git a/Source/cmVS11CSharpFlagTable.h b/Source/cmVS11CSharpFlagTable.h
index e3ba83c..18b804a 100644
--- a/Source/cmVS11CSharpFlagTable.h
+++ b/Source/cmVS11CSharpFlagTable.h
@@ -21,8 +21,8 @@
   { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
   { "", "link", "", "", 0 },
 
-  { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
-  { "ApplicationIcon", "win32icon", "", "",
+  { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired },
+  { "ApplicationIcon", "win32icon:", "", "",
     cmIDEFlagTable::UserValueRequired },
 
   { "ApplicationManifest", "win32manifest:", "", "",
diff --git a/Source/cmVS12CSharpFlagTable.h b/Source/cmVS12CSharpFlagTable.h
index f8db636..0370499 100644
--- a/Source/cmVS12CSharpFlagTable.h
+++ b/Source/cmVS12CSharpFlagTable.h
@@ -21,8 +21,8 @@
   { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
   { "", "link", "", "", 0 },
 
-  { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
-  { "ApplicationIcon", "win32icon", "", "",
+  { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired },
+  { "ApplicationIcon", "win32icon:", "", "",
     cmIDEFlagTable::UserValueRequired },
 
   { "ApplicationManifest", "win32manifest:", "", "",
diff --git a/Source/cmVS140CSharpFlagTable.h b/Source/cmVS140CSharpFlagTable.h
index 055d5cb..f695f45 100644
--- a/Source/cmVS140CSharpFlagTable.h
+++ b/Source/cmVS140CSharpFlagTable.h
@@ -21,8 +21,8 @@
   { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
   { "", "link", "", "", 0 },
 
-  { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
-  { "ApplicationIcon", "win32icon", "", "",
+  { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired },
+  { "ApplicationIcon", "win32icon:", "", "",
     cmIDEFlagTable::UserValueRequired },
 
   { "ApplicationManifest", "win32manifest:", "", "",
diff --git a/Source/cmVS141CLFlagTable.h b/Source/cmVS141CLFlagTable.h
index 7d3e356..2a9944a 100644
--- a/Source/cmVS141CLFlagTable.h
+++ b/Source/cmVS141CLFlagTable.h
@@ -83,6 +83,8 @@
   { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
   { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
 
+  { "SpectreMitigation", "Qspectre", "Spectre mitigations", "Spectre", 0 },
+
   { "LanguageStandard", "std:c++17", "ISO C++17 Standard", "stdcpp17", 0 },
   { "LanguageStandard", "std:c++14", "ISO C++14 Standard", "stdcpp14", 0 },
   { "LanguageStandard", "std:c++latest", "ISO C++ Latest Draft Standard",
diff --git a/Source/cmVS141CSharpFlagTable.h b/Source/cmVS141CSharpFlagTable.h
index 66c61bd..1f84097 100644
--- a/Source/cmVS141CSharpFlagTable.h
+++ b/Source/cmVS141CSharpFlagTable.h
@@ -21,8 +21,8 @@
   { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
   { "", "link", "", "", 0 },
 
-  { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
-  { "ApplicationIcon", "win32icon", "", "",
+  { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired },
+  { "ApplicationIcon", "win32icon:", "", "",
     cmIDEFlagTable::UserValueRequired },
 
   { "ApplicationManifest", "win32manifest:", "", "",
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 16eca96..09c08d3 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1125,11 +1125,18 @@
   if (this->IPOEnabledConfigurations.count(config) > 0) {
     e1.Element("WholeProgramOptimization", "true");
   }
+  if (this->SpectreMitigationConfigurations.count(config) > 0) {
+    e1.Element("SpectreMitigation", "Spectre");
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
   Elem& e1, std::string const& config)
 {
+  if (this->GeneratorTarget->GetType() > cmStateEnums::OBJECT_LIBRARY) {
+    return;
+  }
+
   cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
 
   Options& o = *(this->ClOptions[config]);
@@ -2625,6 +2632,11 @@
     }
   }
 
+  if (clOptions.HasFlag("SpectreMitigation")) {
+    this->SpectreMitigationConfigurations.insert(configName);
+    clOptions.RemoveFlag("SpectreMitigation");
+  }
+
   this->ClOptions[configName] = std::move(pOptions);
   return true;
 }
@@ -2671,6 +2683,13 @@
     // Specify the compiler program database file if configured.
     std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName);
     if (!pdb.empty()) {
+      if (this->GlobalGenerator->IsCudaEnabled()) {
+        // CUDA does not quote paths with spaces correctly when forwarding
+        // this to the host compiler.  Use a relative path to avoid spaces.
+        // FIXME: We can likely do this even when CUDA is not involved,
+        // but for now we will make a minimal change.
+        pdb = this->ConvertPath(pdb, true);
+      }
       ConvertToWindowsSlash(pdb);
       e2.Element("ProgramDataBaseFileName", pdb);
     }
@@ -2811,15 +2830,19 @@
   // Specify the compiler program database file if configured.
   std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName);
   if (!pdb.empty()) {
-    // CUDA does not have a field for this and does not honor the
-    // ProgramDataBaseFileName field in ClCompile.  Work around this
-    // limitation by creating the directory and passing the flag ourselves.
+    // CUDA does not make the directory if it is non-standard.
     std::string const pdbDir = cmSystemTools::GetFilenamePath(pdb);
     cmSystemTools::MakeDirectory(pdbDir);
-    pdb = this->ConvertPath(pdb, true);
-    ConvertToWindowsSlash(pdb);
-    std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\"";
-    cudaOptions.AppendFlagString("AdditionalOptions", clFd);
+    if (cmSystemTools::VersionCompareGreaterEq(
+          "9.2", this->GlobalGenerator->GetPlatformToolsetCudaString())) {
+      // CUDA does not have a field for this and does not honor the
+      // ProgramDataBaseFileName field in ClCompile.  Work around this
+      // limitation by creating the directory and passing the flag ourselves.
+      pdb = this->ConvertPath(pdb, true);
+      ConvertToWindowsSlash(pdb);
+      std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\"";
+      cudaOptions.AppendFlagString("AdditionalOptions", clFd);
+    }
   }
 
   // CUDA automatically passes the proper '--machine' flag to nvcc
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 829d2bf..0dc03b6 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -205,6 +205,7 @@
   unsigned int NsightTegraVersion[4];
   bool TargetCompileAsWinRT;
   std::set<std::string> IPOEnabledConfigurations;
+  std::set<std::string> SpectreMitigationConfigurations;
   cmGlobalVisualStudio10Generator* const GlobalGenerator;
   cmLocalVisualStudio10Generator* const LocalGenerator;
   std::set<std::string> CSharpCustomCommandNames;
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 516104b..43aec00 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -35,6 +35,7 @@
 #                            target_link_libraries. Because of how interface
 #                            properties propagate, this target is not suitable
 #                            for use with PUBLIC or INTERFACE linking.
+#  KWSYS_ALIAS_TARGET = The name of an alias target to create to the actual target.
 #
 #    Example:
 #
@@ -887,6 +888,9 @@
     ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE}
       ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
   ENDIF()
+  if (KWSYS_ALIAS_TARGET)
+    add_library(${KWSYS_ALIAS_TARGET} ALIAS ${KWSYS_TARGET_INTERFACE})
+  endif ()
   SET_TARGET_PROPERTIES(${KWSYS_TARGET_OBJECT} PROPERTIES
     C_CLANG_TIDY ""
     CXX_CLANG_TIDY ""
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 7545ec7..d368fa2 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -112,7 +112,8 @@
 #  endif
 #endif
 
-#if defined(__linux) || defined(__sun) || defined(_SCO_DS)
+#if defined(__linux) || defined(__sun) || defined(_SCO_DS) ||                 \
+  defined(__GLIBC__) || defined(__GNU__)
 #  include <netdb.h>
 #  include <netinet/in.h>
 #  include <sys/socket.h>
diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx
index 0dfa326..623ad28 100644
--- a/Tests/CMakeLib/testSystemTools.cxx
+++ b/Tests/CMakeLib/testSystemTools.cxx
@@ -52,7 +52,7 @@
   cmAssert(cmSystemTools::strverscmp("99999999999999", "99999999999991") > 0,
            "strverscmp natural overflow");
   cmAssert(cmSystemTools::strverscmp("00000000000009", "00000000000001") > 0,
-           "strverscmp deciaml precision");
+           "strverscmp decimal precision");
   cmAssert(cmSystemTools::strverscmp("a.b.c.0", "a.b.c.000") > 0,
            "strverscmp multiple zeros");
   cmAssert(cmSystemTools::strverscmp("lib_1.2_10", "lib_1.2_2") > 0,
diff --git a/Tests/CSharpOnly/CMakeLists.txt b/Tests/CSharpOnly/CMakeLists.txt
index 0e3e39e..84b58ca 100644
--- a/Tests/CSharpOnly/CMakeLists.txt
+++ b/Tests/CSharpOnly/CMakeLists.txt
@@ -8,3 +8,6 @@
 add_executable(CSharpOnly csharponly.cs)
 
 target_link_libraries(CSharpOnly lib1 lib2)
+
+add_custom_target(CSharpCustom SOURCES empty.cs)
+add_custom_target(custom.cs DEPENDS empty.txt)
diff --git a/Tests/CSharpOnly/empty.cs b/Tests/CSharpOnly/empty.cs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/CSharpOnly/empty.cs
diff --git a/Tests/CSharpOnly/empty.txt b/Tests/CSharpOnly/empty.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/CSharpOnly/empty.txt
diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt
index 8a43df5..1b3daa6 100644
--- a/Tests/Cuda/CMakeLists.txt
+++ b/Tests/Cuda/CMakeLists.txt
@@ -4,5 +4,6 @@
 ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary)
 ADD_TEST_MACRO(Cuda.MixedStandardLevels MixedStandardLevels)
 ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude)
+ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries)
 ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags)
 ADD_TEST_MACRO(Cuda.WithC CudaWithC)
diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt
index f4e1923..d3d4b7c 100644
--- a/Tests/Cuda/Complex/CMakeLists.txt
+++ b/Tests/Cuda/Complex/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaComplex CXX CUDA)
+project (Complex CXX CUDA)
 #Goal for this example:
 
 #build a cpp dynamic library base
diff --git a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt
index 9fda2d0..7098a7d 100644
--- a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt
+++ b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaConsumeCompileFeatures CXX CUDA)
+project (ConsumeCompileFeatures CXX CUDA)
 #Goal for this example:
 
 #build a c++11 library that express a c++11 public compile feature
diff --git a/Tests/Cuda/MixedStandardLevels/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels/CMakeLists.txt
index 683abe7..b399662 100644
--- a/Tests/Cuda/MixedStandardLevels/CMakeLists.txt
+++ b/Tests/Cuda/MixedStandardLevels/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project(CudaComplex CXX CUDA)
+project(MixedStandardLevels CXX CUDA)
 
 string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
 
diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
index da5fb87..395bd38 100644
--- a/Tests/Cuda/ObjectLibrary/CMakeLists.txt
+++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project (CudaObjectLibrary CUDA CXX)
+project (ObjectLibrary CUDA CXX)
 #Goal for this example:
 #
 #Build C++ and CUDA object files and than use them to make an executable
diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
new file mode 100644
index 0000000..cb47b09
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.13)
+project(ProperDeviceLibraries CXX CUDA)
+
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35")
+set(CMAKE_CUDA_STANDARD 11)
+
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads)
+
+add_executable(ProperDeviceLibraries main.cu)
+set_target_properties(ProperDeviceLibraries
+                      PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
+
+add_library(UseThreadsMixed SHARED use_pthreads.cxx use_pthreads.cu)
+target_link_libraries(UseThreadsMixed Threads::Threads)
+
+add_library(UseThreadsCuda SHARED use_pthreads.cu)
+target_link_libraries(UseThreadsCuda Threads::Threads)
+
+target_link_libraries(ProperDeviceLibraries PRIVATE UseThreadsMixed UseThreadsCuda)
+
+if(THREADS_HAVE_PTHREAD_ARG AND CMAKE_USE_PTHREADS_INIT)
+  add_library(UseExplicitPThreadsFlag SHARED use_pthreads.cu)
+  target_compile_options(UseExplicitPThreadsFlag PUBLIC "-Xcompiler=-pthread")
+  target_link_libraries(UseExplicitPThreadsFlag PUBLIC "-pthread")
+
+  add_library(UseExplicitLThreadsFlag SHARED use_pthreads.cu)
+  target_compile_options(UseExplicitLThreadsFlag PUBLIC "-Xcompiler=-pthread")
+  target_link_libraries(UseExplicitLThreadsFlag PUBLIC "-lpthread")
+
+  add_library(UseExplicitLongThreadsFlag SHARED use_pthreads.cu)
+  target_link_libraries(UseExplicitLongThreadsFlag PUBLIC "--library pthread")
+
+  target_link_libraries(ProperDeviceLibraries PRIVATE UseExplicitPThreadsFlag UseExplicitLThreadsFlag UseExplicitLongThreadsFlag)
+endif()
+
+if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0)
+  #CUDA 10 removed the cublas_device library
+  target_link_libraries(ProperDeviceLibraries PRIVATE cublas_device)
+endif()
+
+if(APPLE)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET ProperDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+endif()
diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu b/Tests/Cuda/ProperDeviceLibraries/main.cu
similarity index 92%
rename from Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu
rename to Tests/Cuda/ProperDeviceLibraries/main.cu
index 2c7c388..8ceb0cc 100644
--- a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu
+++ b/Tests/Cuda/ProperDeviceLibraries/main.cu
@@ -3,6 +3,15 @@
 #include <cuda_runtime.h>
 #include <iostream>
 
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+
+#  include <pthread.h>
+static int verify_linking_to_pthread()
+{
+  return static_cast<int>(pthread_self());
+}
+#endif
+
 // this test only makes sense for versions of CUDA that ships
 // static libraries that have separable compilation device symbols
 #if __CUDACC_VER_MAJOR__ <= 9
diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu
new file mode 100644
index 0000000..c57b8a8
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu
@@ -0,0 +1,9 @@
+
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+
+#  include <pthread.h>
+static int verify_linking_to_pthread_cuda()
+{
+  return static_cast<int>(pthread_self());
+}
+#endif
diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx
new file mode 100644
index 0000000..dc7c208
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx
@@ -0,0 +1,9 @@
+
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+
+#  include <pthread.h>
+static int verify_linking_to_pthread_cxx()
+{
+  return static_cast<int>(pthread_self());
+}
+#endif
diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt
index 831ce12..69aa3f9 100644
--- a/Tests/Cuda/WithC/CMakeLists.txt
+++ b/Tests/Cuda/WithC/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project(CudaComplex CUDA C)
+project(WithC CUDA C)
 
 string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
 
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index 5b7c0e6..9c4f86a 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -3,7 +3,6 @@
 ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard)
 ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX)
 ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag)
-ADD_TEST_MACRO(CudaOnly.LinkSystemDeviceLibraries CudaOnlyLinkSystemDeviceLibraries)
 ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols)
 ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation)
 ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs)
diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
index c978e51..5e6f7ab 100644
--- a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
+++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyCircularLinkLine CUDA)
+project (CircularLinkLine CUDA)
 
 #Goal for this example:
 # Verify that we de-duplicate the device link line
diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt
index 35a1deb..54e2c14 100644
--- a/Tests/CudaOnly/EnableStandard/CMakeLists.txt
+++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyEnableStandard CUDA)
+project (EnableStandard CUDA)
 
 #Goal for this example:
 #build cuda sources that require C++11 to be enabled.
diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
index 65d5243..ff6e77c 100644
--- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt
+++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.8)
-project (CudaOnlyExportPTX CUDA)
+project (ExportPTX CUDA)
 
 #Goal for this example:
 # How to generate PTX files instead of OBJECT files
diff --git a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
index 5b96906..fbef15f 100644
--- a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
+++ b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlGPUDebugFlag CUDA)
+project (GPUDebugFlag CUDA)
 
 #Goal for this example:
 #verify that -G enables gpu debug flags
diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt b/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt
deleted file mode 100644
index 62be1e6..0000000
--- a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-cmake_minimum_required(VERSION 3.8)
-project(CudaOnlyLinkSystemDeviceLibraries CUDA)
-
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35")
-set(CMAKE_CUDA_STANDARD 11)
-
-add_executable(CudaOnlyLinkSystemDeviceLibraries main.cu)
-set_target_properties( CudaOnlyLinkSystemDeviceLibraries
-                       PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
-target_link_libraries( CudaOnlyLinkSystemDeviceLibraries PRIVATE cublas_device)
-
-if(APPLE)
-  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
-  set_property(TARGET CudaOnlyLinkSystemDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
-endif()
diff --git a/Tests/CudaOnly/PDB/CMakeLists.txt b/Tests/CudaOnly/PDB/CMakeLists.txt
index 34e1e5c..6ecf989 100644
--- a/Tests/CudaOnly/PDB/CMakeLists.txt
+++ b/Tests/CudaOnly/PDB/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.11)
-project (CudaOnlyPDB CUDA)
+project (PDB CUDA)
 
 add_executable(CudaOnlyPDB main.cu)
 set_target_properties(CudaOnlyPDB PROPERTIES
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
index 0c453a9..796e133 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyResolveDeviceSymbols CUDA)
+project (ResolveDeviceSymbols CUDA)
 
 # Find nm and dumpbin
 if(CMAKE_NM)
diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
index c934c51..1e574d6 100644
--- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
+++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlySeparateCompilation CUDA)
+project (SeparateCompilation CUDA)
 
 #Goal for this example:
 #Build a static library that defines multiple methods and kernels that
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index 926d9ed..e58204d 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyWithDefs CUDA)
+project (WithDefs CUDA)
 
 #verify that we can pass explicit cuda arch flags
 string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt b/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt
index b1c4fc3..1ad6238 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt
+++ b/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt
@@ -9,7 +9,7 @@
 set(MOC_INCLUDE_NAME "mocIncludeRelaxed")
 include(${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/shared.cmake)
 
-# Relaxed ony executable
+# Relaxed only executable
 add_executable(mocIncludeRelaxedOnly
   RObjA.cpp
   RObjB.cpp
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake
new file mode 100644
index 0000000..2a505c6
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake
@@ -0,0 +1,83 @@
+cmake_minimum_required(VERSION 3.12)
+
+project(FindPkgConfig_IMPORTED_TARGET C)
+
+find_package(PkgConfig REQUIRED)
+
+message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}")
+
+# Setup for the remaining package tests below
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+set(fakePkgDir ${CMAKE_CURRENT_BINARY_DIR}/pc-fakepackage)
+file(WRITE ${fakePkgDir}/lib/libcmakeinternalfakepackage.a "")
+file(WRITE ${fakePkgDir}/lib/cmakeinternalfakepackage.lib  "")
+file(WRITE ${fakePkgDir}/lib/pkgconfig/cmakeinternalfakepackage.pc
+"Name: CMakeInternalFakePackage
+Description: Dummy package for FindPkgConfig VERSION_OPERATORS test
+Version: 8.9
+Libs: -lcmakeinternalfakepackage
+")
+
+# Always find the .pc file in the calls further below so that we can test that
+# the import target find_library() calls handle the NO...PATH options correctly
+set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig)
+
+pkg_check_modules(FakePackageGE REQUIRED QUIET "cmakeinternalfakepackage >= 8")
+if (NOT FakePackageGE_FOUND)
+  message(FATAL_ERROR "fake package >= 8 not found")
+endif()
+
+pkg_check_modules(FakePackageGE_FAIL QUIET "cmakeinternalfakepackage >= 8.10")
+if (FakePackageGE_FAIL_FOUND)
+  message(FATAL_ERROR "fake package >= 8.10 found")
+endif()
+
+pkg_check_modules(FakePackageLE REQUIRED QUIET "cmakeinternalfakepackage<=9")
+if (NOT FakePackageLE_FOUND)
+  message(FATAL_ERROR "fake package <= 9 not found")
+endif()
+
+pkg_check_modules(FakePackageLE_FAIL QUIET "cmakeinternalfakepackage <= 8.1")
+if (FakePackageLE_FAIL_FOUND)
+  message(FATAL_ERROR "fake package <= 8.1 found")
+endif()
+
+pkg_check_modules(FakePackageGT REQUIRED QUIET "cmakeinternalfakepackage > 8")
+if (NOT FakePackageGT_FOUND)
+  message(FATAL_ERROR "fake package > 8 not found")
+endif()
+
+pkg_check_modules(FakePackageGT_FAIL QUIET "cmakeinternalfakepackage > 8.9")
+if (FakePackageGT_FAIL_FOUND)
+  message(FATAL_ERROR "fake package > 8.9 found")
+endif()
+
+pkg_check_modules(FakePackageLT REQUIRED QUIET "cmakeinternalfakepackage<9")
+if (NOT FakePackageLT_FOUND)
+  message(FATAL_ERROR "fake package < 9 not found")
+endif()
+
+pkg_check_modules(FakePackageLT_FAIL QUIET "cmakeinternalfakepackage < 8.9")
+if (FakePackageLT_FAIL_FOUND)
+  message(FATAL_ERROR "fake package < 8.9 found")
+endif()
+
+pkg_check_modules(FakePackageEQ REQUIRED QUIET "cmakeinternalfakepackage=8.9")
+if (NOT FakePackageEQ_FOUND)
+  message(FATAL_ERROR "fake package = 8.9 not found")
+endif()
+
+pkg_check_modules(FakePackageEQ_FAIL QUIET "cmakeinternalfakepackage = 8.8")
+if (FakePackageEQ_FAIL_FOUND)
+  message(FATAL_ERROR "fake package = 8.8 found")
+endif()
+
+pkg_check_modules(FakePackageEQ_INV QUIET "cmakeinternalfakepackage == 8.9")
+if (FakePackageEQ_FAIL_FOUND)
+  message(FATAL_ERROR "fake package == 8.9 found")
+endif()
+
+pkg_check_modules(FakePackageLLT_INV QUIET "cmakeinternalfakepackage <<= 9")
+if (FakePackageLLT_FAIL_FOUND)
+  message(FATAL_ERROR "fake package <<= 9 found")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index e12b52f..671ff51 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -16,4 +16,5 @@
   run_cmake(FindPkgConfig_GET_VARIABLE)
   run_cmake(FindPkgConfig_cache_variables)
   run_cmake(FindPkgConfig_IMPORTED_TARGET)
+  run_cmake(FindPkgConfig_VERSION_OPERATORS)
 endif ()
diff --git a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake
index b544ba6..e00af58 100644
--- a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake
@@ -1,6 +1,6 @@
 include(RunCMake)
 
-if(SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$")
+if(SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$")
   set(EXPECT_BSD 1)
 endif()
 
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW-stderr.txt
new file mode 100644
index 0000000..7f248ae
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW-stderr.txt
@@ -0,0 +1,2 @@
+^-->value<--
+-->value<--$
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW.cmake b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW.cmake
new file mode 100644
index 0000000..b81fd56
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0053 NEW)
+
+set($ value)
+set(dollar $)
+message("-->${${dollar}}<--")
+message("-->${$}<--")
diff --git a/Tests/RunCMake/install/CODE-genex-bad-result.txt b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-result.txt
similarity index 100%
rename from Tests/RunCMake/install/CODE-genex-bad-result.txt
rename to Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt
new file mode 100644
index 0000000..aecd4d3
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt
@@ -0,0 +1,24 @@
+^CMake Deprecation Warning at CMP0053-Dollar-OLD.cmake:1 \(cmake_policy\):
+  The OLD behavior for policy CMP0053 will be removed from a future version
+  of CMake.
+
+  The cmake-policies\(7\) manual explains that the OLD behaviors of all
+  policies are deprecated and that a policy should be set to OLD only under
+  specific short-term circumstances.  Projects should be ported to the NEW
+  behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+-->value<--
+CMake Error at CMP0053-Dollar-OLD.cmake:6 \(message\):
+  Syntax error in cmake code at
+
+    .*CMP0053-Dollar-OLD.cmake:6
+
+  when parsing string
+
+    -->\${\$}<--
+
+  syntax error, unexpected \$, expecting } \(7\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD.cmake b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD.cmake
new file mode 100644
index 0000000..647f464
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0053 OLD)
+
+set($ value)
+set(dollar $)
+message("-->${${dollar}}<--")
+message("-->${$}<--")
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index a397620..8d74dc1 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -111,6 +111,8 @@
 run_cmake(CMP0053-NameWithCarriageReturnQuoted)
 run_cmake(CMP0053-NameWithEscapedSpacesQuoted)
 run_cmake(CMP0053-NameWithEscapedTabsQuoted)
+run_cmake(CMP0053-Dollar-OLD)
+run_cmake(CMP0053-Dollar-NEW)
 
 # Variable special types
 run_cmake(QueryCache)
diff --git a/Tests/RunCMake/install/CODE-genex-bad-stderr.txt b/Tests/RunCMake/install/CODE-genex-bad-stderr.txt
deleted file mode 100644
index 9844158..0000000
--- a/Tests/RunCMake/install/CODE-genex-bad-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
-  Error evaluating generator expression:
-
-    \$<NOTAGENEX>
-
-  Expression did not evaluate to a known generator expression
diff --git a/Tests/RunCMake/install/CODE-genex-bad.cmake b/Tests/RunCMake/install/CODE-genex-bad.cmake
deleted file mode 100644
index 1663b39..0000000
--- a/Tests/RunCMake/install/CODE-genex-bad.cmake
+++ /dev/null
@@ -1 +0,0 @@
-install(CODE "message(\"$<NOTAGENEX>\")")
diff --git a/Tests/RunCMake/install/CODE-genex-check.cmake b/Tests/RunCMake/install/CODE-genex-check.cmake
deleted file mode 100644
index 422c532..0000000
--- a/Tests/RunCMake/install/CODE-genex-check.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake
-  OUTPUT_VARIABLE out ERROR_VARIABLE err)
-if(NOT out MATCHES "-- Install configuration: .*-- codegenexlib")
-  string(REGEX REPLACE "\n" "\n  " out "  ${out}")
-  string(APPEND RunCMake_TEST_FAILED
-      "\"-- codegenexlib\" was not found:\n${out}")
-endif()
diff --git a/Tests/RunCMake/install/CODE-genex.cmake b/Tests/RunCMake/install/CODE-genex.cmake
deleted file mode 100644
index 3b8513d..0000000
--- a/Tests/RunCMake/install/CODE-genex.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library( codegenexlib INTERFACE )
-install(CODE "message( STATUS \"$<TARGET_PROPERTY:codegenexlib,NAME>\")")
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index 91524a6..ec022ca 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -65,8 +65,6 @@
 run_cmake(CMP0062-WARN)
 run_cmake(TARGETS-NAMELINK_COMPONENT-bad-all)
 run_cmake(TARGETS-NAMELINK_COMPONENT-bad-exc)
-run_cmake(CODE-genex)
-run_cmake(CODE-genex-bad)
 
 if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
   run_install_test(FILES-TARGET_OBJECTS)
diff --git a/Tests/RunCMake/project/ProjectTwice.cmake b/Tests/RunCMake/project/ProjectTwice.cmake
new file mode 100644
index 0000000..d053834
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectTwice.cmake
@@ -0,0 +1,26 @@
+cmake_policy(SET CMP0048 NEW)
+project(ProjectTwiceTestFirst
+  VERSION 1.2.3.4
+  DESCRIPTION "Test Project"
+  HOMEPAGE_URL "http://example.com"
+  LANGUAGES NONE
+)
+
+project(ProjectTwiceTestSecond LANGUAGES NONE)
+
+foreach(var
+  PROJECT_VERSION
+  PROJECT_VERSION_MAJOR
+  PROJECT_VERSION_MINOR
+  PROJECT_VERSION_PATCH
+  PROJECT_VERSION_TWEAK
+  PROJECT_DESCRIPTION
+  PROJECT_HOMEPAGE_URL
+)
+  if(${var})
+    message(SEND_ERROR "${var} set but should be empty")
+  endif()
+  if(CMAKE_${var})
+    message(SEND_ERROR "CMAKE_${var} set but should be empty")
+  endif()
+endforeach()
diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake
index e9fb929..3a8ad4b 100644
--- a/Tests/RunCMake/project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/project/RunCMakeTest.cmake
@@ -15,6 +15,7 @@
 run_cmake(ProjectHomepage)
 run_cmake(ProjectHomepage2)
 run_cmake(ProjectHomepageNoArg)
+run_cmake(ProjectTwice)
 run_cmake(VersionAndLanguagesEmpty)
 run_cmake(VersionEmpty)
 run_cmake(VersionInvalid)
diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake
index 3af1b03..b3cc352 100644
--- a/Utilities/Release/create-cmake-release.cmake
+++ b/Utilities/Release/create-cmake-release.cmake
@@ -54,7 +54,7 @@
   -DCMAKE_INSTALL_PREFIX=\"\$inst/\" \\
   -DCMAKE_DOC_DIR=doc/cmake \\
   -DSPHINX_EXECUTABLE=\"${SPHINX_EXECUTABLE}\" \\
-  -DSPHINX_HTML=ON -DSPHINX_MAN=ON &&
+  -DSPHINX_HTML=ON -DSPHINX_MAN=ON -DSPHINX_QTHELP=ON &&
 make install &&
 cd .. &&
 tar czf \${name}.tar.gz \${name} ||
diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake
index 1edcd65..bbc7437 100644
--- a/Utilities/Release/upload_release.cmake
+++ b/Utilities/Release/upload_release.cmake
@@ -1,6 +1,6 @@
 set(CTEST_RUN_CURRENT_SCRIPT 0)
 if(NOT VERSION)
- set(VERSION 3.12)
+ set(VERSION 3.13)
 endif()
 if(NOT DEFINED PROJECT_PREFIX)
   set(PROJECT_PREFIX cmake-${VERSION})
diff --git a/Utilities/Scripts/update-curl.bash b/Utilities/Scripts/update-curl.bash
index b02180f..3d31e38 100755
--- a/Utilities/Scripts/update-curl.bash
+++ b/Utilities/Scripts/update-curl.bash
@@ -8,7 +8,7 @@
 readonly ownership="Curl Upstream <curl-library@cool.haxx.se>"
 readonly subtree="Utilities/cmcurl"
 readonly repo="https://github.com/curl/curl.git"
-readonly tag="curl-7_60_0"
+readonly tag="curl-7_61_1"
 readonly shortlog=false
 readonly paths="
   CMake/*
diff --git a/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake b/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake
index 9f7d296..15ba46e 100644
--- a/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake
+++ b/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake
@@ -4,57 +4,57 @@
 mark_as_advanced(CURL_HIDDEN_SYMBOLS)
 
 if(CURL_HIDDEN_SYMBOLS)
-    set(SUPPORTS_SYMBOL_HIDING FALSE)
+  set(SUPPORTS_SYMBOL_HIDING FALSE)
 
-    if(CMAKE_C_COMPILER_ID MATCHES "Clang")
-        set(SUPPORTS_SYMBOL_HIDING TRUE)
-        set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
-        set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
-    elseif(CMAKE_COMPILER_IS_GNUCC)
-        if(NOT CMAKE_VERSION VERSION_LESS 2.8.10)
-            set(GCC_VERSION ${CMAKE_C_COMPILER_VERSION})
-        else()
-            execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
-                            OUTPUT_VARIABLE GCC_VERSION)
-        endif()
-        if(NOT GCC_VERSION VERSION_LESS 3.4)
-            # note: this is considered buggy prior to 4.0 but the autotools don't care, so let's ignore that fact
-            set(SUPPORTS_SYMBOL_HIDING TRUE)
-            set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
-            set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
-        endif()
-    elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0)
-        set(SUPPORTS_SYMBOL_HIDING TRUE)
-        set(_SYMBOL_EXTERN "__global")
-        set(_CFLAG_SYMBOLS_HIDE "-xldscope=hidden")
-    elseif(CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0)
-        # note: this should probably just check for version 9.1.045 but I'm not 100% sure
-        #       so let's to it the same way autotools do.
-        set(SUPPORTS_SYMBOL_HIDING TRUE)
-        set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
-        set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
-        check_c_source_compiles("#include <stdio.h>
-            int main (void) { printf(\"icc fvisibility bug test\"); return 0; }" _no_bug)
-        if(NOT _no_bug)
-            set(SUPPORTS_SYMBOL_HIDING FALSE)
-            set(_SYMBOL_EXTERN "")
-            set(_CFLAG_SYMBOLS_HIDE "")
-        endif()
-    elseif(MSVC)
-        set(SUPPORTS_SYMBOL_HIDING TRUE)
-    endif()
-
-    set(HIDES_CURL_PRIVATE_SYMBOLS ${SUPPORTS_SYMBOL_HIDING})
-elseif(MSVC)
-    if(NOT CMAKE_VERSION VERSION_LESS 3.7)
-        set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #present since 3.4.3 but broken
-        set(HIDES_CURL_PRIVATE_SYMBOLS FALSE)
+  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+    set(SUPPORTS_SYMBOL_HIDING TRUE)
+    set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
+    set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
+  elseif(CMAKE_COMPILER_IS_GNUCC)
+    if(NOT CMAKE_VERSION VERSION_LESS 2.8.10)
+      set(GCC_VERSION ${CMAKE_C_COMPILER_VERSION})
     else()
-        message(WARNING "Hiding private symbols regardless CURL_HIDDEN_SYMBOLS being disabled.")
-        set(HIDES_CURL_PRIVATE_SYMBOLS TRUE)
+      execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+                      OUTPUT_VARIABLE GCC_VERSION)
     endif()
-elseif()
+    if(NOT GCC_VERSION VERSION_LESS 3.4)
+      # note: this is considered buggy prior to 4.0 but the autotools don't care, so let's ignore that fact
+      set(SUPPORTS_SYMBOL_HIDING TRUE)
+      set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
+      set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
+    endif()
+  elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0)
+    set(SUPPORTS_SYMBOL_HIDING TRUE)
+    set(_SYMBOL_EXTERN "__global")
+    set(_CFLAG_SYMBOLS_HIDE "-xldscope=hidden")
+  elseif(CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0)
+    # note: this should probably just check for version 9.1.045 but I'm not 100% sure
+    #       so let's to it the same way autotools do.
+    set(SUPPORTS_SYMBOL_HIDING TRUE)
+    set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
+    set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
+    check_c_source_compiles("#include <stdio.h>
+        int main (void) { printf(\"icc fvisibility bug test\"); return 0; }" _no_bug)
+    if(NOT _no_bug)
+      set(SUPPORTS_SYMBOL_HIDING FALSE)
+      set(_SYMBOL_EXTERN "")
+      set(_CFLAG_SYMBOLS_HIDE "")
+    endif()
+  elseif(MSVC)
+    set(SUPPORTS_SYMBOL_HIDING TRUE)
+  endif()
+
+  set(HIDES_CURL_PRIVATE_SYMBOLS ${SUPPORTS_SYMBOL_HIDING})
+elseif(MSVC)
+  if(NOT CMAKE_VERSION VERSION_LESS 3.7)
+    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #present since 3.4.3 but broken
     set(HIDES_CURL_PRIVATE_SYMBOLS FALSE)
+  else()
+    message(WARNING "Hiding private symbols regardless CURL_HIDDEN_SYMBOLS being disabled.")
+    set(HIDES_CURL_PRIVATE_SYMBOLS TRUE)
+  endif()
+elseif()
+  set(HIDES_CURL_PRIVATE_SYMBOLS FALSE)
 endif()
 
 set(CURL_CFLAG_SYMBOLS_HIDE ${_CFLAG_SYMBOLS_HIDE})
diff --git a/Utilities/cmcurl/CMake/CurlTests.c b/Utilities/cmcurl/CMake/CurlTests.c
index bc36c8e..ab244ac 100644
--- a/Utilities/cmcurl/CMake/CurlTests.c
+++ b/Utilities/cmcurl/CMake/CurlTests.c
@@ -507,30 +507,30 @@
 #ifdef HAVE_GLIBC_STRERROR_R
 #include <string.h>
 #include <errno.h>
+
+void check(char c) {}
+
 int
 main () {
-  char buffer[1024]; /* big enough to play with */
-  char *string =
-    strerror_r(EACCES, buffer, sizeof(buffer));
-    /* this should've returned a string */
-    if(!string || !string[0])
-      return 99;
-    return 0;
+  char buffer[1024];
+  /* This will not compile if strerror_r does not return a char* */
+  check(strerror_r(EACCES, buffer, sizeof(buffer))[0]);
+  return 0;
 }
 #endif
 #ifdef HAVE_POSIX_STRERROR_R
 #include <string.h>
 #include <errno.h>
+
+/* float, because a pointer can't be implicitly cast to float */
+void check(float f) {}
+
 int
 main () {
-  char buffer[1024]; /* big enough to play with */
-  int error =
-    strerror_r(EACCES, buffer, sizeof(buffer));
-    /* This should've returned zero, and written an error string in the
-       buffer.*/
-    if(!buffer[0] || error)
-      return 99;
-    return 0;
+  char buffer[1024];
+  /* This will not compile if strerror_r does not return an int */
+  check(strerror_r(EACCES, buffer, sizeof(buffer)));
+  return 0;
 }
 #endif
 #ifdef HAVE_FSETXATTR_6
diff --git a/Utilities/cmcurl/CMake/FindCARES.cmake b/Utilities/cmcurl/CMake/FindCARES.cmake
index c4ab5f1..723044a 100644
--- a/Utilities/cmcurl/CMake/FindCARES.cmake
+++ b/Utilities/cmcurl/CMake/FindCARES.cmake
@@ -7,36 +7,36 @@
 # also defined, but not for general use are
 # CARES_LIBRARY, where to find the c-ares library.
 
-FIND_PATH(CARES_INCLUDE_DIR ares.h
+find_path(CARES_INCLUDE_DIR ares.h
   /usr/local/include
   /usr/include
   )
 
-SET(CARES_NAMES ${CARES_NAMES} cares)
-FIND_LIBRARY(CARES_LIBRARY
+set(CARES_NAMES ${CARES_NAMES} cares)
+find_library(CARES_LIBRARY
   NAMES ${CARES_NAMES}
   PATHS /usr/lib /usr/local/lib
   )
 
-IF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
-  SET(CARES_LIBRARIES ${CARES_LIBRARY})
-  SET(CARES_FOUND "YES")
-ELSE (CARES_LIBRARY AND CARES_INCLUDE_DIR)
-  SET(CARES_FOUND "NO")
-ENDIF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
+if(CARES_LIBRARY AND CARES_INCLUDE_DIR)
+  set(CARES_LIBRARIES ${CARES_LIBRARY})
+  set(CARES_FOUND "YES")
+else()
+  set(CARES_FOUND "NO")
+endif()
 
 
-IF (CARES_FOUND)
-  IF (NOT CARES_FIND_QUIETLY)
-    MESSAGE(STATUS "Found c-ares: ${CARES_LIBRARIES}")
-  ENDIF (NOT CARES_FIND_QUIETLY)
-ELSE (CARES_FOUND)
-  IF (CARES_FIND_REQUIRED)
-    MESSAGE(FATAL_ERROR "Could not find c-ares library")
-  ENDIF (CARES_FIND_REQUIRED)
-ENDIF (CARES_FOUND)
+if(CARES_FOUND)
+  if(NOT CARES_FIND_QUIETLY)
+    message(STATUS "Found c-ares: ${CARES_LIBRARIES}")
+  endif()
+else()
+  if(CARES_FIND_REQUIRED)
+    message(FATAL_ERROR "Could not find c-ares library")
+  endif()
+endif()
 
-MARK_AS_ADVANCED(
+mark_as_advanced(
   CARES_LIBRARY
   CARES_INCLUDE_DIR
   )
diff --git a/Utilities/cmcurl/CMake/FindGSS.cmake b/Utilities/cmcurl/CMake/FindGSS.cmake
index 60dcb73..7a637fc 100644
--- a/Utilities/cmcurl/CMake/FindGSS.cmake
+++ b/Utilities/cmcurl/CMake/FindGSS.cmake
@@ -28,211 +28,209 @@
 
 # try to find library using system pkg-config if user didn't specify root dir
 if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}")
-    if(UNIX)
-        find_package(PkgConfig QUIET)
-        pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME})
-        list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}")
-    elseif(WIN32)
-        list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]")
-    endif()
+  if(UNIX)
+    find_package(PkgConfig QUIET)
+    pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME})
+    list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}")
+  elseif(WIN32)
+    list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]")
+  endif()
 endif()
 
 if(NOT _GSS_FOUND) #not found by pkg-config. Let's take more traditional approach.
-    find_file(_GSS_CONFIGURE_SCRIPT
+  find_file(_GSS_CONFIGURE_SCRIPT
+      NAMES
+          "krb5-config"
+      HINTS
+          ${_GSS_ROOT_HINTS}
+      PATH_SUFFIXES
+          bin
+      NO_CMAKE_PATH
+      NO_CMAKE_ENVIRONMENT_PATH
+  )
+
+  # if not found in user-supplied directories, maybe system knows better
+  find_file(_GSS_CONFIGURE_SCRIPT
+      NAMES
+          "krb5-config"
+      PATH_SUFFIXES
+          bin
+  )
+
+  if(_GSS_CONFIGURE_SCRIPT)
+    execute_process(
+          COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi"
+          OUTPUT_VARIABLE _GSS_CFLAGS
+          RESULT_VARIABLE _GSS_CONFIGURE_FAILED
+      )
+    message(STATUS "CFLAGS: ${_GSS_CFLAGS}")
+    if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
+      # should also work in an odd case when multiple directories are given
+      string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS)
+      string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}")
+      string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1"_GSS_CFLAGS "${_GSS_CFLAGS}")
+
+      foreach(_flag ${_GSS_CFLAGS})
+        if(_flag MATCHES "^-I.*")
+          string(REGEX REPLACE "^-I" "" _val "${_flag}")
+          list(APPEND _GSS_INCLUDE_DIR "${_val}")
+        else()
+          list(APPEND _GSS_COMPILER_FLAGS "${_flag}")
+        endif()
+      endforeach()
+    endif()
+
+    execute_process(
+        COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi"
+        OUTPUT_VARIABLE _GSS_LIB_FLAGS
+        RESULT_VARIABLE _GSS_CONFIGURE_FAILED
+    )
+    message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}")
+
+    if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
+      # this script gives us libraries and link directories. Blah. We have to deal with it.
+      string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS)
+      string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
+      string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1"_GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
+
+      foreach(_flag ${_GSS_LIB_FLAGS})
+        if(_flag MATCHES "^-l.*")
+          string(REGEX REPLACE "^-l" "" _val "${_flag}")
+          list(APPEND _GSS_LIBRARIES "${_val}")
+        elseif(_flag MATCHES "^-L.*")
+          string(REGEX REPLACE "^-L" "" _val "${_flag}")
+          list(APPEND _GSS_LINK_DIRECTORIES "${_val}")
+        else()
+          list(APPEND _GSS_LINKER_FLAGS "${_flag}")
+        endif()
+      endforeach()
+    endif()
+
+    execute_process(
+        COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version"
+        OUTPUT_VARIABLE _GSS_VERSION
+        RESULT_VARIABLE _GSS_CONFIGURE_FAILED
+    )
+
+    # older versions may not have the "--version" parameter. In this case we just don't care.
+    if(_GSS_CONFIGURE_FAILED)
+      set(_GSS_VERSION 0)
+    endif()
+
+    execute_process(
+        COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor"
+        OUTPUT_VARIABLE _GSS_VENDOR
+        RESULT_VARIABLE _GSS_CONFIGURE_FAILED
+    )
+
+    # older versions may not have the "--vendor" parameter. In this case we just don't care.
+    if(_GSS_CONFIGURE_FAILED)
+      set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter
+    else()
+      if(_GSS_VENDOR MATCHES ".*H|heimdal.*")
+        set(GSS_FLAVOUR "Heimdal")
+      else()
+        set(GSS_FLAVOUR "MIT")
+      endif()
+    endif()
+
+  else() # either there is no config script or we are on platform that doesn't provide one (Windows?)
+
+    find_path(_GSS_INCLUDE_DIR
         NAMES
-            "krb5-config"
+            "gssapi/gssapi.h"
         HINTS
             ${_GSS_ROOT_HINTS}
         PATH_SUFFIXES
-            bin
-        NO_CMAKE_PATH
-        NO_CMAKE_ENVIRONMENT_PATH
+            include
+            inc
     )
 
-    # if not found in user-supplied directories, maybe system knows better
-    find_file(_GSS_CONFIGURE_SCRIPT
-        NAMES
-            "krb5-config"
-        PATH_SUFFIXES
-            bin
-    )
+    if(_GSS_INCLUDE_DIR) #jay, we've found something
+      set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}")
+      check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS)
 
-    if(_GSS_CONFIGURE_SCRIPT)
-        execute_process(
-            COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi"
-            OUTPUT_VARIABLE _GSS_CFLAGS
-            RESULT_VARIABLE _GSS_CONFIGURE_FAILED
-        )
-message(STATUS "CFLAGS: ${_GSS_CFLAGS}")
-        if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
-            # should also work in an odd case when multiple directories are given
-            string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS)
-            string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}")
-            string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1"_GSS_CFLAGS "${_GSS_CFLAGS}")
-
-            foreach(_flag ${_GSS_CFLAGS})
-                if(_flag MATCHES "^-I.*")
-                    string(REGEX REPLACE "^-I" "" _val "${_flag}")
-                    list(APPEND _GSS_INCLUDE_DIR "${_val}")
-                else()
-                    list(APPEND _GSS_COMPILER_FLAGS "${_flag}")
-                endif()
-            endforeach()
-        endif()
-
-        execute_process(
-            COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi"
-            OUTPUT_VARIABLE _GSS_LIB_FLAGS
-            RESULT_VARIABLE _GSS_CONFIGURE_FAILED
-        )
-message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}")
-        if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
-            # this script gives us libraries and link directories. Blah. We have to deal with it.
-            string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS)
-            string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
-            string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1"_GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
-
-            foreach(_flag ${_GSS_LIB_FLAGS})
-                if(_flag MATCHES "^-l.*")
-                    string(REGEX REPLACE "^-l" "" _val "${_flag}")
-                    list(APPEND _GSS_LIBRARIES "${_val}")
-                elseif(_flag MATCHES "^-L.*")
-                    string(REGEX REPLACE "^-L" "" _val "${_flag}")
-                    list(APPEND _GSS_LINK_DIRECTORIES "${_val}")
-                else()
-                    list(APPEND _GSS_LINKER_FLAGS "${_flag}")
-                endif()
-            endforeach()
-        endif()
-
-
-        execute_process(
-            COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version"
-            OUTPUT_VARIABLE _GSS_VERSION
-            RESULT_VARIABLE _GSS_CONFIGURE_FAILED
-        )
-
-        # older versions may not have the "--version" parameter. In this case we just don't care.
-        if(_GSS_CONFIGURE_FAILED)
-            set(_GSS_VERSION 0)
-        endif()
-
-
-        execute_process(
-            COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor"
-            OUTPUT_VARIABLE _GSS_VENDOR
-            RESULT_VARIABLE _GSS_CONFIGURE_FAILED
-        )
-
-        # older versions may not have the "--vendor" parameter. In this case we just don't care.
-        if(_GSS_CONFIGURE_FAILED)
-            set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter
-        else()
-            if(_GSS_VENDOR MATCHES ".*H|heimdal.*")
-                set(GSS_FLAVOUR "Heimdal")
-            else()
-                set(GSS_FLAVOUR "MIT")
-            endif()
-        endif()
-
-    else() # either there is no config script or we are on platform that doesn't provide one (Windows?)
-
-        find_path(_GSS_INCLUDE_DIR
-            NAMES
-                "gssapi/gssapi.h"
-            HINTS
-                ${_GSS_ROOT_HINTS}
-            PATH_SUFFIXES
-                include
-                inc
-        )
-
-        if(_GSS_INCLUDE_DIR) #jay, we've found something
-            set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}")
-            check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS)
-
-            if(_GSS_HAVE_MIT_HEADERS)
-                set(GSS_FLAVOUR "MIT")
-            else()
-                # prevent compiling the header - just check if we can include it
-                set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__")
-                check_include_file( "roken.h" _GSS_HAVE_ROKEN_H)
-
-                check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H)
-                if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H)
-                    set(GSS_FLAVOUR "Heimdal")
-                endif()
-                set(CMAKE_REQUIRED_DEFINITIONS "")
-            endif()
-        else()
-            # I'm not convienced if this is the right way but this is what autotools do at the moment
-            find_path(_GSS_INCLUDE_DIR
-                NAMES
-                    "gssapi.h"
-                HINTS
-                    ${_GSS_ROOT_HINTS}
-                PATH_SUFFIXES
-                    include
-                    inc
-            )
-
-            if(_GSS_INCLUDE_DIR)
-                set(GSS_FLAVOUR "Heimdal")
-            endif()
-        endif()
-
-        # if we have headers, check if we can link libraries
-        if(GSS_FLAVOUR)
-            set(_GSS_LIBDIR_SUFFIXES "")
-            set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS})
-            get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH)
-            list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT})
-
-            if(WIN32)
-                if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-                    list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64")
-                    if(GSS_FLAVOUR STREQUAL "MIT")
-                        set(_GSS_LIBNAME "gssapi64")
-                    else()
-                        set(_GSS_LIBNAME "libgssapi")
-                    endif()
-                else()
-                    list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386")
-                    if(GSS_FLAVOUR STREQUAL "MIT")
-                        set(_GSS_LIBNAME "gssapi32")
-                    else()
-                        set(_GSS_LIBNAME "libgssapi")
-                    endif()
-                endif()
-            else()
-                list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS
-                if(GSS_FLAVOUR STREQUAL "MIT")
-                    set(_GSS_LIBNAME "gssapi_krb5")
-                else()
-                    set(_GSS_LIBNAME "gssapi")
-                endif()
-            endif()
-
-            find_library(_GSS_LIBRARIES
-                NAMES
-                    ${_GSS_LIBNAME}
-                HINTS
-                    ${_GSS_LIBDIR_HINTS}
-                PATH_SUFFIXES
-                    ${_GSS_LIBDIR_SUFFIXES}
-            )
-
-        endif()
-
-    endif()
-else()
-    if(_GSS_PKG_${_MIT_MODNAME}_VERSION)
+      if(_GSS_HAVE_MIT_HEADERS)
         set(GSS_FLAVOUR "MIT")
-        set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION)
+      else()
+        # prevent compiling the header - just check if we can include it
+        set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__")
+        check_include_file( "roken.h" _GSS_HAVE_ROKEN_H)
+
+        check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H)
+        if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H)
+          set(GSS_FLAVOUR "Heimdal")
+        endif()
+        set(CMAKE_REQUIRED_DEFINITIONS "")
+      endif()
     else()
+      # I'm not convienced if this is the right way but this is what autotools do at the moment
+      find_path(_GSS_INCLUDE_DIR
+          NAMES
+              "gssapi.h"
+          HINTS
+              ${_GSS_ROOT_HINTS}
+          PATH_SUFFIXES
+              include
+              inc
+      )
+
+      if(_GSS_INCLUDE_DIR)
         set(GSS_FLAVOUR "Heimdal")
-        set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION)
+      endif()
     endif()
+
+    # if we have headers, check if we can link libraries
+    if(GSS_FLAVOUR)
+      set(_GSS_LIBDIR_SUFFIXES "")
+      set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS})
+      get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH)
+      list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT})
+
+      if(WIN32)
+        if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+          list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64")
+          if(GSS_FLAVOUR STREQUAL "MIT")
+            set(_GSS_LIBNAME "gssapi64")
+          else()
+            set(_GSS_LIBNAME "libgssapi")
+          endif()
+        else()
+          list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386")
+          if(GSS_FLAVOUR STREQUAL "MIT")
+            set(_GSS_LIBNAME "gssapi32")
+          else()
+            set(_GSS_LIBNAME "libgssapi")
+          endif()
+        endif()
+      else()
+        list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS
+        if(GSS_FLAVOUR STREQUAL "MIT")
+          set(_GSS_LIBNAME "gssapi_krb5")
+        else()
+          set(_GSS_LIBNAME "gssapi")
+        endif()
+      endif()
+
+      find_library(_GSS_LIBRARIES
+          NAMES
+              ${_GSS_LIBNAME}
+          HINTS
+              ${_GSS_LIBDIR_HINTS}
+          PATH_SUFFIXES
+              ${_GSS_LIBDIR_SUFFIXES}
+      )
+
+    endif()
+  endif()
+else()
+  if(_GSS_PKG_${_MIT_MODNAME}_VERSION)
+    set(GSS_FLAVOUR "MIT")
+    set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION)
+  else()
+    set(GSS_FLAVOUR "Heimdal")
+    set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION)
+  endif()
 endif()
 
 set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIR})
@@ -243,35 +241,33 @@
 set(GSS_VERSION ${_GSS_VERSION})
 
 if(GSS_FLAVOUR)
-
-    if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal")
-        if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-            set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest")
-        else()
-            set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest")
-        endif()
-
-        if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}")
-            file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str
-                 REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$")
-
-            string(REGEX MATCH "[0-9]\\.[^\"]+"
-                   GSS_VERSION "${heimdal_version_str}")
-        endif()
-
-        if(NOT GSS_VERSION)
-            set(GSS_VERSION "Heimdal Unknown")
-        endif()
-    elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT")
-        get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE)
-        if(WIN32 AND _MIT_VERSION)
-            set(GSS_VERSION "${_MIT_VERSION}")
-        else()
-            set(GSS_VERSION "MIT Unknown")
-        endif()
+  if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal")
+    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+      set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest")
+    else()
+      set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest")
     endif()
-endif()
 
+    if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}")
+      file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str
+           REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$")
+
+      string(REGEX MATCH "[0-9]\\.[^\"]+"
+             GSS_VERSION "${heimdal_version_str}")
+    endif()
+
+    if(NOT GSS_VERSION)
+      set(GSS_VERSION "Heimdal Unknown")
+    endif()
+  elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT")
+    get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE)
+    if(WIN32 AND _MIT_VERSION)
+      set(GSS_VERSION "${_MIT_VERSION}")
+    else()
+      set(GSS_VERSION "MIT Unknown")
+    endif()
+  endif()
+endif()
 
 include(FindPackageHandleStandardArgs)
 
diff --git a/Utilities/cmcurl/CMake/FindLibSSH2.cmake b/Utilities/cmcurl/CMake/FindLibSSH2.cmake
index 12a7c61..84822db 100644
--- a/Utilities/cmcurl/CMake/FindLibSSH2.cmake
+++ b/Utilities/cmcurl/CMake/FindLibSSH2.cmake
@@ -5,14 +5,14 @@
 # LIBSSH2_INCLUDE_DIR - the libssh2 include directory
 # LIBSSH2_LIBRARY - the libssh2 library name
 
-if (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY)
+if(LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY)
   set(LibSSH2_FIND_QUIETLY TRUE)
-endif (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY)
+endif()
 
-FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h
+find_path(LIBSSH2_INCLUDE_DIR libssh2.h
 )
 
-FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2
+find_library(LIBSSH2_LIBRARY NAMES ssh2
 )
 
 if(LIBSSH2_INCLUDE_DIR)
@@ -27,9 +27,9 @@
   string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_PATCH "${LIBSSH2_VERSION_PATCH}")
 
   set(LIBSSH2_VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}")
-endif(LIBSSH2_INCLUDE_DIR)
+endif()
 
 include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY )
+find_package_handle_standard_args(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY )
 
-MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION)
+mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION)
diff --git a/Utilities/cmcurl/CMake/FindNGHTTP2.cmake b/Utilities/cmcurl/CMake/FindNGHTTP2.cmake
index 4e566cf..348b961 100644
--- a/Utilities/cmcurl/CMake/FindNGHTTP2.cmake
+++ b/Utilities/cmcurl/CMake/FindNGHTTP2.cmake
@@ -14,5 +14,5 @@
       "Could NOT find NGHTTP2"
 )
 
-set(NGHTTP2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR} )
+set(NGHTTP2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR})
 set(NGHTTP2_LIBRARIES ${NGHTTP2_LIBRARY})
diff --git a/Utilities/cmcurl/CMake/Macros.cmake b/Utilities/cmcurl/CMake/Macros.cmake
index 82aadca..7f71345 100644
--- a/Utilities/cmcurl/CMake/Macros.cmake
+++ b/Utilities/cmcurl/CMake/Macros.cmake
@@ -5,35 +5,35 @@
 # multiple times with a sequence of possibly dependent libraries in
 # order of least-to-most-dependent.  Some libraries depend on others
 # to link correctly.
-macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
+macro(check_library_exists_concat LIBRARY SYMBOL VARIABLE)
   check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}"
     ${VARIABLE})
   if(${VARIABLE})
     set(CURL_LIBS ${LIBRARY} ${CURL_LIBS})
-  endif(${VARIABLE})
-endmacro(CHECK_LIBRARY_EXISTS_CONCAT)
+  endif()
+endmacro()
 
 # Check if header file exists and add it to the list.
 # This macro is intended to be called multiple times with a sequence of
 # possibly dependent header files.  Some headers depend on others to be
 # compiled correctly.
-macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
+macro(check_include_file_concat FILE VARIABLE)
   check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE})
   if(${VARIABLE})
     set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
     set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}")
-  endif(${VARIABLE})
-endmacro(CHECK_INCLUDE_FILE_CONCAT)
+  endif()
+endmacro()
 
 # For other curl specific tests, use this macro.
-macro(CURL_INTERNAL_TEST CURL_TEST)
+macro(curl_internal_test CURL_TEST)
   if(NOT DEFINED "${CURL_TEST}")
     set(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}")
     if(CMAKE_REQUIRED_LIBRARIES)
       set(CURL_TEST_ADD_LIBRARIES
         "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
-    endif(CMAKE_REQUIRED_LIBRARIES)
+    endif()
 
     message(STATUS "Performing Curl Test ${CURL_TEST}")
     try_compile(${CURL_TEST}
@@ -48,53 +48,17 @@
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Performing Curl Test ${CURL_TEST} passed with the following output:\n"
         "${OUTPUT}\n")
-    else(${CURL_TEST})
+    else()
       message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
       set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
         "${OUTPUT}\n")
-    endif(${CURL_TEST})
+    endif()
   endif()
-endmacro(CURL_INTERNAL_TEST)
+endmacro()
 
-macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
-  if(NOT DEFINED "${CURL_TEST}_COMPILE")
-    set(MACRO_CHECK_FUNCTION_DEFINITIONS
-      "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
-    if(CMAKE_REQUIRED_LIBRARIES)
-      set(CURL_TEST_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
-    endif(CMAKE_REQUIRED_LIBRARIES)
-
-    message(STATUS "Performing Curl Test ${CURL_TEST}")
-    try_run(${CURL_TEST} ${CURL_TEST}_COMPILE
-      ${CMAKE_BINARY_DIR}
-      ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
-      CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-      "${CURL_TEST_ADD_LIBRARIES}"
-      OUTPUT_VARIABLE OUTPUT)
-    if(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
-      set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
-      message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
-    else(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
-      message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
-      set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
-      file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
-        "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
-        "${OUTPUT}")
-      if(${CURL_TEST}_COMPILE)
-        file(APPEND
-          "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
-          "There was a problem running this test\n")
-      endif(${CURL_TEST}_COMPILE)
-      file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
-        "\n\n")
-    endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
-  endif()
-endmacro(CURL_INTERNAL_TEST_RUN)
-
-macro(CURL_NROFF_CHECK)
+macro(curl_nroff_check)
   find_program(NROFF NAMES gnroff nroff)
   if(NROFF)
     # Need a way to write to stdin, this will do
@@ -121,4 +85,4 @@
   else()
     message(WARNING "Found no *nroff program")
   endif()
-endmacro(CURL_NROFF_CHECK)
+endmacro()
diff --git a/Utilities/cmcurl/CMake/OtherTests.cmake b/Utilities/cmcurl/CMake/OtherTests.cmake
index 989f04e..ce6d3e1 100644
--- a/Utilities/cmcurl/CMake/OtherTests.cmake
+++ b/Utilities/cmcurl/CMake/OtherTests.cmake
@@ -5,8 +5,8 @@
 macro(add_header_include check header)
   if(${check})
     set(_source_epilogue "${_source_epilogue}\n#include <${header}>")
-  endif(${check})
-endmacro(add_header_include)
+  endif()
+endmacro()
 
 set(signature_call_conv)
 if(HAVE_WINDOWS_H)
@@ -19,10 +19,10 @@
   if(HAVE_LIBWS2_32)
     set(CMAKE_REQUIRED_LIBRARIES ws2_32)
   endif()
-else(HAVE_WINDOWS_H)
+else()
   add_header_include(HAVE_SYS_TYPES_H "sys/types.h")
   add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h")
-endif(HAVE_WINDOWS_H)
+endif()
 
 check_c_source_compiles("${_source_epilogue}
 int main(void) {
@@ -64,13 +64,13 @@
                   set(RECV_TYPE_RETV "${recv_retv}")
                   set(HAVE_RECV 1)
                   set(curl_cv_func_recv_done 1)
-                endif(curl_cv_func_recv_test)
-              endif(NOT curl_cv_func_recv_done)
-            endforeach(recv_arg4)
-          endforeach(recv_arg3)
-        endforeach(recv_arg2)
-      endforeach(recv_arg1)
-    endforeach(recv_retv)
+                endif()
+              endif()
+            endforeach()
+          endforeach()
+        endforeach()
+      endforeach()
+    endforeach()
   else()
     string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG1 "${curl_cv_func_recv_args}")
     string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG2 "${curl_cv_func_recv_args}")
@@ -81,10 +81,10 @@
 
   if("${curl_cv_func_recv_args}" STREQUAL "unknown")
     message(FATAL_ERROR "Cannot find proper types to use for recv args")
-  endif("${curl_cv_func_recv_args}" STREQUAL "unknown")
-else(curl_cv_recv)
+  endif()
+else()
   message(FATAL_ERROR "Unable to link function recv")
-endif(curl_cv_recv)
+endif()
 set(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv")
 set(HAVE_RECV 1)
 
@@ -130,13 +130,13 @@
                   set(SEND_TYPE_RETV "${send_retv}")
                   set(HAVE_SEND 1)
                   set(curl_cv_func_send_done 1)
-                endif(curl_cv_func_send_test)
-              endif(NOT curl_cv_func_send_done)
-            endforeach(send_arg4)
-          endforeach(send_arg3)
-        endforeach(send_arg2)
-      endforeach(send_arg1)
-    endforeach(send_retv)
+                endif()
+              endif()
+            endforeach()
+          endforeach()
+        endforeach()
+      endforeach()
+    endforeach()
   else()
     string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG1 "${curl_cv_func_send_args}")
     string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG2 "${curl_cv_func_send_args}")
@@ -148,11 +148,11 @@
 
   if("${curl_cv_func_send_args}" STREQUAL "unknown")
     message(FATAL_ERROR "Cannot find proper types to use for send args")
-  endif("${curl_cv_func_send_args}" STREQUAL "unknown")
+  endif()
   set(SEND_QUAL_ARG2 "const")
-else(curl_cv_send)
+else()
   message(FATAL_ERROR "Unable to link function send")
-endif(curl_cv_send)
+endif()
 set(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments for send")
 set(HAVE_SEND 1)
 
@@ -184,7 +184,7 @@
   set(CMAKE_REQUIRED_FLAGS)
   if(HAVE_SYS_POLL_H)
     set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H")
-  endif(HAVE_SYS_POLL_H)
+  endif()
   check_c_source_runs("
     #ifdef HAVE_SYS_POLL_H
     #  include <sys/poll.h>
@@ -199,7 +199,7 @@
 if(HAVE_SIGNAL_H)
   set(CMAKE_REQUIRED_FLAGS "-DHAVE_SIGNAL_H")
   set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
-endif(HAVE_SIGNAL_H)
+endif()
 check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T)
 if(HAVE_SIZEOF_SIG_ATOMIC_T)
   check_c_source_compiles("
@@ -213,8 +213,8 @@
     }" HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
   if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
     set(HAVE_SIG_ATOMIC_T_VOLATILE 1)
-  endif(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
-endif(HAVE_SIZEOF_SIG_ATOMIC_T)
+  endif()
+endif()
 
 if(HAVE_WINDOWS_H)
   set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h)
@@ -222,11 +222,10 @@
   set(CMAKE_EXTRA_INCLUDE_FILES)
   if(HAVE_SYS_SOCKET_H)
     set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
-  endif(HAVE_SYS_SOCKET_H)
+  endif()
 endif()
 
 check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE)
 if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
   set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
-endif(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
-
+endif()
diff --git a/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake b/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake
index 53d0a5e..2dbe1bb 100644
--- a/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake
+++ b/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake
@@ -115,8 +115,7 @@
 
     set(HAVE_SIGACTION 0)
     set(HAVE_MACRO_SIGSETJMP 0)
-  else(WIN32)
+  else()
     message("This file should be included on Windows platform only")
-  endif(WIN32)
-endif(NOT UNIX)
-
+  endif()
+endif()
diff --git a/Utilities/cmcurl/CMake/Utilities.cmake b/Utilities/cmcurl/CMake/Utilities.cmake
index 005b166..5cb1d44 100644
--- a/Utilities/cmcurl/CMake/Utilities.cmake
+++ b/Utilities/cmcurl/CMake/Utilities.cmake
@@ -1,44 +1,13 @@
 # File containing various utilities
 
-# Converts a CMake list to a string containing elements separated by spaces
-function(TO_LIST_SPACES _LIST_NAME OUTPUT_VAR)
-  set(NEW_LIST_SPACE)
-  foreach(ITEM ${${_LIST_NAME}})
-    set(NEW_LIST_SPACE "${NEW_LIST_SPACE} ${ITEM}")
-  endforeach()
-  string(STRIP ${NEW_LIST_SPACE} NEW_LIST_SPACE)
-  set(${OUTPUT_VAR} "${NEW_LIST_SPACE}" PARENT_SCOPE)
-endfunction()
-
-# Appends a lis of item to a string which is a space-separated list, if they don't already exist.
-function(LIST_SPACES_APPEND_ONCE LIST_NAME)
-  string(REPLACE " " ";" _LIST ${${LIST_NAME}})
-  list(APPEND _LIST ${ARGN})
-  list(REMOVE_DUPLICATES _LIST)
-  to_list_spaces(_LIST NEW_LIST_SPACE)
-  set(${LIST_NAME} "${NEW_LIST_SPACE}" PARENT_SCOPE)
-endfunction()
-
-# Convenience function that does the same as LIST(FIND ...) but with a TRUE/FALSE return value.
-# Ex: IN_STR_LIST(MY_LIST "Searched item" WAS_FOUND)
-function(IN_STR_LIST LIST_NAME ITEM_SEARCHED RETVAL)
-  list(FIND ${LIST_NAME} ${ITEM_SEARCHED} FIND_POS)
-  if(${FIND_POS} EQUAL -1)
-    set(${RETVAL} FALSE PARENT_SCOPE)
-  else()
-    set(${RETVAL} TRUE PARENT_SCOPE)
-  endif()
-endfunction()
-
 # Returns a list of arguments that evaluate to true
-function(collect_true output_var output_count_var)
-  set(${output_var})
+function(count_true output_count_var)
+  set(lst)
   foreach(option_var IN LISTS ARGN)
     if(${option_var})
-      list(APPEND ${output_var} ${option_var})
+      list(APPEND lst ${option_var})
     endif()
   endforeach()
-  set(${output_var} ${${output_var}} PARENT_SCOPE)
-  list(LENGTH ${output_var} ${output_count_var})
-  set(${output_count_var} ${${output_count_var}} PARENT_SCOPE)
+  list(LENGTH lst lst_len)
+  set(${output_count_var} ${lst_len} PARENT_SCOPE)
 endfunction()
diff --git a/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
index d00a516..db8e536 100644
--- a/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
+++ b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
@@ -1,11 +1,11 @@
 if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
   message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
-endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif()
 
-if (NOT DEFINED CMAKE_INSTALL_PREFIX)
-  set (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
-endif ()
- message(${CMAKE_INSTALL_PREFIX})
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+  set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
+endif()
+message(${CMAKE_INSTALL_PREFIX})
 
 file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
 string(REGEX REPLACE "\n" ";" files "${files}")
@@ -19,8 +19,8 @@
       )
     if(NOT "${rm_retval}" STREQUAL 0)
       message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
-    endif(NOT "${rm_retval}" STREQUAL 0)
-  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    endif()
+  else()
     message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
-  endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
-endforeach(file)
+  endif()
+endforeach()
diff --git a/Utilities/cmcurl/CMake/curl-config.cmake b/Utilities/cmcurl/CMake/curl-config.cmake
deleted file mode 100644
index 119332c..0000000
--- a/Utilities/cmcurl/CMake/curl-config.cmake
+++ /dev/null
@@ -1,59 +0,0 @@
-
-get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
-if(NOT CURL_FIND_COMPONENTS)
-    set(CURL_FIND_COMPONENTS curl libcurl)
-    if(CURL_FIND_REQUIRED)
-        set(CURL_FIND_REQUIRED_curl TRUE)
-        set(CURL_FIND_REQUIRED_libcurl TRUE)
-    endif()
-endif()
-
-set(_curl_missing_components)
-foreach(_comp ${CURL_FIND_COMPONENTS})
-    if(EXISTS "${_DIR}/${_comp}-target.cmake")
-        include("${_DIR}/${_comp}-target.cmake")
-        set(CURL_${_comp}_FOUND TRUE)
-    else()
-        set(CURL_${_comp}_FOUND FALSE)
-        if(CURL_FIND_REQUIRED_${_comp})
-            set(CURL_FOUND FALSE)
-            list(APPEND _curl_missing_components ${_comp})
-        endif()
-    endif()
-endforeach()
-
-if(_curl_missing_components)
-    set(CURL_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components})
-else()
-    if(TARGET CURL::libcurl)
-        string(TOUPPER "${CMAKE_BUILD_TYPE}" _curl_current_config)
-        if(NOT _curl_current_config)
-            set(_curl_current_config "NOCONFIG")
-        endif()
-        get_target_property(_curl_configurations CURL::libcurl IMPORTED_CONFIGURATIONS)
-        list(FIND _curl_configurations "${_curl_current_config}" _i)
-        if(_i LESS 0)
-            set(_curl_config "RELEASE")
-            list(FIND _curl_configurations "${_curl_current_config}" _i)
-            if(_i LESS 0)
-                set(_curl_config "NOCONFIG")
-                list(FIND _curl_configurations "${_curl_current_config}" _i)
-            endif()
-        endif()
-
-        if(_i LESS 0)
-            set(_curl_current_config "") # let CMake pick config at random
-        else()
-	    set(_curl_current_config "_${_curl_current_config}")
-        endif()
-
-        get_target_property(CURL_INCLUDE_DIRS CURL::libcurl INTERFACE_INCLUDE_DIRECTORIES)
-        get_target_property(CURL_LIBRARIES CURL::libcurl "LOCATION${_curl_current_config}")
-        set(_curl_current_config)
-        set(_curl_configurations)
-        set(_i)
-    endif()
-endif()
-
-unset(_curl_missing_components)
diff --git a/Utilities/cmcurl/CMake/curl-config.cmake.in b/Utilities/cmcurl/CMake/curl-config.cmake.in
new file mode 100644
index 0000000..73e04c6
--- /dev/null
+++ b/Utilities/cmcurl/CMake/curl-config.cmake.in
@@ -0,0 +1,64 @@
+
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+if(NOT CURL_FIND_COMPONENTS)
+  set(CURL_FIND_COMPONENTS curl libcurl)
+  if(CURL_FIND_REQUIRED)
+    set(CURL_FIND_REQUIRED_curl TRUE)
+    set(CURL_FIND_REQUIRED_libcurl TRUE)
+  endif()
+endif()
+
+include(CMakeFindDependencyMacro)
+if(CURL_FIND_REQUIRED_libcurl)
+    find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@")
+endif()
+
+set(_curl_missing_components)
+foreach(_comp ${CURL_FIND_COMPONENTS})
+  if(EXISTS "${_DIR}/${_comp}-target.cmake")
+    include("${_DIR}/${_comp}-target.cmake")
+    set(CURL_${_comp}_FOUND TRUE)
+  else()
+    set(CURL_${_comp}_FOUND FALSE)
+    if(CURL_FIND_REQUIRED_${_comp})
+      set(CURL_FOUND FALSE)
+      list(APPEND _curl_missing_components ${_comp})
+    endif()
+  endif()
+endforeach()
+
+if(_curl_missing_components)
+  set(CURL_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components})
+else()
+  if(TARGET CURL::libcurl)
+    string(TOUPPER "${CMAKE_BUILD_TYPE}" _curl_current_config)
+    if(NOT _curl_current_config)
+      set(_curl_current_config "NOCONFIG")
+    endif()
+    get_target_property(_curl_configurations CURL::libcurl IMPORTED_CONFIGURATIONS)
+    list(FIND _curl_configurations "${_curl_current_config}" _i)
+    if(_i LESS 0)
+      set(_curl_config "RELEASE")
+      list(FIND _curl_configurations "${_curl_current_config}" _i)
+      if(_i LESS 0)
+        set(_curl_config "NOCONFIG")
+        list(FIND _curl_configurations "${_curl_current_config}" _i)
+      endif()
+    endif()
+
+    if(_i LESS 0)
+      set(_curl_current_config "") # let CMake pick config at random
+    else()
+      set(_curl_current_config "_${_curl_current_config}")
+    endif()
+
+    get_target_property(CURL_INCLUDE_DIRS CURL::libcurl INTERFACE_INCLUDE_DIRECTORIES)
+    get_target_property(CURL_LIBRARIES CURL::libcurl "LOCATION${_curl_current_config}")
+    set(_curl_current_config)
+    set(_curl_configurations)
+    set(_i)
+  endif()
+endif()
+
+unset(_curl_missing_components)
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index 0128214..636530e 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -2,6 +2,7 @@
 set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe")
 set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports")
 set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs")
+set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libraries")
 set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi")
 set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2")
 set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP")
@@ -23,7 +24,6 @@
 set(CURL_DISABLE_TFTP ON CACHE INTERNAL "Disable curl tftp protocol?")
 set(CURL_DISABLE_VERBOSE_STRINGS OFF CACHE INTERNAL "Do not disable curl verbosity")
 set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols")
-set(CURL_STATICLIB ON CACHE INTERNAL "Static curl")
 set(CURL_WERROR OFF CACHE INTERNAL "Turn compiler warnings into errors")
 set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions")
 set(ENABLE_ARES OFF CACHE INTERNAL "No curl c-ares support")
@@ -123,26 +123,26 @@
 # To check:
 # (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not.
 # (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options.
-cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
 include(Utilities)
 include(Macros)
 include(CMakeDependentOption)
 include(CheckCCompilerFlag)
 
-project( CURL C )
+project(CURL C)
 
 if(0) # This code not needed for building within CMake.
 message(WARNING "the curl cmake build system is poorly maintained. Be aware")
 endif()
 
-file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
-string (REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*"
+file(READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
+string(REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*"
   CURL_VERSION ${CURL_VERSION_H_CONTENTS})
-string (REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION})
-string (REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+"
+string(REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION})
+string(REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+"
   CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS})
-string (REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM})
+string(REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM})
 
 include_regular_expression("^.*$")    # Sukender: Is it necessary?
 
@@ -160,19 +160,19 @@
 set(OS "\"${CMAKE_SYSTEM_NAME}\"")
 
 include_directories(${PROJECT_BINARY_DIR}/include/curl)
-include_directories( ${CURL_SOURCE_DIR}/include )
+include_directories(${CURL_SOURCE_DIR}/include)
 
 option(CURL_WERROR "Turn compiler warnings into errors" OFF)
 option(PICKY_COMPILER "Enable picky compiler options" ON)
 option(BUILD_CURL_EXE "Set to ON to build curl executable." ON)
-option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
+option(BUILD_SHARED_LIBS "Build shared libraries" ON)
 option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
 if(WIN32)
   option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF)
   option(ENABLE_INET_PTON "Set to OFF to prevent usage of inet_pton when building against modern SDKs while still requiring compatibility with older Windows versions, such as Windows XP, Windows Server 2003 etc." ON)
 endif()
 
-CMAKE_DEPENDENT_OPTION(ENABLE_THREADED_RESOLVER "Set to ON to enable threaded DNS lookup"
+cmake_dependent_option(ENABLE_THREADED_RESOLVER "Set to ON to enable threaded DNS lookup"
         ON "NOT ENABLE_ARES"
         OFF)
 
@@ -180,19 +180,19 @@
 option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF)
 
 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
-  if (PICKY_COMPILER)
-    foreach (_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -Wdouble-promotion -Wno-system-headers)
+  if(PICKY_COMPILER)
+    foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -Wdouble-promotion -Wno-system-headers)
       # surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new
       # test result in.
-      CHECK_C_COMPILER_FLAG(${_CCOPT} OPT${_CCOPT})
+      check_c_compiler_flag(${_CCOPT} OPT${_CCOPT})
       if(OPT${_CCOPT})
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}")
       endif()
     endforeach()
-  endif(PICKY_COMPILER)
-endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
+  endif()
+endif()
 
-if (ENABLE_DEBUG)
+if(ENABLE_DEBUG)
   # DEBUGBUILD will be defined only for Debug builds
   if(NOT CMAKE_VERSION VERSION_LESS 3.0)
     set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>)
@@ -202,13 +202,15 @@
   set(ENABLE_CURLDEBUG ON)
 endif()
 
-if (ENABLE_CURLDEBUG)
+if(ENABLE_CURLDEBUG)
   set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG)
 endif()
 
 if(0) # This code not needed for building within CMake.
 # For debug libs and exes, add "-d" postfix
-set(CMAKE_DEBUG_POSTFIX "-d" CACHE STRING "Set debug library postfix")
+if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
+  set(CMAKE_DEBUG_POSTFIX "-d")
+endif()
 endif()
 
 # initialize CURL_LIBS
@@ -217,7 +219,7 @@
 if(ENABLE_ARES)
   set(USE_ARES 1)
   find_package(CARES REQUIRED)
-  list(APPEND CURL_LIBS ${CARES_LIBRARY} )
+  list(APPEND CURL_LIBS ${CARES_LIBRARY})
   set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY})
 endif()
 
@@ -297,11 +299,11 @@
 endif()
 
 if(0) # This code not needed for building within CMake.
-CURL_NROFF_CHECK()
 # Required for building manual, docs, tests
+curl_nroff_check()
 find_package(Perl)
 
-CMAKE_DEPENDENT_OPTION(ENABLE_MANUAL "to provide the built-in manual"
+cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual"
     ON "NROFF_USEFUL;PERL_FOUND"
     OFF)
 
@@ -326,27 +328,27 @@
 # Disable warnings on Borland to avoid changing 3rd party code.
 if(BORLAND)
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
-endif(BORLAND)
+endif()
 
 # If we are on AIX, do the _ALL_SOURCE magic
 if(${CMAKE_SYSTEM_NAME} MATCHES AIX)
   set(_ALL_SOURCE 1)
-endif(${CMAKE_SYSTEM_NAME} MATCHES AIX)
+endif()
 
 # Include all the necessary files for macros
-include (CheckFunctionExists)
-include (CheckIncludeFile)
-include (CheckIncludeFiles)
-include (CheckLibraryExists)
-include (CheckSymbolExists)
-include (CheckTypeSize)
-include (CheckCSourceCompiles)
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+include(CheckIncludeFiles)
+include(CheckLibraryExists)
+include(CheckSymbolExists)
+include(CheckTypeSize)
+include(CheckCSourceCompiles)
 
 # On windows preload settings
 if(WIN32)
   set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_=")
   include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake)
-endif(WIN32)
+endif()
 
 if(ENABLE_THREADED_RESOLVER)
   find_package(Threads REQUIRED)
@@ -375,13 +377,13 @@
   set(NOT_NEED_LIBNSL 1)
   check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND)
   check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI)
-endif(BEOS)
+endif()
 
 check_library_exists_concat("network" recv HAVE_LIBNETWORK)
 
 if(NOT NOT_NEED_LIBNSL)
   check_library_exists_concat("nsl"    gethostbyname  HAVE_LIBNSL)
-endif(NOT NOT_NEED_LIBNSL)
+endif()
 
 check_function_exists(gethostname HAVE_GETHOSTNAME)
 
@@ -409,14 +411,14 @@
   set(openssl_default OFF)
 endif()
 
-collect_true(enabled_ssl_options enabled_ssl_options_count
+count_true(enabled_ssl_options_count
   CMAKE_USE_WINSSL
   CMAKE_USE_DARWINSSL
   CMAKE_USE_OPENSSL
   CMAKE_USE_MBEDTLS
 )
-if(enabled_ssl_options_count GREATER 1)
-  message(FATAL_ERROR "Multiple SSL options specified: ${enabled_ssl_options}. Please pick at most one and disable the rest.")
+if(enabled_ssl_options_count GREATER "1")
+  set(CURL_WITH_MULTI_SSL ON)
 endif()
 
 if(CMAKE_USE_WINSSL)
@@ -454,9 +456,9 @@
   set(HAVE_LIBSSL ON)
   list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
   include_directories(${OPENSSL_INCLUDE_DIR})
+
   set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
   check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
-  check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
   check_include_file("openssl/err.h"    HAVE_OPENSSL_ERR_H)
   check_include_file("openssl/pem.h"    HAVE_OPENSSL_PEM_H)
   check_include_file("openssl/rsa.h"    HAVE_OPENSSL_RSA_H)
@@ -585,7 +587,6 @@
       endif()
     endif()
   endif()
-
 endif()
 
 # No ldap, no ldaps.
@@ -677,9 +678,8 @@
     check_function_exists(libssh2_scp_send64        HAVE_LIBSSH2_SCP_SEND64)
     check_function_exists(libssh2_session_handshake HAVE_LIBSSH2_SESSION_HANDSHAKE)
     set(CMAKE_EXTRA_INCLUDE_FILES "")
-
-  endif(LIBSSH2_FOUND)
-endif(CMAKE_USE_LIBSSH2)
+  endif()
+endif()
 
 option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF)
 mark_as_advanced(CMAKE_USE_GSSAPI)
@@ -761,68 +761,67 @@
     "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
 
 if("${CURL_CA_BUNDLE}" STREQUAL "")
-    message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.")
+  message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.")
 elseif("${CURL_CA_BUNDLE}" STREQUAL "none")
-    unset(CURL_CA_BUNDLE CACHE)
+  unset(CURL_CA_BUNDLE CACHE)
 elseif("${CURL_CA_BUNDLE}" STREQUAL "auto")
-    unset(CURL_CA_BUNDLE CACHE)
-    set(CURL_CA_BUNDLE_AUTODETECT TRUE)
+  unset(CURL_CA_BUNDLE CACHE)
+  set(CURL_CA_BUNDLE_AUTODETECT TRUE)
 else()
-    set(CURL_CA_BUNDLE_SET TRUE)
+  set(CURL_CA_BUNDLE_SET TRUE)
 endif()
 
 if("${CURL_CA_PATH}" STREQUAL "")
-    message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.")
+  message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.")
 elseif("${CURL_CA_PATH}" STREQUAL "none")
-    unset(CURL_CA_PATH CACHE)
+  unset(CURL_CA_PATH CACHE)
 elseif("${CURL_CA_PATH}" STREQUAL "auto")
-    unset(CURL_CA_PATH CACHE)
-    set(CURL_CA_PATH_AUTODETECT TRUE)
+  unset(CURL_CA_PATH CACHE)
+  set(CURL_CA_PATH_AUTODETECT TRUE)
 else()
-    set(CURL_CA_PATH_SET TRUE)
+  set(CURL_CA_PATH_SET TRUE)
 endif()
 
 if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT)
-    # Skip autodetection of unset CA path because CA bundle is set explicitly
+  # Skip autodetection of unset CA path because CA bundle is set explicitly
 elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT)
-    # Skip autodetection of unset CA bundle because CA path is set explicitly
+  # Skip autodetection of unset CA bundle because CA path is set explicitly
 elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT)
-    # first try autodetecting a CA bundle, then a CA path
+  # first try autodetecting a CA bundle, then a CA path
 
-    if(CURL_CA_BUNDLE_AUTODETECT)
-        set(SEARCH_CA_BUNDLE_PATHS
-            /etc/ssl/certs/ca-certificates.crt
-            /etc/pki/tls/certs/ca-bundle.crt
-            /usr/share/ssl/certs/ca-bundle.crt
-            /usr/local/share/certs/ca-root-nss.crt
-            /etc/ssl/cert.pem)
+  if(CURL_CA_BUNDLE_AUTODETECT)
+    set(SEARCH_CA_BUNDLE_PATHS
+        /etc/ssl/certs/ca-certificates.crt
+        /etc/pki/tls/certs/ca-bundle.crt
+        /usr/share/ssl/certs/ca-bundle.crt
+        /usr/local/share/certs/ca-root-nss.crt
+        /etc/ssl/cert.pem)
 
-        foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
-            if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
-                message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
-                set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}")
-                set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
-                break()
-            endif()
-        endforeach()
+    foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
+      if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
+        message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
+        set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}")
+        set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
+        break()
+      endif()
+    endforeach()
+  endif()
+
+  if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
+    if(EXISTS "/etc/ssl/certs")
+      set(CURL_CA_PATH "/etc/ssl/certs")
+      set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
     endif()
-
-    if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
-        if(EXISTS "/etc/ssl/certs")
-            set(CURL_CA_PATH "/etc/ssl/certs")
-            set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
-        endif()
-    endif()
+  endif()
 endif()
 
 if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS)
-    message(FATAL_ERROR
-            "CA path only supported by OpenSSL, GnuTLS or mbed TLS. "
-            "Set CURL_CA_PATH=none or enable one of those TLS backends.")
+  message(FATAL_ERROR
+          "CA path only supported by OpenSSL, GnuTLS or mbed TLS. "
+          "Set CURL_CA_PATH=none or enable one of those TLS backends.")
 endif()
 endif()
 
-
 # Check for header files
 if(NOT UNIX)
   check_include_file_concat("windows.h"      HAVE_WINDOWS_H)
@@ -920,7 +919,7 @@
 if(HAVE_SIZEOF_LONG_LONG)
   set(HAVE_LONGLONG 1)
   set(HAVE_LL 1)
-endif(HAVE_SIZEOF_LONG_LONG)
+endif()
 
 find_file(RANDOM_FILE urandom /dev)
 mark_as_advanced(RANDOM_FILE)
@@ -954,7 +953,7 @@
 check_symbol_exists(alarm         "${CURL_INCLUDES}" HAVE_ALARM)
 if(NOT HAVE_STRNCMPI)
   set(HAVE_STRCMPI)
-endif(NOT HAVE_STRNCMPI)
+endif()
 check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
 check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
 check_symbol_exists(gettimeofday  "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
@@ -970,6 +969,7 @@
 check_symbol_exists(getpass_r     "${CURL_INCLUDES}" HAVE_GETPASS_R)
 check_symbol_exists(strlcat       "${CURL_INCLUDES}" HAVE_STRLCAT)
 check_symbol_exists(getpwuid      "${CURL_INCLUDES}" HAVE_GETPWUID)
+check_symbol_exists(getpwuid_r    "${CURL_INCLUDES}" HAVE_GETPWUID_R)
 check_symbol_exists(geteuid       "${CURL_INCLUDES}" HAVE_GETEUID)
 check_symbol_exists(utime         "${CURL_INCLUDES}" HAVE_UTIME)
 check_symbol_exists(gmtime_r      "${CURL_INCLUDES}" HAVE_GMTIME_R)
@@ -982,7 +982,7 @@
 check_symbol_exists(SIGALRM       "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
 if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
   set(HAVE_SIGNAL 1)
-endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
+endif()
 check_symbol_exists(uname          "${CURL_INCLUDES}" HAVE_UNAME)
 check_symbol_exists(strtoll        "${CURL_INCLUDES}" HAVE_STRTOLL)
 check_symbol_exists(_strtoi64      "${CURL_INCLUDES}" HAVE__STRTOI64)
@@ -1016,35 +1016,35 @@
     add_definitions(-D_WIN32_WINNT=0x0501)
   endif()
 else()
-    check_function_exists(inet_pton HAVE_INET_PTON)
+  check_function_exists(inet_pton HAVE_INET_PTON)
 endif()
 
 check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR)
 if(HAVE_FSETXATTR)
   foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6)
-    curl_internal_test_run(${CURL_TEST})
-  endforeach(CURL_TEST)
-endif(HAVE_FSETXATTR)
+    curl_internal_test(${CURL_TEST})
+  endforeach()
+endif()
 
 # sigaction and sigsetjmp are special. Use special mechanism for
 # detecting those, but only if previous attempt failed.
 if(HAVE_SIGNAL_H)
   check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
-endif(HAVE_SIGNAL_H)
+endif()
 
 if(NOT HAVE_SIGSETJMP)
   if(HAVE_SETJMP_H)
     check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
     if(HAVE_MACRO_SIGSETJMP)
       set(HAVE_SIGSETJMP 1)
-    endif(HAVE_MACRO_SIGSETJMP)
-  endif(HAVE_SETJMP_H)
-endif(NOT HAVE_SIGSETJMP)
+    endif()
+  endif()
+endif()
 
 # If there is no stricmp(), do not allow LDAP to parse URLs
 if(NOT HAVE_STRICMP)
   set(HAVE_LDAP_URL_PARSE 1)
-endif(NOT HAVE_STRICMP)
+endif()
 
 # Do curl specific tests
 foreach(CURL_TEST
@@ -1082,12 +1082,12 @@
     HAVE_FILE_OFFSET_BITS
     )
   curl_internal_test(${CURL_TEST})
-endforeach(CURL_TEST)
+endforeach()
 
 if(HAVE_FILE_OFFSET_BITS)
   set(_FILE_OFFSET_BITS 64)
   set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
-endif(HAVE_FILE_OFFSET_BITS)
+endif()
 check_type_size("off_t"  SIZEOF_OFF_T)
 
 # include this header to get the type
@@ -1102,8 +1102,8 @@
     HAVE_GLIBC_STRERROR_R
     HAVE_POSIX_STRERROR_R
     )
-  curl_internal_test_run(${CURL_TEST})
-endforeach(CURL_TEST)
+  curl_internal_test(${CURL_TEST})
+endforeach()
 
 # Check for reentrant
 foreach(CURL_TEST
@@ -1117,9 +1117,9 @@
   if(NOT ${CURL_TEST})
     if(${CURL_TEST}_REENTRANT)
       set(NEED_REENTRANT 1)
-    endif(${CURL_TEST}_REENTRANT)
-  endif(NOT ${CURL_TEST})
-endforeach(CURL_TEST)
+    endif()
+  endif()
+endforeach()
 
 if(NEED_REENTRANT)
   foreach(CURL_TEST
@@ -1132,32 +1132,32 @@
     set(${CURL_TEST} 0)
     if(${CURL_TEST}_REENTRANT)
       set(${CURL_TEST} 1)
-    endif(${CURL_TEST}_REENTRANT)
-  endforeach(CURL_TEST)
-endif(NEED_REENTRANT)
+    endif()
+  endforeach()
+endif()
 
 if(HAVE_INET_NTOA_R_DECL_REENTRANT)
   set(HAVE_INET_NTOA_R_DECL 1)
   set(NEED_REENTRANT 1)
-endif(HAVE_INET_NTOA_R_DECL_REENTRANT)
+endif()
 
 # Some other minor tests
 
 if(NOT HAVE_IN_ADDR_T)
   set(in_addr_t "unsigned long")
-endif(NOT HAVE_IN_ADDR_T)
+endif()
 
 # Fix libz / zlib.h
 
 if(NOT CURL_SPECIAL_LIBZ)
   if(NOT HAVE_LIBZ)
     set(HAVE_ZLIB_H 0)
-  endif(NOT HAVE_LIBZ)
+  endif()
 
   if(NOT HAVE_ZLIB_H)
     set(HAVE_LIBZ 0)
-  endif(NOT HAVE_ZLIB_H)
-endif(NOT CURL_SPECIAL_LIBZ)
+  endif()
+endif()
 
 # Check for nonblocking
 set(HAVE_DISABLED_NONBLOCKING 1)
@@ -1166,16 +1166,13 @@
     HAVE_IOCTLSOCKET_CASE OR
     HAVE_O_NONBLOCK)
   set(HAVE_DISABLED_NONBLOCKING)
-endif(HAVE_FIONBIO OR
-  HAVE_IOCTLSOCKET OR
-  HAVE_IOCTLSOCKET_CASE OR
-  HAVE_O_NONBLOCK)
+endif()
 
 if(RETSIGTYPE_TEST)
   set(RETSIGTYPE void)
-else(RETSIGTYPE_TEST)
+else()
   set(RETSIGTYPE int)
-endif(RETSIGTYPE_TEST)
+endif()
 
 if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
   include(CheckCCompilerFlag)
@@ -1185,13 +1182,13 @@
     get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
     if(MPRINTF_COMPILE_FLAGS)
       set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
-    else(MPRINTF_COMPILE_FLAGS)
+    else()
       set(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
-    endif(MPRINTF_COMPILE_FLAGS)
+    endif()
     set_source_files_properties(mprintf.c PROPERTIES
       COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
-  endif(HAVE_C_FLAG_Wno_long_double)
-endif(CMAKE_COMPILER_IS_GNUCC AND APPLE)
+  endif()
+endif()
 
 if(HAVE_SOCKLEN_T)
   set(CURL_HAVE_SOCKLEN_T 1)
@@ -1226,19 +1223,25 @@
 
 add_definitions(-DHAVE_CONFIG_H)
 
-# For windows, all compilers used by cmake should support large files
+# For Windows, all compilers used by CMake should support large files
 if(WIN32)
   set(USE_WIN32_LARGE_FILES ON)
-endif(WIN32)
+
+  # Use the manifest embedded in the Windows Resource
+  set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST")
+endif()
 
 if(MSVC)
+  # Disable default manifest added by CMake
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
+
   add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
   if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
     string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-  else(CMAKE_C_FLAGS MATCHES "/W[0-4]")
+  else()
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
-  endif(CMAKE_C_FLAGS MATCHES "/W[0-4]")
-endif(MSVC)
+  endif()
+endif()
 
 if(CURL_WERROR)
   if(MSVC_VERSION)
@@ -1247,7 +1250,7 @@
     # this assumes clang or gcc style options
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
   endif()
-endif(CURL_WERROR)
+endif()
 
 # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
 function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
@@ -1266,9 +1269,9 @@
 endfunction()
 
 if(WIN32 AND NOT CYGWIN)
-    set(CURL_INSTALL_CMAKE_DIR CMake)
+  set(CURL_INSTALL_CMAKE_DIR CMake)
 else()
-    set(CURL_INSTALL_CMAKE_DIR lib/cmake/curl)
+  set(CURL_INSTALL_CMAKE_DIR lib/cmake/curl)
 endif()
 
 if(USE_MANUAL)
@@ -1286,7 +1289,7 @@
 add_executable(LIBCURL curltest.c)
 target_link_libraries(LIBCURL cmcurl)
 
-if(CMAKE_CURL_TEST_URL)
+if(BUILD_TESTING AND CMAKE_CURL_TEST_URL)
   add_test(curl LIBCURL ${CMAKE_CURL_TEST_URL})
 endif()
 
@@ -1381,11 +1384,12 @@
 # TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB?
 set(CPPFLAG_CURL_STATICLIB  "")
 set(CURLVERSION             "${CURL_VERSION}")
-set(ENABLE_SHARED           "yes")
-if(CURL_STATICLIB)
-  set(ENABLE_STATIC         "yes")
-else()
+if(BUILD_SHARED_LIBS)
+  set(ENABLE_SHARED         "yes")
   set(ENABLE_STATIC         "no")
+else()
+  set(ENABLE_SHARED         "no")
+  set(ENABLE_STATIC         "yes")
 endif()
 set(exec_prefix             "\${prefix}")
 set(includedir              "\${prefix}/include")
@@ -1409,6 +1413,9 @@
 set(VERSIONNUM              "${CURL_VERSION_NUM}")
 
 # Finally generate a "curl-config" matching this config
+# Use:
+# * ENABLE_SHARED
+# * ENABLE_STATIC
 configure_file("${CURL_SOURCE_DIR}/curl-config.in"
                "${CURL_BINARY_DIR}/curl-config" @ONLY)
 install(FILES "${CURL_BINARY_DIR}/curl-config"
@@ -1442,9 +1449,9 @@
     COMPATIBILITY SameMajorVersion
 )
 
-configure_file(CMake/curl-config.cmake
+configure_file(CMake/curl-config.cmake.in
         "${PROJECT_BINARY_DIR}/curl-config.cmake"
-        COPYONLY
+        @ONLY
 )
 
 install(
diff --git a/Utilities/cmcurl/include/curl/curl.h b/Utilities/cmcurl/include/curl/curl.h
index 10e5c49..d9955bd 100644
--- a/Utilities/cmcurl/include/curl/curl.h
+++ b/Utilities/cmcurl/include/curl/curl.h
@@ -691,6 +691,7 @@
  * CURLAUTH_NTLM         - HTTP NTLM authentication
  * CURLAUTH_DIGEST_IE    - HTTP Digest authentication with IE flavour
  * CURLAUTH_NTLM_WB      - HTTP NTLM authentication delegated to winbind helper
+ * CURLAUTH_BEARER       - HTTP Bearer token authentication
  * CURLAUTH_ONLY         - Use together with a single other type to force no
  *                         authentication or just that single type
  * CURLAUTH_ANY          - All fine types set
@@ -708,6 +709,7 @@
 #define CURLAUTH_NTLM         (((unsigned long)1)<<3)
 #define CURLAUTH_DIGEST_IE    (((unsigned long)1)<<4)
 #define CURLAUTH_NTLM_WB      (((unsigned long)1)<<5)
+#define CURLAUTH_BEARER       (((unsigned long)1)<<6)
 #define CURLAUTH_ONLY         (((unsigned long)1)<<31)
 #define CURLAUTH_ANY          (~CURLAUTH_DIGEST_IE)
 #define CURLAUTH_ANYSAFE      (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE))
@@ -1847,6 +1849,13 @@
   /* shuffle addresses before use when DNS returns multiple */
   CINIT(DNS_SHUFFLE_ADDRESSES, LONG, 275),
 
+  /* Specify which TLS 1.3 ciphers suites to use */
+  CINIT(TLS13_CIPHERS, STRINGPOINT, 276),
+  CINIT(PROXY_TLS13_CIPHERS, STRINGPOINT, 277),
+
+  /* Disallow specifying username/login in URL. */
+  CINIT(DISALLOW_USERNAME_IN_URL, LONG, 278),
+
   CURLOPT_LASTENTRY /* the last unused */
 } CURLoption;
 
@@ -2527,7 +2536,17 @@
   CURLINFO_SCHEME           = CURLINFO_STRING + 49,
   /* Fill in new entries below here! */
 
-  CURLINFO_LASTONE          = 49
+  /* Preferably these would be defined conditionally based on the
+     sizeof curl_off_t being 64-bits */
+  CURLINFO_TOTAL_TIME_T     = CURLINFO_OFF_T + 50,
+  CURLINFO_NAMELOOKUP_TIME_T = CURLINFO_OFF_T + 51,
+  CURLINFO_CONNECT_TIME_T   = CURLINFO_OFF_T + 52,
+  CURLINFO_PRETRANSFER_TIME_T = CURLINFO_OFF_T + 53,
+  CURLINFO_STARTTRANSFER_TIME_T = CURLINFO_OFF_T + 54,
+  CURLINFO_REDIRECT_TIME_T  = CURLINFO_OFF_T + 55,
+  CURLINFO_APPCONNECT_TIME_T = CURLINFO_OFF_T + 56,
+
+  CURLINFO_LASTONE          = 56
 } CURLINFO;
 
 /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
@@ -2570,6 +2589,7 @@
   CURL_LOCK_DATA_DNS,
   CURL_LOCK_DATA_SSL_SESSION,
   CURL_LOCK_DATA_CONNECT,
+  CURL_LOCK_DATA_PSL,
   CURL_LOCK_DATA_LAST
 } curl_lock_data;
 
diff --git a/Utilities/cmcurl/include/curl/curlver.h b/Utilities/cmcurl/include/curl/curlver.h
index 2d1505a..e266f18 100644
--- a/Utilities/cmcurl/include/curl/curlver.h
+++ b/Utilities/cmcurl/include/curl/curlver.h
@@ -30,13 +30,13 @@
 
 /* This is the version number of the libcurl package from which this header
    file origins: */
-#define LIBCURL_VERSION "7.60.0"
+#define LIBCURL_VERSION "7.61.1"
 
 /* The numeric version number is also available "in parts" by using these
    defines: */
 #define LIBCURL_VERSION_MAJOR 7
-#define LIBCURL_VERSION_MINOR 60
-#define LIBCURL_VERSION_PATCH 0
+#define LIBCURL_VERSION_MINOR 61
+#define LIBCURL_VERSION_PATCH 1
 
 /* This is the numeric version of the libcurl version number, meant for easier
    parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
@@ -57,7 +57,7 @@
    CURL_VERSION_BITS() macro since curl's own configure script greps for it
    and needs it to contain the full number.
 */
-#define LIBCURL_VERSION_NUM 0x073C00
+#define LIBCURL_VERSION_NUM 0x073D01
 
 /*
  * This is the date and time when the full source package was created. The
diff --git a/Utilities/cmcurl/include/curl/system.h b/Utilities/cmcurl/include/curl/system.h
index eac4cfe..a54fd58 100644
--- a/Utilities/cmcurl/include/curl/system.h
+++ b/Utilities/cmcurl/include/curl/system.h
@@ -320,6 +320,24 @@
 #  define CURL_PULL_SYS_TYPES_H      1
 #  define CURL_PULL_SYS_SOCKET_H     1
 
+#elif defined(__xlc__) /* IBM xlc compiler */
+#  if !defined(_LP64)
+#    define CURL_TYPEOF_CURL_OFF_T     long long
+#    define CURL_FORMAT_CURL_OFF_T     "lld"
+#    define CURL_FORMAT_CURL_OFF_TU    "llu"
+#    define CURL_SUFFIX_CURL_OFF_T     LL
+#    define CURL_SUFFIX_CURL_OFF_TU    ULL
+#  else
+#    define CURL_TYPEOF_CURL_OFF_T     long
+#    define CURL_FORMAT_CURL_OFF_T     "ld"
+#    define CURL_FORMAT_CURL_OFF_TU    "lu"
+#    define CURL_SUFFIX_CURL_OFF_T     L
+#    define CURL_SUFFIX_CURL_OFF_TU    UL
+#  endif
+#  define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+#  define CURL_PULL_SYS_TYPES_H      1
+#  define CURL_PULL_SYS_SOCKET_H     1
+
 /* ===================================== */
 /*    KEEP MSVC THE PENULTIMATE ENTRY    */
 /* ===================================== */
@@ -344,7 +362,7 @@
 /*    KEEP GENERIC GCC THE LAST ENTRY    */
 /* ===================================== */
 
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && !defined(_SCO_DS)
 #  if !defined(__LP64__) &&                                             \
   (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) ||      \
    defined(__ppc__) || defined(__powerpc__) || defined(__arm__) ||      \
diff --git a/Utilities/cmcurl/include/curl/typecheck-gcc.h b/Utilities/cmcurl/include/curl/typecheck-gcc.h
index 3a0f253..a6f6386 100644
--- a/Utilities/cmcurl/include/curl/typecheck-gcc.h
+++ b/Utilities/cmcurl/include/curl/typecheck-gcc.h
@@ -428,7 +428,7 @@
  * == or whatsoever.
  */
 
-/* XXX: should evaluate to true iff expr is a pointer */
+/* XXX: should evaluate to true if expr is a pointer */
 #define _curl_is_any_ptr(expr)                                                \
   (sizeof(expr) == sizeof(void *))
 
diff --git a/Utilities/cmcurl/lib/CMakeLists.txt b/Utilities/cmcurl/lib/CMakeLists.txt
index 9f19daa..3d52105 100644
--- a/Utilities/cmcurl/lib/CMakeLists.txt
+++ b/Utilities/cmcurl/lib/CMakeLists.txt
@@ -1,5 +1,13 @@
 set(LIB_NAME cmcurl)
 
+if(BUILD_SHARED_LIBS)
+  set(CURL_STATICLIB NO)
+else()
+  set(CURL_STATICLIB YES)
+endif()
+
+# Use:
+# * CURL_STATICLIB
 configure_file(curl_config.h.cmake
   ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
 
@@ -59,14 +67,6 @@
   include_directories(${CARES_INCLUDE_DIR})
 endif()
 
-if(CURL_STATICLIB)
-  # Static lib
-  set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC)
-else()
-  # DLL / so dynamic lib
-  set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED)
-endif()
-
 # For windows we want to install OPENSSL_LIBRARIES dlls
 # and also copy them into the build tree so that testing
 # can find them.
@@ -93,16 +93,19 @@
 
 add_library(
   ${LIB_NAME}
-  ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC}
   ${HHEADERS} ${CSOURCES}
   ${CMAKE_CURL_SSL_DLLS}
   )
 
+if(NOT BUILD_SHARED_LIBS)
+    set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB)
+endif()
+
 target_link_libraries(${LIB_NAME} ${CURL_LIBS})
 
 if(0) # This code not needed for building within CMake.
 if(WIN32)
-  add_definitions( -D_USRDLL )
+  add_definitions(-D_USRDLL)
 endif()
 endif()
 
@@ -119,21 +122,14 @@
 set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
 
 if(WIN32)
-  if(NOT CURL_STATICLIB)
+  if(BUILD_SHARED_LIBS)
     # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib"
     set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
-
-    set_target_properties (${LIB_NAME} PROPERTIES
-       DEBUG_POSTFIX "-d"
-       # Note: no postfix for release variants, let user choose what style of release he wants
-       # MINSIZEREL_POSTFIX "-z"
-       # RELWITHDEBINFO_POSTFIX "-g"
-       )
   endif()
 endif()
 
 target_include_directories(${LIB_NAME} INTERFACE
-	$<INSTALL_INTERFACE:include>)
+  $<INSTALL_INTERFACE:include>)
 
 install(TARGETS ${LIB_NAME}
   EXPORT libcurl-target
diff --git a/Utilities/cmcurl/lib/Makefile.inc b/Utilities/cmcurl/lib/Makefile.inc
index 61c2341..76ca6d0 100644
--- a/Utilities/cmcurl/lib/Makefile.inc
+++ b/Utilities/cmcurl/lib/Makefile.inc
@@ -54,7 +54,7 @@
   http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c        \
   curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c          \
   x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c      \
-  mime.c sha256.c setopt.c curl_path.c curl_ctype.c curl_range.c
+  mime.c sha256.c setopt.c curl_path.c curl_ctype.c curl_range.c psl.c
 
 LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
   formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h         \
@@ -74,7 +74,7 @@
   curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h       \
   x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h           \
   curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h     \
-  curl_path.h curl_ctype.h curl_range.h
+  curl_path.h curl_ctype.h curl_range.h psl.h
 
 LIB_RCFILES = libcurl.rc
 
diff --git a/Utilities/cmcurl/lib/asyn-ares.c b/Utilities/cmcurl/lib/asyn-ares.c
index aa581a4..5cfb260 100644
--- a/Utilities/cmcurl/lib/asyn-ares.c
+++ b/Utilities/cmcurl/lib/asyn-ares.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -312,22 +312,25 @@
     conn->async.os_specific;
   CURLcode result = CURLE_OK;
 
-  *dns = NULL;
+  if(dns)
+    *dns = NULL;
 
   waitperform(conn, 0);
 
   if(res && !res->num_pending) {
-    (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai);
-    /* temp_ai ownership is moved to the connection, so we need not free-up
-       them */
-    res->temp_ai = NULL;
+    if(dns) {
+      (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai);
+      /* temp_ai ownership is moved to the connection, so we need not free-up
+         them */
+      res->temp_ai = NULL;
+    }
     if(!conn->async.dns) {
       failf(data, "Could not resolve: %s (%s)",
             conn->async.hostname, ares_strerror(conn->async.status));
       result = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY:
         CURLE_COULDNT_RESOLVE_HOST;
     }
-    else
+    else if(dns)
       *dns = conn->async.dns;
 
     destroy_async_data(&conn->async);
@@ -390,7 +393,7 @@
       timeout_ms = 1000;
 
     waitperform(conn, timeout_ms);
-    result = Curl_resolver_is_resolved(conn, &temp_entry);
+    result = Curl_resolver_is_resolved(conn, entry?&temp_entry:NULL);
 
     if(result || conn->async.done)
       break;
@@ -472,17 +475,19 @@
     return;
 
   res = (struct ResolverResults *)conn->async.os_specific;
-  res->num_pending--;
+  if(res) {
+    res->num_pending--;
 
-  if(CURL_ASYNC_SUCCESS == status) {
-    Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
-    if(ai) {
-      compound_results(res, ai);
+    if(CURL_ASYNC_SUCCESS == status) {
+      Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
+      if(ai) {
+        compound_results(res, ai);
+      }
     }
+    /* A successful result overwrites any previous error */
+    if(res->last_status != ARES_SUCCESS)
+      res->last_status = status;
   }
-  /* A successful result overwrites any previous error */
-  if(res->last_status != ARES_SUCCESS)
-    res->last_status = status;
 }
 
 /*
diff --git a/Utilities/cmcurl/lib/asyn-thread.c b/Utilities/cmcurl/lib/asyn-thread.c
index b11fab2..2a59294 100644
--- a/Utilities/cmcurl/lib/asyn-thread.c
+++ b/Utilities/cmcurl/lib/asyn-thread.c
@@ -182,8 +182,6 @@
   return &(((struct thread_data *)conn->async.os_specific)->tsd);
 }
 
-#define CONN_THREAD_SYNC_DATA(conn) &(((conn)->async.os_specific)->tsd);
-
 /* Destroy resolver thread synchronization data */
 static
 void destroy_thread_sync_data(struct thread_sync_data * tsd)
@@ -481,8 +479,10 @@
   DEBUGASSERT(conn && td);
 
   /* wait for the thread to resolve the name */
-  if(Curl_thread_join(&td->thread_hnd))
-    result = getaddrinfo_complete(conn);
+  if(Curl_thread_join(&td->thread_hnd)) {
+    if(entry)
+      result = getaddrinfo_complete(conn);
+  }
   else
     DEBUGASSERT(0);
 
@@ -572,10 +572,10 @@
   (void)socks;
   (void)numsocks;
   ms = Curl_timediff(Curl_now(), reslv->start);
-  if(ms < 10)
-    milli = ms/3;
+  if(ms < 3)
+    milli = 0;
   else if(ms <= 50)
-    milli = 10;
+    milli = ms/3;
   else if(ms <= 250)
     milli = 50;
   else
diff --git a/Utilities/cmcurl/lib/base64.c b/Utilities/cmcurl/lib/base64.c
index 204a227..6370e4c 100644
--- a/Utilities/cmcurl/lib/base64.c
+++ b/Utilities/cmcurl/lib/base64.c
@@ -49,13 +49,12 @@
   unsigned long i, x = 0;
 
   for(i = 0, s = src; i < 4; i++, s++) {
-    unsigned long v = 0;
-
     if(*s == '=') {
       x = (x << 6);
       padding++;
     }
     else {
+      unsigned long v = 0;
       p = base64;
 
       while(*p && (*p != *s)) {
diff --git a/Utilities/cmcurl/lib/conncache.c b/Utilities/cmcurl/lib/conncache.c
index b8f5444..6fbf3b1 100644
--- a/Utilities/cmcurl/lib/conncache.c
+++ b/Utilities/cmcurl/lib/conncache.c
@@ -6,7 +6,7 @@
  *                             \___|\___/|_| \_\_____|
  *
  * Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se>
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -63,10 +63,9 @@
 
 static void conn_llist_dtor(void *user, void *element)
 {
-  struct connectdata *data = element;
+  struct connectdata *conn = element;
   (void)user;
-
-  data->bundle = NULL;
+  conn->bundle = NULL;
 }
 
 static CURLcode bundle_create(struct Curl_easy *data,
@@ -96,14 +95,13 @@
 }
 
 /* Add a connection to a bundle */
-static CURLcode bundle_add_conn(struct connectbundle *cb_ptr,
-                                struct connectdata *conn)
+static void bundle_add_conn(struct connectbundle *cb_ptr,
+                            struct connectdata *conn)
 {
   Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn,
                          &conn->bundle_node);
   conn->bundle = cb_ptr;
   cb_ptr->num_connections++;
-  return CURLE_OK;
 }
 
 /* Remove a connection from a bundle */
@@ -263,7 +261,7 @@
 CURLcode Curl_conncache_add_conn(struct conncache *connc,
                                  struct connectdata *conn)
 {
-  CURLcode result;
+  CURLcode result = CURLE_OK;
   struct connectbundle *bundle;
   struct connectbundle *new_bundle = NULL;
   struct Curl_easy *data = conn->data;
@@ -290,19 +288,13 @@
     bundle = new_bundle;
   }
 
-  result = bundle_add_conn(bundle, conn);
-  if(result) {
-    if(new_bundle)
-      conncache_remove_bundle(data->state.conn_cache, new_bundle);
-    goto unlock;
-  }
-
+  bundle_add_conn(bundle, conn);
   conn->connection_id = connc->next_connection_id++;
   connc->num_conn++;
 
   DEBUGF(infof(conn->data, "Added connection %ld. "
-               "The cache now contains %" CURL_FORMAT_CURL_OFF_TU " members\n",
-               conn->connection_id, (curl_off_t) connc->num_conn));
+               "The cache now contains %zu members\n",
+               conn->connection_id, connc->num_conn));
 
   unlock:
   CONN_UNLOCK(data);
@@ -320,7 +312,7 @@
      due to a failed connection attempt, before being added to a bundle */
   if(bundle) {
     if(lock) {
-      CONN_LOCK(conn->data);
+      CONN_LOCK(data);
     }
     bundle_remove_conn(bundle, conn);
     if(bundle->num_connections == 0)
@@ -328,12 +320,11 @@
     conn->bundle = NULL; /* removed from it */
     if(connc) {
       connc->num_conn--;
-      DEBUGF(infof(conn->data, "The cache now contains %"
-                   CURL_FORMAT_CURL_OFF_TU " members\n",
-                   (curl_off_t) connc->num_conn));
+      DEBUGF(infof(data, "The cache now contains %zu members\n",
+                   connc->num_conn));
     }
     if(lock) {
-      CONN_UNLOCK(conn->data);
+      CONN_UNLOCK(data);
     }
   }
 }
@@ -441,18 +432,11 @@
     infof(data, "Connection cache is full, closing the oldest one.\n");
 
     conn_candidate = Curl_conncache_extract_oldest(data);
-
     if(conn_candidate) {
-      /* Set the connection's owner correctly */
-      conn_candidate->data = data;
-
       /* the winner gets the honour of being disconnected */
-      (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE);
+      (void)Curl_disconnect(data, conn_candidate, /* dead_connection */ FALSE);
     }
   }
-  CONN_LOCK(data);
-  conn->inuse = FALSE; /* Mark the connection unused */
-  CONN_UNLOCK(data);
 
   return (conn_candidate == conn) ? FALSE : TRUE;
 
@@ -486,7 +470,7 @@
   while(curr) {
     conn = curr->ptr;
 
-    if(!conn->inuse) {
+    if(!CONN_INUSE(conn)) {
       /* Set higher score for the age passed since the connection was used */
       score = Curl_timediff(now, conn->now);
 
@@ -501,9 +485,9 @@
     /* remove it to prevent another thread from nicking it */
     bundle_remove_conn(bundle, conn_candidate);
     data->state.conn_cache->num_conn--;
-    DEBUGF(infof(data, "The cache now contains %"
-                 CURL_FORMAT_CURL_OFF_TU " members\n",
-                 (curl_off_t) data->state.conn_cache->num_conn));
+    DEBUGF(infof(data, "The cache now contains %zu members\n",
+                 data->state.conn_cache->num_conn));
+    conn_candidate->data = data; /* associate! */
   }
 
   return conn_candidate;
@@ -544,7 +528,7 @@
     while(curr) {
       conn = curr->ptr;
 
-      if(!conn->inuse) {
+      if(!CONN_INUSE(conn)) {
         /* Set higher score for the age passed since the connection was used */
         score = Curl_timediff(now, conn->now);
 
@@ -563,9 +547,9 @@
     /* remove it to prevent another thread from nicking it */
     bundle_remove_conn(bundle_candidate, conn_candidate);
     connc->num_conn--;
-    DEBUGF(infof(data, "The cache now contains %"
-                 CURL_FORMAT_CURL_OFF_TU " members\n",
-                 (curl_off_t) connc->num_conn));
+    DEBUGF(infof(data, "The cache now contains %zu members\n",
+                 connc->num_conn));
+    conn_candidate->data = data; /* associate! */
   }
   CONN_UNLOCK(data);
 
@@ -586,7 +570,7 @@
                                      pointer */
     /* This will remove the connection from the cache */
     connclose(conn, "kill all");
-    (void)Curl_disconnect(conn, FALSE);
+    (void)Curl_disconnect(connc->closure_handle, conn, FALSE);
     sigpipe_restore(&pipe_st);
 
     conn = Curl_conncache_find_first_connection(connc);
diff --git a/Utilities/cmcurl/lib/conncache.h b/Utilities/cmcurl/lib/conncache.h
index d8ad80f..eedd7a8 100644
--- a/Utilities/cmcurl/lib/conncache.h
+++ b/Utilities/cmcurl/lib/conncache.h
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2015 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  * Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
  *
  * This software is licensed as described in the file COPYING, which
@@ -63,7 +63,7 @@
 
 bool Curl_conncache_return_conn(struct connectdata *conn);
 CURLcode Curl_conncache_add_conn(struct conncache *connc,
-                                 struct connectdata *conn);
+                                 struct connectdata *conn) WARN_UNUSED_RESULT;
 void Curl_conncache_remove_conn(struct connectdata *conn,
                                 bool lock);
 bool Curl_conncache_foreach(struct Curl_easy *data,
diff --git a/Utilities/cmcurl/lib/connect.c b/Utilities/cmcurl/lib/connect.c
index 1a27ae1..41f2202 100644
--- a/Utilities/cmcurl/lib/connect.c
+++ b/Utilities/cmcurl/lib/connect.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -1237,8 +1237,6 @@
 curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
                                   struct connectdata **connp)
 {
-  curl_socket_t sockfd;
-
   DEBUGASSERT(data);
 
   /* this works for an easy handle:
@@ -1261,15 +1259,15 @@
       return CURL_SOCKET_BAD;
     }
 
-    if(connp)
+    if(connp) {
       /* only store this if the caller cares for it */
       *connp = c;
-    sockfd = c->sock[FIRSTSOCKET];
+      c->data = data;
+    }
+    return c->sock[FIRSTSOCKET];
   }
   else
     return CURL_SOCKET_BAD;
-
-  return sockfd;
 }
 
 /*
diff --git a/Utilities/cmcurl/lib/content_encoding.c b/Utilities/cmcurl/lib/content_encoding.c
index 7c979ef..6d47537 100644
--- a/Utilities/cmcurl/lib/content_encoding.c
+++ b/Utilities/cmcurl/lib/content_encoding.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -71,13 +71,13 @@
 #define RESERVED     0xE0 /* bits 5..7: reserved */
 
 typedef enum {
-  ZLIB_UNINIT,          /* uninitialized */
-  ZLIB_INIT,            /* initialized */
-  ZLIB_INFLATING,       /* Inflating started. */
-  ZLIB_GZIP_HEADER,     /* reading gzip header */
-  ZLIB_GZIP_TRAILER,    /* reading gzip trailer */
-  ZLIB_GZIP_INFLATING,  /* inflating gzip stream */
-  ZLIB_INIT_GZIP        /* initialized in transparent gzip mode */
+  ZLIB_UNINIT,               /* uninitialized */
+  ZLIB_INIT,                 /* initialized */
+  ZLIB_INFLATING,            /* inflating started. */
+  ZLIB_EXTERNAL_TRAILER,     /* reading external trailer */
+  ZLIB_GZIP_HEADER,          /* reading gzip header */
+  ZLIB_GZIP_INFLATING,       /* inflating gzip stream */
+  ZLIB_INIT_GZIP             /* initialized in transparent gzip mode */
 } zlibInitState;
 
 /* Writer parameters. */
@@ -150,8 +150,8 @@
   if(result || !zp->trailerlen)
     result = exit_zlib(conn, z, &zp->zlib_init, result);
   else {
-    /* Only occurs for gzip with zlib < 1.2.0.4. */
-    zp->zlib_init = ZLIB_GZIP_TRAILER;
+    /* Only occurs for gzip with zlib < 1.2.0.4 or raw deflate. */
+    zp->zlib_init = ZLIB_EXTERNAL_TRAILER;
   }
   return result;
 }
@@ -163,7 +163,6 @@
   z_stream *z = &zp->z;         /* zlib state structure */
   uInt nread = z->avail_in;
   Bytef *orig_in = z->next_in;
-  int status;                   /* zlib status */
   bool done = FALSE;
   CURLcode result = CURLE_OK;   /* Curl_client_write status */
   char *decomp;                 /* Put the decompressed data here. */
@@ -184,13 +183,20 @@
   /* because the buffer size is fixed, iteratively decompress and transfer to
      the client via downstream_write function. */
   while(!done) {
+    int status;                   /* zlib status */
     done = TRUE;
 
     /* (re)set buffer for decompressed output for every iteration */
     z->next_out = (Bytef *) decomp;
     z->avail_out = DSIZ;
 
+#ifdef Z_BLOCK
+    /* Z_BLOCK is only available in zlib ver. >= 1.2.0.5 */
     status = inflate(z, Z_BLOCK);
+#else
+    /* fallback for zlib ver. < 1.2.0.5 */
+    status = inflate(z, Z_SYNC_FLUSH);
+#endif
 
     /* Flush output data if some. */
     if(z->avail_out != DSIZ) {
@@ -227,6 +233,7 @@
           z->next_in = orig_in;
           z->avail_in = nread;
           zp->zlib_init = ZLIB_INFLATING;
+          zp->trailerlen = 4; /* Tolerate up to 4 unknown trailer bytes. */
           done = FALSE;
           break;
         }
@@ -281,6 +288,9 @@
   z->next_in = (Bytef *) buf;
   z->avail_in = (uInt) nbytes;
 
+  if(zp->zlib_init == ZLIB_EXTERNAL_TRAILER)
+    return process_trailer(conn, zp);
+
   /* Now uncompress the data */
   return inflate_stream(conn, writer, ZLIB_INFLATING);
 }
@@ -526,7 +536,7 @@
   }
   break;
 
-  case ZLIB_GZIP_TRAILER:
+  case ZLIB_EXTERNAL_TRAILER:
     z->next_in = (Bytef *) buf;
     z->avail_in = (uInt) nbytes;
     return process_trailer(conn, zp);
@@ -755,7 +765,6 @@
   const content_encoding * const *cep;
   const content_encoding *ce;
   char *ace;
-  char *p;
 
   for(cep = encodings; *cep; cep++) {
     ce = *cep;
@@ -768,7 +777,7 @@
 
   ace = malloc(len);
   if(ace) {
-    p = ace;
+    char *p = ace;
     for(cep = encodings; *cep; cep++) {
       ce = *cep;
       if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) {
@@ -915,10 +924,9 @@
 static const content_encoding *find_encoding(const char *name, size_t len)
 {
   const content_encoding * const *cep;
-  const content_encoding *ce;
 
   for(cep = encodings; *cep; cep++) {
-    ce = *cep;
+    const content_encoding *ce = *cep;
     if((strncasecompare(name, ce->name, len) && !ce->name[len]) ||
        (ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len]))
       return ce;
diff --git a/Utilities/cmcurl/lib/cookie.c b/Utilities/cmcurl/lib/cookie.c
index 2c028b3..da49c2a 100644
--- a/Utilities/cmcurl/lib/cookie.c
+++ b/Utilities/cmcurl/lib/cookie.c
@@ -40,7 +40,7 @@
         received from a server.
 
         The function need to replace previously stored lines that this new
-        line superceeds.
+        line supersedes.
 
         It may remove lines that are expired.
 
@@ -84,12 +84,9 @@
 
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
 
-#ifdef USE_LIBPSL
-# include <libpsl.h>
-#endif
-
 #include "urldata.h"
 #include "cookie.h"
+#include "psl.h"
 #include "strtok.h"
 #include "sendf.h"
 #include "slist.h"
@@ -253,9 +250,9 @@
   len = strlen(domain);
   last = memrchr(domain, '.', len);
   if(last) {
-    first = memrchr(domain, '.', (size_t) (last - domain));
+    first = memrchr(domain, '.', (last - domain));
     if(first)
-      len -= (size_t) (++first - domain);
+      len -= (++first - domain);
   }
 
   if(outlen)
@@ -379,13 +376,13 @@
  */
 static void remove_expired(struct CookieInfo *cookies)
 {
-  struct Cookie *co, *nx, *pv;
+  struct Cookie *co, *nx;
   curl_off_t now = (curl_off_t)time(NULL);
   unsigned int i;
 
   for(i = 0; i < COOKIE_HASH_SIZE; i++) {
+    struct Cookie *pv = NULL;
     co = cookies->cookies[i];
-    pv = NULL;
     while(co) {
       nx = co->next;
       if(co->expires && co->expires < now) {
@@ -406,6 +403,12 @@
   }
 }
 
+/* Make sure domain contains a dot or is localhost. */
+static bool bad_domain(const char *domain)
+{
+  return !strchr(domain, '.') && !strcasecompare(domain, "localhost");
+}
+
 /****************************************************************************
  *
  * Curl_cookie_add()
@@ -442,10 +445,6 @@
   bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */
   size_t myhash;
 
-#ifdef USE_LIBPSL
-  const psl_ctx_t *psl;
-#endif
-
 #ifdef CURL_DISABLE_VERBOSE_STRINGS
   (void)data;
 #endif
@@ -497,7 +496,7 @@
              name + contents. Chrome and Firefox support 4095 or 4096 bytes
              combo. */
           freecookie(co);
-          infof(data, "oversized cookie dropped, name/val %d + %d bytes\n",
+          infof(data, "oversized cookie dropped, name/val %zu + %zu bytes\n",
                 nlen, len);
           return NULL;
         }
@@ -585,13 +584,8 @@
            * TLD or otherwise "protected" suffix. To reduce risk, we require a
            * dot OR the exact host name being "localhost".
            */
-          {
-            const char *dotp;
-            /* check for more dots */
-            dotp = strchr(whatptr, '.');
-            if(!dotp && !strcasecompare("localhost", whatptr))
-              domain = ":";
-          }
+          if(bad_domain(whatptr))
+            domain = ":";
 #endif
 
           is_ip = isip(domain ? domain : whatptr);
@@ -723,9 +717,9 @@
       if(!queryp)
         endslash = strrchr(path, '/');
       else
-        endslash = memrchr(path, '/', (size_t)(queryp - path));
+        endslash = memrchr(path, '/', (queryp - path));
       if(endslash) {
-        size_t pathlen = (size_t)(endslash-path + 1); /* include end slash */
+        size_t pathlen = (endslash-path + 1); /* include end slash */
         co->path = malloc(pathlen + 1); /* one extra for the zero byte */
         if(co->path) {
           memcpy(co->path, path, pathlen);
@@ -880,9 +874,10 @@
   }
 
   co->livecookie = c->running;
+  co->creationtime = ++c->lastct;
 
   /* now, we have parsed the incoming line, we must now check if this
-     superceeds an already existing cookie, which it may if the previous have
+     supersedes an already existing cookie, which it may if the previous have
      the same domain and path as this */
 
   /* at first, remove expired cookies */
@@ -890,14 +885,21 @@
     remove_expired(c);
 
 #ifdef USE_LIBPSL
-  /* Check if the domain is a Public Suffix and if yes, ignore the cookie.
-     This needs a libpsl compiled with builtin data. */
+  /* Check if the domain is a Public Suffix and if yes, ignore the cookie. */
   if(domain && co->domain && !isip(co->domain)) {
-    psl = psl_builtin();
-    if(psl && !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
-      infof(data,
-            "cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n",
-            co->name, domain, co->domain);
+    const psl_ctx_t *psl = Curl_psl_use(data);
+    int acceptable;
+
+    if(psl) {
+      acceptable = psl_is_cookie_domain_acceptable(psl, domain, co->domain);
+      Curl_psl_release(data);
+    }
+    else
+      acceptable = !bad_domain(domain);
+
+    if(!acceptable) {
+      infof(data, "cookie '%s' dropped, domain '%s' must not "
+                  "set cookies for '%s'\n", co->name, domain, co->domain);
       freecookie(co);
       return NULL;
     }
@@ -951,6 +953,9 @@
       if(replace_old) {
         co->next = clist->next; /* get the next-pointer first */
 
+        /* when replacing, creationtime is kept from old */
+        co->creationtime = clist->creationtime;
+
         /* then free all the old pointers */
         free(clist->name);
         free(clist->value);
@@ -1140,12 +1145,24 @@
   if(l1 != l2)
     return (l2 > l1) ? 1 : -1 ;  /* avoid size_t <=> int conversions */
 
-  /* 3 - compare cookie names */
-  if(c1->name && c2->name)
-    return strcmp(c1->name, c2->name);
+  /* 3 - compare cookie name lengths */
+  l1 = c1->name ? strlen(c1->name) : 0;
+  l2 = c2->name ? strlen(c2->name) : 0;
 
-  /* sorry, can't be more deterministic */
-  return 0;
+  if(l1 != l2)
+    return (l2 > l1) ? 1 : -1;
+
+  /* 4 - compare cookie creation time */
+  return (c2->creationtime > c1->creationtime) ? 1 : -1;
+}
+
+/* sort cookies only according to creation time */
+static int cookie_sort_ct(const void *p1, const void *p2)
+{
+  struct Cookie *c1 = *(struct Cookie **)p1;
+  struct Cookie *c2 = *(struct Cookie **)p2;
+
+  return (c2->creationtime > c1->creationtime) ? 1 : -1;
 }
 
 #define CLONE(field)                     \
@@ -1174,6 +1191,7 @@
     d->secure = src->secure;
     d->livecookie = src->livecookie;
     d->httponly = src->httponly;
+    d->creationtime = src->creationtime;
   }
   return d;
 
@@ -1384,9 +1402,8 @@
  ****************************************************************************/
 void Curl_cookie_cleanup(struct CookieInfo *c)
 {
-  unsigned int i;
-
   if(c) {
+    unsigned int i;
     free(c->filename);
     for(i = 0; i < COOKIE_HASH_SIZE; i++)
       Curl_cookie_freelist(c->cookies[i]);
@@ -1439,6 +1456,8 @@
   bool use_stdout = FALSE;
   char *format_ptr;
   unsigned int i;
+  unsigned int j;
+  struct Cookie **array;
 
   if((NULL == c) || (0 == c->numcookies))
     /* If there are no known cookies, we don't write or even create any
@@ -1452,6 +1471,10 @@
   if(0 == c->numcookies)
     return 0;
 
+  array = malloc(sizeof(struct Cookie *) * c->numcookies);
+  if(!array)
+    return 1;
+
   if(!strcmp("-", dumphere)) {
     /* use stdout */
     out = stdout;
@@ -1459,8 +1482,10 @@
   }
   else {
     out = fopen(dumphere, FOPEN_WRITETEXT);
-    if(!out)
+    if(!out) {
+      free(array);
       return 1; /* failure */
+    }
   }
 
   fputs("# Netscape HTTP Cookie File\n"
@@ -1468,22 +1493,33 @@
         "# This file was generated by libcurl! Edit at your own risk.\n\n",
         out);
 
+  j = 0;
   for(i = 0; i < COOKIE_HASH_SIZE; i++) {
     for(co = c->cookies[i]; co; co = co->next) {
       if(!co->domain)
         continue;
-      format_ptr = get_netscape_format(co);
-      if(format_ptr == NULL) {
-        fprintf(out, "#\n# Fatal libcurl error\n");
-        if(!use_stdout)
-          fclose(out);
-        return 1;
-      }
-      fprintf(out, "%s\n", format_ptr);
-      free(format_ptr);
+      array[j++] = co;
     }
   }
 
+  qsort(array, c->numcookies, sizeof(struct Cookie *), cookie_sort_ct);
+
+  for(i = 0; i < j; i++) {
+    format_ptr = get_netscape_format(array[i]);
+    if(format_ptr == NULL) {
+      fprintf(out, "#\n# Fatal libcurl error\n");
+      if(!use_stdout) {
+        free(array);
+        fclose(out);
+      }
+      return 1;
+    }
+    fprintf(out, "%s\n", format_ptr);
+    free(format_ptr);
+  }
+
+  free(array);
+
   if(!use_stdout)
     fclose(out);
 
diff --git a/Utilities/cmcurl/lib/cookie.h b/Utilities/cmcurl/lib/cookie.h
index 79b5928..a9f90ca 100644
--- a/Utilities/cmcurl/lib/cookie.h
+++ b/Utilities/cmcurl/lib/cookie.h
@@ -34,7 +34,7 @@
   char *domain;      /* domain = <this> */
   curl_off_t expires;  /* expires = <this> */
   char *expirestr;   /* the plain text version */
-  bool tailmatch;    /* weather we do tail-matchning of the domain name */
+  bool tailmatch;    /* whether we do tail-matching of the domain name */
 
   /* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */
   char *version;     /* Version = <value> */
@@ -43,6 +43,7 @@
   bool secure;       /* whether the 'secure' keyword was used */
   bool livecookie;   /* updated from a server, not a stored file */
   bool httponly;     /* true if the httponly directive is present */
+  int creationtime;  /* time when the cookie was written */
 };
 
 #define COOKIE_HASH_SIZE 256
@@ -55,6 +56,7 @@
   bool running;    /* state info, for cookie adding information */
   long numcookies; /* number of cookies in the "jar" */
   bool newsession; /* new session, discard session cookies on load */
+  int lastct;      /* last creation-time used in the jar */
 };
 
 /* This is the maximum line length we accept for a cookie line. RFC 2109
diff --git a/Utilities/cmcurl/lib/curl_addrinfo.c b/Utilities/cmcurl/lib/curl_addrinfo.c
index 55d5a39..fd49679 100644
--- a/Utilities/cmcurl/lib/curl_addrinfo.c
+++ b/Utilities/cmcurl/lib/curl_addrinfo.c
@@ -536,7 +536,8 @@
 }
 #endif
 
-#if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO)
+#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) &&  \
+  defined(HAVE_FREEADDRINFO)
 /*
  * curl_dofreeaddrinfo()
  *
diff --git a/Utilities/cmcurl/lib/curl_config.h.cmake b/Utilities/cmcurl/lib/curl_config.h.cmake
index 24d1ca0..f67188e 100644
--- a/Utilities/cmcurl/lib/curl_config.h.cmake
+++ b/Utilities/cmcurl/lib/curl_config.h.cmake
@@ -226,6 +226,9 @@
 /* Define to 1 if you have the `getpwuid' function. */
 #cmakedefine HAVE_GETPWUID 1
 
+/* Define to 1 if you have the `getpwuid_r' function. */
+#cmakedefine HAVE_GETPWUID_R 1
+
 /* Define to 1 if you have the `getrlimit' function. */
 #cmakedefine HAVE_GETRLIMIT 1
 
@@ -876,6 +879,12 @@
 /* The size of `long', as computed by sizeof. */
 @SIZEOF_LONG_CODE@
 
+/* The size of `long long', as computed by sizeof. */
+@SIZEOF_LONG_LONG_CODE@
+
+/* The size of `__int64', as computed by sizeof. */
+@SIZEOF___INT64_CODE@
+
 /* The size of `off_t', as computed by sizeof. */
 @SIZEOF_OFF_T_CODE@
 
@@ -951,6 +960,9 @@
 /* to enable Windows SSL  */
 #cmakedefine USE_SCHANNEL 1
 
+/* enable multiple SSL backends */
+#cmakedefine CURL_WITH_MULTI_SSL 1
+
 /* Define to 1 if using yaSSL in OpenSSL compatibility mode. */
 #cmakedefine USE_YASSLEMUL 1
 
diff --git a/Utilities/cmcurl/lib/curl_fnmatch.c b/Utilities/cmcurl/lib/curl_fnmatch.c
index 0179a4f..fbfd85c 100644
--- a/Utilities/cmcurl/lib/curl_fnmatch.c
+++ b/Utilities/cmcurl/lib/curl_fnmatch.c
@@ -30,6 +30,17 @@
 /* The last #include file should be: */
 #include "memdebug.h"
 
+#ifndef HAVE_FNMATCH
+
+/*
+ * TODO:
+ *
+ * Make this function match POSIX. Test 1307 includes a set of test patterns
+ * that returns different results with a POSIX fnmatch() than with this
+ * implementation and this is considered a bug where POSIX is the guiding
+ * light.
+ */
+
 #define CURLFNM_CHARSET_LEN (sizeof(char) * 256)
 #define CURLFNM_CHSET_SIZE (CURLFNM_CHARSET_LEN + 15)
 
@@ -334,9 +345,9 @@
         s++;
         break;
       }
+      /* Syntax error in set; mismatch! */
+      return CURL_FNMATCH_NOMATCH;
 
-      /* Syntax error in set: this must be taken as a regular character. */
-      /* FALLTHROUGH */
     default:
       if(*p++ != *s++)
         return CURL_FNMATCH_NOMATCH;
@@ -355,5 +366,31 @@
   if(!pattern || !string) {
     return CURL_FNMATCH_FAIL;
   }
-  return loop((unsigned char *)pattern, (unsigned char *)string, 5);
+  return loop((unsigned char *)pattern, (unsigned char *)string, 2);
 }
+#else
+#include <fnmatch.h>
+/*
+ * @unittest: 1307
+ */
+int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
+{
+  int rc;
+  (void)ptr; /* the argument is specified by the curl_fnmatch_callback
+                prototype, but not used by Curl_fnmatch() */
+  if(!pattern || !string) {
+    return CURL_FNMATCH_FAIL;
+  }
+  rc = fnmatch(pattern, string, 0);
+  switch(rc) {
+  case 0:
+    return CURL_FNMATCH_MATCH;
+  case FNM_NOMATCH:
+    return CURL_FNMATCH_NOMATCH;
+  default:
+    return CURL_FNMATCH_FAIL;
+  }
+  /* not reached */
+}
+
+#endif
diff --git a/Utilities/cmcurl/lib/curl_ntlm_core.c b/Utilities/cmcurl/lib/curl_ntlm_core.c
index e27cab3..922e85a 100644
--- a/Utilities/cmcurl/lib/curl_ntlm_core.c
+++ b/Utilities/cmcurl/lib/curl_ntlm_core.c
@@ -557,8 +557,11 @@
                                    unsigned char *ntbuffer /* 21 bytes */)
 {
   size_t len = strlen(password);
-  unsigned char *pw = len ? malloc(len * 2) : strdup("");
+  unsigned char *pw;
   CURLcode result;
+  if(len > SIZE_T_MAX/2) /* avoid integer overflow */
+    return CURLE_OUT_OF_MEMORY;
+  pw = len ? malloc(len * 2) : strdup("");
   if(!pw)
     return CURLE_OUT_OF_MEMORY;
 
diff --git a/Utilities/cmcurl/lib/curl_sasl.c b/Utilities/cmcurl/lib/curl_sasl.c
index e54e487..354bc54 100644
--- a/Utilities/cmcurl/lib/curl_sasl.c
+++ b/Utilities/cmcurl/lib/curl_sasl.c
@@ -146,7 +146,6 @@
                                          const char *value, size_t len)
 {
   CURLcode result = CURLE_OK;
-  unsigned int mechbit;
   size_t mechlen;
 
   if(!len)
@@ -160,7 +159,7 @@
   if(!strncmp(value, "*", len))
     sasl->prefmech = SASL_AUTH_DEFAULT;
   else {
-    mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
+    unsigned int mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
     if(mechbit && mechlen == len)
       sasl->prefmech |= mechbit;
     else
diff --git a/Utilities/cmcurl/lib/curl_setup.h b/Utilities/cmcurl/lib/curl_setup.h
index 7e6fd5e..b056126 100644
--- a/Utilities/cmcurl/lib/curl_setup.h
+++ b/Utilities/cmcurl/lib/curl_setup.h
@@ -221,7 +221,7 @@
 
 /*
  * Use getaddrinfo to resolve the IPv4 address literal. If the current network
- * interface doesn’t support IPv4, but supports IPv6, NAT64, and DNS64,
+ * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
  * performing this task will result in a synthesized IPv6 address.
  */
 #ifdef  __APPLE__
@@ -246,6 +246,7 @@
 #  if defined(_UNICODE) && !defined(UNICODE)
 #    define UNICODE
 #  endif
+#  include <winerror.h>
 #  include <windows.h>
 #  ifdef HAVE_WINSOCK2_H
 #    include <winsock2.h>
@@ -815,4 +816,16 @@
 #define CURL_SA_FAMILY_T unsigned short
 #endif
 
+/* Some convenience macros to get the larger/smaller value out of two given.
+   We prefix with CURL to prevent name collisions. */
+#define CURLMAX(x,y) ((x)>(y)?(x):(y))
+#define CURLMIN(x,y) ((x)<(y)?(x):(y))
+
+/* Some versions of the Android SDK is missing the declaration */
+#if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING)
+struct passwd;
+int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
+               size_t buflen, struct passwd **result);
+#endif
+
 #endif /* HEADER_CURL_SETUP_H */
diff --git a/Utilities/cmcurl/lib/curl_threads.c b/Utilities/cmcurl/lib/curl_threads.c
index c1624a9..b8f0cd3 100644
--- a/Utilities/cmcurl/lib/curl_threads.c
+++ b/Utilities/cmcurl/lib/curl_threads.c
@@ -108,7 +108,8 @@
 #ifdef _WIN32_WCE
   t = CreateThread(NULL, 0, func, arg, 0, NULL);
 #else
-  t = (curl_thread_t)_beginthreadex(NULL, 0, func, arg, 0, NULL);
+  uintptr_t thread_handle = _beginthreadex(NULL, 0, func, arg, 0, NULL);
+  t = (curl_thread_t)thread_handle;
 #endif
   if((t == 0) || (t == LongToHandle(-1L))) {
 #ifdef _WIN32_WCE
diff --git a/Utilities/cmcurl/lib/dict.c b/Utilities/cmcurl/lib/dict.c
index 4fc8552..408d57b 100644
--- a/Utilities/cmcurl/lib/dict.c
+++ b/Utilities/cmcurl/lib/dict.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -95,17 +95,17 @@
 {
   char *newp = NULL;
   char *dictp;
-  char *ptr;
   size_t len;
-  char ch;
-  int olen = 0;
 
   CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len, FALSE);
   if(!newp || result)
     return NULL;
 
-  dictp = malloc(((size_t)len)*2 + 1); /* add one for terminating zero */
+  dictp = malloc(len*2 + 1); /* add one for terminating zero */
   if(dictp) {
+    char *ptr;
+    char ch;
+    int olen = 0;
     /* According to RFC2229 section 2.2, these letters need to be escaped with
        \[letter] */
     for(ptr = newp;
diff --git a/Utilities/cmcurl/lib/easy.c b/Utilities/cmcurl/lib/easy.c
index 6b91435..027d0be 100644
--- a/Utilities/cmcurl/lib/easy.c
+++ b/Utilities/cmcurl/lib/easy.c
@@ -113,7 +113,7 @@
   res = WSAStartup(wVersionRequested, &wsaData);
 
   if(res != 0)
-    /* Tell the user that we couldn't find a useable */
+    /* Tell the user that we couldn't find a usable */
     /* winsock.dll.     */
     return CURLE_FAILED_INIT;
 
@@ -125,7 +125,7 @@
 
   if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
      HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) {
-    /* Tell the user that we couldn't find a useable */
+    /* Tell the user that we couldn't find a usable */
 
     /* winsock.dll. */
     WSACleanup();
@@ -661,38 +661,27 @@
   bool done = FALSE;
   CURLMcode mcode = CURLM_OK;
   CURLcode result = CURLE_OK;
-  struct curltime before;
-  int without_fds = 0;  /* count number of consecutive returns from
-                           curl_multi_wait() without any filedescriptors */
 
   while(!done && !mcode) {
     int still_running = 0;
     int rc;
 
-    before = Curl_now();
     mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc);
 
     if(!mcode) {
       if(!rc) {
-        struct curltime after = Curl_now();
+        long sleep_ms;
 
         /* If it returns without any filedescriptor instantly, we need to
            avoid busy-looping during periods where it has nothing particular
            to wait for */
-        if(Curl_timediff(after, before) <= 10) {
-          without_fds++;
-          if(without_fds > 2) {
-            int sleep_ms = without_fds < 10 ? (1 << (without_fds - 1)) : 1000;
-            Curl_wait_ms(sleep_ms);
-          }
+        curl_multi_timeout(multi, &sleep_ms);
+        if(sleep_ms) {
+          if(sleep_ms > 1000)
+            sleep_ms = 1000;
+          Curl_wait_ms((int)sleep_ms);
         }
-        else
-          /* it wasn't "instant", restart counter */
-          without_fds = 0;
       }
-      else
-        /* got file descriptor, restart counter */
-        without_fds = 0;
 
       mcode = curl_multi_perform(multi, &still_running);
     }
@@ -969,6 +958,13 @@
     outcurl->change.referer_alloc = TRUE;
   }
 
+  /* Reinitialize an SSL engine for the new handle
+   * note: the engine name has already been copied by dupset */
+  if(outcurl->set.str[STRING_SSL_ENGINE]) {
+    if(Curl_ssl_set_engine(outcurl, outcurl->set.str[STRING_SSL_ENGINE]))
+      goto fail;
+  }
+
   /* Clone the resolver handle, if present, for the new handle */
   if(Curl_resolver_duphandle(&outcurl->state.resolver,
                              data->state.resolver))
diff --git a/Utilities/cmcurl/lib/escape.c b/Utilities/cmcurl/lib/escape.c
index b7e2d32..10774f0 100644
--- a/Utilities/cmcurl/lib/escape.c
+++ b/Utilities/cmcurl/lib/escape.c
@@ -82,7 +82,6 @@
   size_t alloc;
   char *ns;
   char *testing_ptr = NULL;
-  unsigned char in; /* we need to treat the characters unsigned */
   size_t newlen;
   size_t strindex = 0;
   size_t length;
@@ -100,7 +99,7 @@
 
   length = alloc-1;
   while(length--) {
-    in = *string;
+    unsigned char in = *string; /* we need to treat the characters unsigned */
 
     if(Curl_isunreserved(in))
       /* just copy this */
@@ -150,7 +149,6 @@
 {
   size_t alloc = (length?length:strlen(string)) + 1;
   char *ns = malloc(alloc);
-  unsigned char in;
   size_t strindex = 0;
   unsigned long hex;
   CURLcode result;
@@ -159,7 +157,7 @@
     return CURLE_OUT_OF_MEMORY;
 
   while(--alloc > 0) {
-    in = *string;
+    unsigned char in = *string;
     if(('%' == in) && (alloc > 2) &&
        ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
       /* this is two hexadecimal digits following a '%' */
diff --git a/Utilities/cmcurl/lib/file.c b/Utilities/cmcurl/lib/file.c
index db04cc2..e50e988 100644
--- a/Utilities/cmcurl/lib/file.c
+++ b/Utilities/cmcurl/lib/file.c
@@ -256,8 +256,6 @@
   CURLcode result = CURLE_OK;
   struct Curl_easy *data = conn->data;
   char *buf = data->state.buffer;
-  size_t nread;
-  size_t nwrite;
   curl_off_t bytecount = 0;
   struct_stat file_stat;
   const char *buf2;
@@ -306,7 +304,9 @@
   }
 
   while(!result) {
-    int readcount;
+    size_t nread;
+    size_t nwrite;
+    size_t readcount;
     result = Curl_fillreadbuffer(conn, (int)data->set.buffer_size, &readcount);
     if(result)
       break;
@@ -314,7 +314,7 @@
     if(readcount <= 0)  /* fix questionable compare error. curlvms */
       break;
 
-    nread = (size_t)readcount;
+    nread = readcount;
 
     /*skip bytes before resume point*/
     if(data->state.resume_from) {
@@ -378,7 +378,6 @@
   curl_off_t expected_size = 0;
   bool size_known;
   bool fstated = FALSE;
-  ssize_t nread;
   struct Curl_easy *data = conn->data;
   char *buf = data->state.buffer;
   curl_off_t bytecount = 0;
@@ -461,7 +460,7 @@
     return result;
 
   /* Adjust the start offset in case we want to get the N last bytes
-   * of the stream iff the filesize could be determined */
+   * of the stream if the filesize could be determined */
   if(data->state.resume_from < 0) {
     if(!fstated) {
       failf(data, "Can't get the size of file.");
@@ -502,6 +501,7 @@
   Curl_pgrsTime(data, TIMER_STARTTRANSFER);
 
   while(!result) {
+    ssize_t nread;
     /* Don't fill a whole buffer if we want less than all data */
     size_t bytestoread;
 
diff --git a/Utilities/cmcurl/lib/formdata.c b/Utilities/cmcurl/lib/formdata.c
index f912410..202d930 100644
--- a/Utilities/cmcurl/lib/formdata.c
+++ b/Utilities/cmcurl/lib/formdata.c
@@ -39,16 +39,13 @@
 #include "sendf.h"
 #include "strdup.h"
 #include "rand.h"
+#include "warnless.h"
 /* The last 3 #include files should be in this order */
 #include "curl_printf.h"
 #include "curl_memory.h"
 #include "memdebug.h"
 
 
-/* What kind of Content-Type to use on un-specified files with unrecognized
-   extensions. */
-#define HTTPPOST_CONTENTTYPE_DEFAULT "application/octet-stream"
-
 #define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME
 #define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME
 #define HTTPPOST_PTRCONTENTS CURL_HTTPPOST_PTRCONTENTS
@@ -305,7 +302,8 @@
        * Set the contents property.
        */
     case CURLFORM_PTRCONTENTS:
-      current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */
+      current_form->flags |= HTTPPOST_PTRCONTENTS;
+      /* FALLTHROUGH */
     case CURLFORM_COPYCONTENTS:
       if(current_form->value)
         return_value = CURL_FORMADD_OPTION_TWICE;
@@ -725,7 +723,7 @@
 
   while(!result) {
     char buffer[8192];
-    size_t nread = Curl_mime_read(buffer, 1, sizeof buffer, &toppart);
+    size_t nread = Curl_mime_read(buffer, 1, sizeof(buffer), &toppart);
 
     if(!nread)
       break;
@@ -812,7 +810,6 @@
 {
   CURLcode result = CURLE_OK;
   curl_mime *form = NULL;
-  curl_mime *multipart;
   curl_mimepart *part;
   struct curl_httppost *file;
 
@@ -831,7 +828,7 @@
   /* Process each top part. */
   for(; !result && post; post = post->next) {
     /* If we have more than a file here, create a mime subpart and fill it. */
-    multipart = form;
+    curl_mime *multipart = form;
     if(post->more) {
       part = curl_mime_addpart(form);
       if(!part)
@@ -883,7 +880,8 @@
                compatibility: use of "-" pseudo file name should be avoided. */
             result = curl_mime_data_cb(part, (curl_off_t) -1,
                                        (curl_read_callback) fread,
-                                       (curl_seek_callback) fseek,
+                                       CURLX_FUNCTION_CAST(curl_seek_callback,
+                                                           fseek),
                                        NULL, (void *) stdin);
           }
           else
diff --git a/Utilities/cmcurl/lib/ftp.c b/Utilities/cmcurl/lib/ftp.c
index a42c0c7..63f32cf 100644
--- a/Utilities/cmcurl/lib/ftp.c
+++ b/Utilities/cmcurl/lib/ftp.c
@@ -239,8 +239,8 @@
 
 static void freedirs(struct ftp_conn *ftpc)
 {
-  int i;
   if(ftpc->dirs) {
+    int i;
     for(i = 0; i < ftpc->dirdepth; i++) {
       free(ftpc->dirs[i]);
       ftpc->dirs[i] = NULL;
@@ -637,8 +637,6 @@
    * line in a response or continue reading.  */
 
   curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
-  time_t timeout;              /* timeout in milliseconds */
-  time_t interval_ms;
   struct Curl_easy *data = conn->data;
   CURLcode result = CURLE_OK;
   struct ftp_conn *ftpc = &conn->proto.ftpc;
@@ -657,7 +655,8 @@
 
   while(!*ftpcode && !result) {
     /* check and reset timeout value every lap */
-    timeout = Curl_pp_state_timeout(pp);
+    time_t timeout = Curl_pp_state_timeout(pp); /* timeout in milliseconds */
+    time_t interval_ms;
 
     if(timeout <= 0) {
       failf(data, "FTP response timeout");
@@ -1589,7 +1588,6 @@
   struct FTP *ftp = conn->data->req.protop;
   struct Curl_easy *data = conn->data;
   struct ftp_conn *ftpc = &conn->proto.ftpc;
-  int seekerr = CURL_SEEKFUNC_OK;
 
   if((data->state.resume_from && !sizechecked) ||
      ((data->state.resume_from > 0) && sizechecked)) {
@@ -1605,6 +1603,7 @@
     /* 3. pass file-size number of bytes in the source file */
     /* 4. lower the infilesize counter */
     /* => transfer as usual */
+    int seekerr = CURL_SEEKFUNC_OK;
 
     if(data->state.resume_from < 0) {
       /* Got no given size to start from, figure it out */
@@ -2782,7 +2781,6 @@
         char *ptr = &data->state.buffer[4];  /* start on the first letter */
         const size_t buf_size = data->set.buffer_size;
         char *dir;
-        char *store;
         bool entry_extracted = FALSE;
 
         dir = malloc(nread + 1);
@@ -2805,6 +2803,7 @@
 
         if('\"' == *ptr) {
           /* it started good */
+          char *store;
           ptr++;
           for(store = dir; *ptr;) {
             if('\"' == *ptr) {
@@ -3993,8 +3992,7 @@
       break;
 
     if(conn->data->set.verbose)
-      Curl_debug(conn->data, CURLINFO_HEADER_OUT,
-                 sptr, (size_t)bytes_written, conn);
+      Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, (size_t)bytes_written);
 
     if(bytes_written != (ssize_t)write_len) {
       write_len -= bytes_written;
@@ -4385,7 +4383,6 @@
 {
   struct Curl_easy *data = conn->data;
   char *type;
-  char command;
   struct FTP *ftp;
 
   conn->data->req.protop = ftp = malloc(sizeof(struct FTP));
@@ -4403,6 +4400,7 @@
     type = strstr(conn->host.rawalloc, ";type=");
 
   if(type) {
+    char command;
     *type = 0;                     /* it was in the middle of the hostname */
     command = Curl_raw_toupper(type[6]);
     conn->bits.type_set = TRUE;
diff --git a/Utilities/cmcurl/lib/getinfo.c b/Utilities/cmcurl/lib/getinfo.c
index d280eeb..14b4562 100644
--- a/Utilities/cmcurl/lib/getinfo.c
+++ b/Utilities/cmcurl/lib/getinfo.c
@@ -281,6 +281,28 @@
     *param_offt = (data->progress.flags & PGRS_UL_SIZE_KNOWN)?
       data->progress.size_ul:-1;
     break;
+  case CURLINFO_TOTAL_TIME_T:
+    *param_offt = data->progress.timespent;
+    break;
+  case CURLINFO_NAMELOOKUP_TIME_T:
+    *param_offt = data->progress.t_nslookup;
+    break;
+  case CURLINFO_CONNECT_TIME_T:
+    *param_offt = data->progress.t_connect;
+    break;
+  case CURLINFO_APPCONNECT_TIME_T:
+    *param_offt = data->progress.t_appconnect;
+    break;
+  case CURLINFO_PRETRANSFER_TIME_T:
+    *param_offt = data->progress.t_pretransfer;
+    break;
+  case CURLINFO_STARTTRANSFER_TIME_T:
+    *param_offt = data->progress.t_starttransfer;
+    break;
+  case CURLINFO_REDIRECT_TIME_T:
+    *param_offt = data->progress.t_redirect;
+    break;
+
   default:
     return CURLE_UNKNOWN_OPTION;
   }
diff --git a/Utilities/cmcurl/lib/gopher.c b/Utilities/cmcurl/lib/gopher.c
index b7c31b6..3ecee9b 100644
--- a/Utilities/cmcurl/lib/gopher.c
+++ b/Utilities/cmcurl/lib/gopher.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -89,22 +89,15 @@
   /* Create selector. Degenerate cases: / and /1 => convert to "" */
   if(strlen(path) <= 2) {
     sel = (char *)"";
-    len = (int)strlen(sel);
+    len = strlen(sel);
   }
   else {
     char *newp;
-    size_t j, i;
 
     /* Otherwise, drop / and the first character (i.e., item type) ... */
     newp = path;
     newp += 2;
 
-    /* ... then turn ? into TAB for search servers, Veronica, etc. ... */
-    j = strlen(newp);
-    for(i = 0; i<j; i++)
-      if(newp[i] == '?')
-        newp[i] = '\x09';
-
     /* ... and finally unescape */
     result = Curl_urldecode(data, newp, 0, &sel, &len, FALSE);
     if(result)
diff --git a/Utilities/cmcurl/lib/hash.c b/Utilities/cmcurl/lib/hash.c
index 15a128f..421d68f 100644
--- a/Utilities/cmcurl/lib/hash.c
+++ b/Utilities/cmcurl/lib/hash.c
@@ -60,8 +60,6 @@
                comp_function comparator,
                curl_hash_dtor dtor)
 {
-  int i;
-
   if(!slots || !hfunc || !comparator ||!dtor) {
     return 1; /* failure */
   }
@@ -74,6 +72,7 @@
 
   h->table = malloc(slots * sizeof(struct curl_llist));
   if(h->table) {
+    int i;
     for(i = 0; i < slots; ++i)
       Curl_llist_init(&h->table[i], (curl_llist_dtor) hash_element_dtor);
     return 0; /* fine */
@@ -140,11 +139,10 @@
 int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
 {
   struct curl_llist_element *le;
-  struct curl_hash_element  *he;
   struct curl_llist *l = FETCH_LIST(h, key, key_len);
 
   for(le = l->head; le; le = le->next) {
-    he = le->ptr;
+    struct curl_hash_element *he = le->ptr;
     if(h->comp_func(he->key, he->key_len, key, key_len)) {
       Curl_llist_remove(l, le, (void *) h);
       --h->size;
@@ -162,13 +160,12 @@
 Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
 {
   struct curl_llist_element *le;
-  struct curl_hash_element  *he;
   struct curl_llist *l;
 
   if(h) {
     l = FETCH_LIST(h, key, key_len);
     for(le = l->head; le; le = le->next) {
-      he = le->ptr;
+      struct curl_hash_element *he = le->ptr;
       if(h->comp_func(he->key, he->key_len, key, key_len)) {
         return he->ptr;
       }
@@ -291,7 +288,6 @@
 struct curl_hash_element *
 Curl_hash_next_element(struct curl_hash_iterator *iter)
 {
-  int i;
   struct curl_hash *h = iter->hash;
 
   /* Get the next element in the current list, if any */
@@ -300,6 +296,7 @@
 
   /* If we have reached the end of the list, find the next one */
   if(!iter->current_element) {
+    int i;
     for(i = iter->slot_index; i < h->slots; i++) {
       if(h->table[i].head) {
         iter->current_element = h->table[i].head;
diff --git a/Utilities/cmcurl/lib/hmac.c b/Utilities/cmcurl/lib/hmac.c
index dae9505..bf49ebe 100644
--- a/Utilities/cmcurl/lib/hmac.c
+++ b/Utilities/cmcurl/lib/hmac.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -58,7 +58,7 @@
   unsigned char b;
 
   /* Create HMAC context. */
-  i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize +
+  i = sizeof(*ctxt) + 2 * hashparams->hmac_ctxtsize +
     hashparams->hmac_resultlen;
   ctxt = malloc(i);
 
diff --git a/Utilities/cmcurl/lib/hostasyn.c b/Utilities/cmcurl/lib/hostasyn.c
index 7b6e856..e7b399e 100644
--- a/Utilities/cmcurl/lib/hostasyn.c
+++ b/Utilities/cmcurl/lib/hostasyn.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -131,7 +131,7 @@
   if(result)
     /* We're not allowed to return failure with memory left allocated
        in the connectdata struct, free those here */
-    Curl_disconnect(conn, FALSE); /* close the connection */
+    Curl_disconnect(conn->data, conn, TRUE); /* close the connection */
 
   return result;
 }
diff --git a/Utilities/cmcurl/lib/hostip.c b/Utilities/cmcurl/lib/hostip.c
index c2f9def..bc20f71 100644
--- a/Utilities/cmcurl/lib/hostip.c
+++ b/Utilities/cmcurl/lib/hostip.c
@@ -907,7 +907,9 @@
       char *entry_id;
       size_t entry_len;
       char address[64];
+#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
       char *addresses = NULL;
+#endif
       char *addr_begin;
       char *addr_end;
       char *port_ptr;
@@ -930,7 +932,9 @@
         goto err;
 
       port = (int)tmp_port;
+#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
       addresses = end_ptr + 1;
+#endif
 
       while(*end_ptr) {
         size_t alen;
@@ -1010,24 +1014,28 @@
       /* See if its already in our dns cache */
       dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1);
 
+      if(dns) {
+        infof(data, "RESOLVE %s:%d is - old addresses discarded!\n",
+                hostname, port);
+        /* delete old entry entry, there are two reasons for this
+         1. old entry may have different addresses.
+         2. even if entry with correct addresses is already in the cache,
+            but if it is close to expire, then by the time next http
+            request is made, it can get expired and pruned because old
+            entry is not necessarily marked as added by CURLOPT_RESOLVE. */
+
+        Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1);
+      }
       /* free the allocated entry_id again */
       free(entry_id);
 
-      if(!dns) {
-        /* if not in the cache already, put this host in the cache */
-        dns = Curl_cache_addr(data, head, hostname, port);
-        if(dns) {
-          dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */
-          /* release the returned reference; the cache itself will keep the
-           * entry alive: */
-          dns->inuse--;
-        }
-      }
-      else {
-        /* this is a duplicate, free it again */
-        infof(data, "RESOLVE %s:%d is already cached, %s not stored!\n",
-              hostname, port, addresses);
-        Curl_freeaddrinfo(head);
+      /* put this new host in the cache */
+      dns = Curl_cache_addr(data, head, hostname, port);
+      if(dns) {
+        dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */
+        /* release the returned reference; the cache itself will keep the
+         * entry alive: */
+            dns->inuse--;
       }
 
       if(data->share)
diff --git a/Utilities/cmcurl/lib/hostip6.c b/Utilities/cmcurl/lib/hostip6.c
index 7c9988f..3bf47b4 100644
--- a/Utilities/cmcurl/lib/hostip6.c
+++ b/Utilities/cmcurl/lib/hostip6.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -59,39 +59,6 @@
 #include "curl_memory.h"
 #include "memdebug.h"
 
-#if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO)
-/* These are strictly for memory tracing and are using the same style as the
- * family otherwise present in memdebug.c. I put these ones here since they
- * require a bunch of structs I didn't want to include in memdebug.c
- */
-
-/*
- * For CURLRES_ARS, this should be written using ares_gethostbyaddr()
- * (ignoring the fact c-ares doesn't return 'serv').
- */
-
-int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
-                       GETNAMEINFO_TYPE_ARG2 salen,
-                       char *host, GETNAMEINFO_TYPE_ARG46 hostlen,
-                       char *serv, GETNAMEINFO_TYPE_ARG46 servlen,
-                       GETNAMEINFO_TYPE_ARG7 flags,
-                       int line, const char *source)
-{
-  int res = (getnameinfo)(sa, salen,
-                          host, hostlen,
-                          serv, servlen,
-                          flags);
-  if(0 == res)
-    /* success */
-    curl_memlog("GETNAME %s:%d getnameinfo()\n",
-                source, line);
-  else
-    curl_memlog("GETNAME %s:%d getnameinfo() failed = %d\n",
-                source, line, res);
-  return res;
-}
-#endif /* defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) */
-
 /*
  * Curl_ipv6works() returns TRUE if IPv6 seems to work.
  */
diff --git a/Utilities/cmcurl/lib/http.c b/Utilities/cmcurl/lib/http.c
index ff1d681..e727ed8 100644
--- a/Utilities/cmcurl/lib/http.c
+++ b/Utilities/cmcurl/lib/http.c
@@ -158,18 +158,20 @@
   /* allocate the HTTP-specific struct for the Curl_easy, only to survive
      during this request */
   struct HTTP *http;
-  DEBUGASSERT(conn->data->req.protop == NULL);
+  struct Curl_easy *data = conn->data;
+  DEBUGASSERT(data->req.protop == NULL);
 
   http = calloc(1, sizeof(struct HTTP));
   if(!http)
     return CURLE_OUT_OF_MEMORY;
 
   Curl_mime_initpart(&http->form, conn->data);
-  conn->data->req.protop = http;
+  data->req.protop = http;
 
-  Curl_http2_setup_conn(conn);
-  Curl_http2_setup_req(conn->data);
-
+  if(!CONN_INUSE(conn))
+    /* if not alredy multi-using, setup connection details */
+    Curl_http2_setup_conn(conn);
+  Curl_http2_setup_req(data);
   return CURLE_OK;
 }
 
@@ -310,22 +312,49 @@
   return result;
 }
 
+/*
+ * http_output_bearer() sets up an Authorization: header
+ * for HTTP Bearer authentication.
+ *
+ * Returns CURLcode.
+ */
+static CURLcode http_output_bearer(struct connectdata *conn)
+{
+  char **userp;
+  CURLcode result = CURLE_OK;
+
+  userp = &conn->allocptr.userpwd;
+  free(*userp);
+  *userp = aprintf("Authorization: Bearer %s\r\n",
+                   conn->oauth_bearer);
+
+  if(!*userp) {
+    result = CURLE_OUT_OF_MEMORY;
+    goto fail;
+  }
+
+  fail:
+  return result;
+}
+
 /* pickoneauth() selects the most favourable authentication method from the
  * ones available and the ones we want.
  *
  * return TRUE if one was picked
  */
-static bool pickoneauth(struct auth *pick)
+static bool pickoneauth(struct auth *pick, unsigned long mask)
 {
   bool picked;
   /* only deal with authentication we want */
-  unsigned long avail = pick->avail & pick->want;
+  unsigned long avail = pick->avail & pick->want & mask;
   picked = TRUE;
 
   /* The order of these checks is highly relevant, as this will be the order
      of preference in case of the existence of multiple accepted types. */
   if(avail & CURLAUTH_NEGOTIATE)
     pick->picked = CURLAUTH_NEGOTIATE;
+  else if(avail & CURLAUTH_BEARER)
+    pick->picked = CURLAUTH_BEARER;
   else if(avail & CURLAUTH_DIGEST)
     pick->picked = CURLAUTH_DIGEST;
   else if(avail & CURLAUTH_NTLM)
@@ -479,6 +508,10 @@
   bool pickhost = FALSE;
   bool pickproxy = FALSE;
   CURLcode result = CURLE_OK;
+  unsigned long authmask = ~0ul;
+
+  if(!conn->oauth_bearer)
+    authmask &= (unsigned long)~CURLAUTH_BEARER;
 
   if(100 <= data->req.httpcode && 199 >= data->req.httpcode)
     /* this is a transient response code, ignore */
@@ -487,17 +520,18 @@
   if(data->state.authproblem)
     return data->set.http_fail_on_error?CURLE_HTTP_RETURNED_ERROR:CURLE_OK;
 
-  if(conn->bits.user_passwd &&
+  if((conn->bits.user_passwd || conn->oauth_bearer) &&
      ((data->req.httpcode == 401) ||
       (conn->bits.authneg && data->req.httpcode < 300))) {
-    pickhost = pickoneauth(&data->state.authhost);
+    pickhost = pickoneauth(&data->state.authhost, authmask);
     if(!pickhost)
       data->state.authproblem = TRUE;
   }
   if(conn->bits.proxy_user_passwd &&
      ((data->req.httpcode == 407) ||
       (conn->bits.authneg && data->req.httpcode < 300))) {
-    pickproxy = pickoneauth(&data->state.authproxy);
+    pickproxy = pickoneauth(&data->state.authproxy,
+                            authmask & ~CURLAUTH_BEARER);
     if(!pickproxy)
       data->state.authproblem = TRUE;
   }
@@ -628,6 +662,20 @@
        functions work that way */
     authstatus->done = TRUE;
   }
+  if(authstatus->picked == CURLAUTH_BEARER) {
+    /* Bearer */
+    if((!proxy && conn->oauth_bearer &&
+        !Curl_checkheaders(conn, "Authorization:"))) {
+      auth = "Bearer";
+      result = http_output_bearer(conn);
+      if(result)
+        return result;
+    }
+
+    /* NOTE: this function should set 'done' TRUE, as the other auth
+       functions work that way */
+    authstatus->done = TRUE;
+  }
 
   if(auth) {
     infof(data, "%s auth using %s with user '%s'\n",
@@ -674,7 +722,7 @@
   authproxy = &data->state.authproxy;
 
   if((conn->bits.httpproxy && conn->bits.proxy_user_passwd) ||
-     conn->bits.user_passwd)
+     conn->bits.user_passwd || conn->oauth_bearer)
     /* continue please */;
   else {
     authhost->done = TRUE;
@@ -883,6 +931,18 @@
               data->state.authproblem = TRUE;
             }
           }
+          else
+            if(checkprefix("Bearer", auth)) {
+              *availp |= CURLAUTH_BEARER;
+              authp->avail |= CURLAUTH_BEARER;
+              if(authp->picked == CURLAUTH_BEARER) {
+                /* We asked for Bearer authentication but got a 40X back
+                  anyway, which basically means our token isn't valid. */
+                authp->avail = CURLAUTH_NONE;
+                infof(data, "Authentication problem. Ignoring this.\n");
+                data->state.authproblem = TRUE;
+              }
+            }
 
     /* there may be multiple methods on one line, so keep reading */
     while(*auth && *auth != ',') /* read up to the next comma */
@@ -1063,7 +1123,8 @@
   CURLcode result;
   char *ptr;
   size_t size;
-  struct HTTP *http = conn->data->req.protop;
+  struct Curl_easy *data = conn->data;
+  struct HTTP *http = data->req.protop;
   size_t sendsize;
   curl_socket_t sockfd;
   size_t headersize;
@@ -1083,7 +1144,7 @@
 
   DEBUGASSERT(size > included_body_bytes);
 
-  result = Curl_convert_to_network(conn->data, ptr, headersize);
+  result = Curl_convert_to_network(data, ptr, headersize);
   /* Curl_convert_to_network calls failf if unsuccessful */
   if(result) {
     /* conversion failed, free memory and return to the caller */
@@ -1108,8 +1169,14 @@
        must copy the data to the uploadbuffer first, since that is the buffer
        we will be using if this send is retried later.
     */
-    memcpy(conn->data->state.uploadbuffer, ptr, sendsize);
-    ptr = conn->data->state.uploadbuffer;
+    result = Curl_get_upload_buffer(data);
+    if(result) {
+      /* malloc failed, free memory and return to the caller */
+      Curl_add_buffer_free(in);
+      return result;
+    }
+    memcpy(data->state.ulbuf, ptr, sendsize);
+    ptr = data->state.ulbuf;
   }
   else
     sendsize = size;
@@ -1126,14 +1193,14 @@
     size_t headlen = (size_t)amount>headersize ? headersize : (size_t)amount;
     size_t bodylen = amount - headlen;
 
-    if(conn->data->set.verbose) {
+    if(data->set.verbose) {
       /* this data _may_ contain binary stuff */
-      Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, headlen, conn);
+      Curl_debug(data, CURLINFO_HEADER_OUT, ptr, headlen);
       if(bodylen) {
         /* there was body data sent beyond the initial header part, pass that
            on to the debug callback too */
-        Curl_debug(conn->data, CURLINFO_DATA_OUT,
-                   ptr + headlen, bodylen, conn);
+        Curl_debug(data, CURLINFO_DATA_OUT,
+                   ptr + headlen, bodylen);
       }
     }
 
@@ -1157,14 +1224,14 @@
         ptr = in->buffer + amount;
 
         /* backup the currently set pointers */
-        http->backup.fread_func = conn->data->state.fread_func;
-        http->backup.fread_in = conn->data->state.in;
+        http->backup.fread_func = data->state.fread_func;
+        http->backup.fread_in = data->state.in;
         http->backup.postdata = http->postdata;
         http->backup.postsize = http->postsize;
 
         /* set the new pointers for the request-sending */
-        conn->data->state.fread_func = (curl_read_callback)readmoredata;
-        conn->data->state.in = (void *)conn;
+        data->state.fread_func = (curl_read_callback)readmoredata;
+        data->state.in = (void *)conn;
         http->postdata = ptr;
         http->postsize = (curl_off_t)size;
 
@@ -1223,7 +1290,6 @@
 CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
 {
   char *new_rb;
-  size_t new_size;
 
   if(~size < in->size_used) {
     /* If resulting used size of send buffer would wrap size_t, cleanup
@@ -1236,10 +1302,10 @@
 
   if(!in->buffer ||
      ((in->size_used + size) > (in->size_max - 1))) {
-
     /* If current buffer size isn't enough to hold the result, use a
        buffer size that doubles the required size. If this new size
        would wrap size_t, then just use the largest possible one */
+    size_t new_size;
 
     if((size > (size_t)-1 / 2) || (in->size_used > (size_t)-1 / 2) ||
        (~(size * 2) < (in->size_used * 2)))
@@ -1406,7 +1472,7 @@
   }
 
   snprintf(proxy_header,
-           sizeof proxy_header,
+           sizeof(proxy_header),
            "PROXY %s %s %s %li %li\r\n",
            tcp_version,
            conn->data->info.conn_local_ip,
@@ -1574,7 +1640,6 @@
                           Curl_send_buffer *req_buffer)
 {
   CURLcode result = CURLE_OK;
-  const char *ptr;
   data->state.expect100header = FALSE; /* default to false unless it is set
                                           to TRUE below */
   if(use_http_1_1plus(data, conn) &&
@@ -1582,7 +1647,7 @@
     /* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an
        Expect: 100-continue to the headers which actually speeds up post
        operations (as there is one packet coming back from the web server) */
-    ptr = Curl_checkheaders(conn, "Expect");
+    const char *ptr = Curl_checkheaders(conn, "Expect");
     if(ptr) {
       data->state.expect100header =
         Curl_compareheader(ptr, "Expect:", "100-continue");
@@ -1819,7 +1884,6 @@
   const char *httpstring;
   Curl_send_buffer *req_buffer;
   curl_off_t postsize = 0; /* curl_off_t to handle large file sizes */
-  int seekerr = CURL_SEEKFUNC_CANTSEEK;
 
   /* Always consider the DO phase done after this function call, even if there
      may be parts of the request that is not yet sent, since we can deal with
@@ -1863,6 +1927,7 @@
   }
 
   http = data->req.protop;
+  DEBUGASSERT(http);
 
   if(!data->state.this_is_a_follow) {
     /* Free to avoid leaking memory on multiple requests*/
@@ -2088,7 +2153,6 @@
     else {
       /* If the host begins with '[', we start searching for the port after
          the bracket has been closed */
-      int startsearch = 0;
       if(*cookiehost == '[') {
         char *closingbracket;
         /* since the 'cookiehost' is an allocated memory area that will be
@@ -2099,6 +2163,7 @@
           *closingbracket = 0;
       }
       else {
+        int startsearch = 0;
         char *colon = strchr(cookiehost + startsearch, ':');
         if(colon)
           *colon = 0; /* The host must not include an embedded port number */
@@ -2244,6 +2309,7 @@
 
       /* Now, let's read off the proper amount of bytes from the
          input. */
+      int seekerr = CURL_SEEKFUNC_CANTSEEK;
       if(conn->seek_func) {
         Curl_set_in_callback(data, true);
         seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
@@ -2828,6 +2894,8 @@
       data->req.exp100 = EXP100_SEND_DATA; /* already sent */
       Curl_expire_done(data, EXPIRE_100_TIMEOUT);
     }
+    else
+      data->req.writebytecount = http->writebytecount;
   }
 
   if((conn->httpversion == 20) && data->req.upload_chunky)
@@ -2838,17 +2906,32 @@
   return result;
 }
 
+typedef enum {
+  STATUS_UNKNOWN, /* not enough data to tell yet */
+  STATUS_DONE, /* a status line was read */
+  STATUS_BAD /* not a status line */
+} statusline;
+
+
+/* Check a string for a prefix. Check no more than 'len' bytes */
+static bool checkprefixmax(const char *prefix, const char *buffer, size_t len)
+{
+  size_t ch = CURLMIN(strlen(prefix), len);
+  return curl_strnequal(prefix, buffer, ch);
+}
+
 /*
  * checkhttpprefix()
  *
  * Returns TRUE if member of the list matches prefix of string
  */
-static bool
+static statusline
 checkhttpprefix(struct Curl_easy *data,
-                const char *s)
+                const char *s, size_t len)
 {
   struct curl_slist *head = data->set.http200aliases;
-  bool rc = FALSE;
+  statusline rc = STATUS_BAD;
+  statusline onmatch = len >= 5? STATUS_DONE : STATUS_UNKNOWN;
 #ifdef CURL_DOES_CONVERSIONS
   /* convert from the network encoding using a scratch area */
   char *scratch = strdup(s);
@@ -2865,15 +2948,15 @@
 #endif /* CURL_DOES_CONVERSIONS */
 
   while(head) {
-    if(checkprefix(head->data, s)) {
-      rc = TRUE;
+    if(checkprefixmax(head->data, s, len)) {
+      rc = onmatch;
       break;
     }
     head = head->next;
   }
 
-  if(!rc && (checkprefix("HTTP/", s)))
-    rc = TRUE;
+  if((rc != STATUS_DONE) && (checkprefixmax("HTTP/", s, len)))
+    rc = onmatch;
 
 #ifdef CURL_DOES_CONVERSIONS
   free(scratch);
@@ -2882,11 +2965,12 @@
 }
 
 #ifndef CURL_DISABLE_RTSP
-static bool
+static statusline
 checkrtspprefix(struct Curl_easy *data,
-                const char *s)
+                const char *s, size_t len)
 {
-  bool result = FALSE;
+  statusline result = STATUS_BAD;
+  statusline onmatch = len >= 5? STATUS_DONE : STATUS_UNKNOWN;
 
 #ifdef CURL_DOES_CONVERSIONS
   /* convert from the network encoding using a scratch area */
@@ -2899,30 +2983,31 @@
     /* Curl_convert_from_network calls failf if unsuccessful */
     result = FALSE; /* can't return CURLE_foobar so return FALSE */
   }
-  else
-    result = checkprefix("RTSP/", scratch)? TRUE: FALSE;
+  else if(checkprefixmax("RTSP/", scratch, len))
+    result = onmatch;
   free(scratch);
 #else
   (void)data; /* unused */
-  result = checkprefix("RTSP/", s)? TRUE: FALSE;
+  if(checkprefixmax("RTSP/", s, len))
+    result = onmatch;
 #endif /* CURL_DOES_CONVERSIONS */
 
   return result;
 }
 #endif /* CURL_DISABLE_RTSP */
 
-static bool
+static statusline
 checkprotoprefix(struct Curl_easy *data, struct connectdata *conn,
-                 const char *s)
+                 const char *s, size_t len)
 {
 #ifndef CURL_DISABLE_RTSP
   if(conn->handler->protocol & CURLPROTO_RTSP)
-    return checkrtspprefix(data, s);
+    return checkrtspprefix(data, s, len);
 #else
   (void)conn;
 #endif /* CURL_DISABLE_RTSP */
 
-  return checkhttpprefix(data, s);
+  return checkhttpprefix(data, s, len);
 }
 
 /*
@@ -2939,7 +3024,7 @@
     /* The reason to have a max limit for this is to avoid the risk of a bad
        server feeding libcurl with a never-ending header that will cause
        reallocs infinitely */
-    failf(data, "Rejected %zd bytes header (max is %d)!", newsize,
+    failf(data, "Rejected %zu bytes header (max is %d)!", newsize,
           CURL_MAX_HTTP_HEADER);
     return CURLE_OUT_OF_MEMORY;
   }
@@ -3036,12 +3121,15 @@
       if(result)
         return result;
 
-      if(!k->headerline && (k->hbuflen>5)) {
-        /* make a first check that this looks like a protocol header */
-        if(!checkprotoprefix(data, conn, data->state.headerbuff)) {
+      if(!k->headerline) {
+        /* check if this looks like a protocol header */
+        statusline st = checkprotoprefix(data, conn, data->state.headerbuff,
+                                         k->hbuflen);
+        if(st == STATUS_BAD) {
           /* this is not the beginning of a protocol first header line */
           k->header = FALSE;
           k->badheader = HEADER_ALLBAD;
+          streamclose(conn, "bad HTTP: No end-of-message indicator");
           break;
         }
       }
@@ -3070,8 +3158,10 @@
 
     if(!k->headerline) {
       /* the first read header */
-      if((k->hbuflen>5) &&
-         !checkprotoprefix(data, conn, data->state.headerbuff)) {
+      statusline st = checkprotoprefix(data, conn, data->state.headerbuff,
+                                       k->hbuflen);
+      if(st == STATUS_BAD) {
+        streamclose(conn, "bad HTTP: No end-of-message indicator");
         /* this is not the beginning of a protocol first header line */
         k->header = FALSE;
         if(*nread)
@@ -3354,7 +3444,7 @@
 
         if(data->set.verbose)
           Curl_debug(data, CURLINFO_HEADER_IN,
-                     k->str_start, headerlen, conn);
+                     k->str_start, headerlen);
         break;          /* exit header line loop */
       }
 
@@ -3440,7 +3530,7 @@
              compare header line against list of aliases
           */
           if(!nc) {
-            if(checkhttpprefix(data, k->p)) {
+            if(checkhttpprefix(data, k->p, k->hbuflen) == STATUS_DONE) {
               nc = 1;
               k->httpcode = 200;
               conn->httpversion = 10;
@@ -3487,21 +3577,18 @@
          * depending on how authentication is working.  Other codes
          * are definitely errors, so give up here.
          */
-        if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
+        if(data->state.resume_from && data->set.httpreq == HTTPREQ_GET &&
+             k->httpcode == 416) {
+          /* "Requested Range Not Satisfiable", just proceed and
+             pretend this is no error */
+          k->ignorebody = TRUE; /* Avoid appending error msg to good data. */
+        }
+        else if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
            ((k->httpcode != 401) || !conn->bits.user_passwd) &&
            ((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) {
-
-          if(data->state.resume_from &&
-             (data->set.httpreq == HTTPREQ_GET) &&
-             (k->httpcode == 416)) {
-            /* "Requested Range Not Satisfiable", just proceed and
-               pretend this is no error */
-          }
-          else {
-            /* serious error, go home! */
-            print_http_error(data);
-            return CURLE_HTTP_RETURNED_ERROR;
-          }
+          /* serious error, go home! */
+          print_http_error(data);
+          return CURLE_HTTP_RETURNED_ERROR;
         }
 
         if(conn->httpversion == 10) {
@@ -3812,8 +3899,7 @@
       writetype |= CLIENTWRITE_BODY;
 
     if(data->set.verbose)
-      Curl_debug(data, CURLINFO_HEADER_IN,
-                 k->p, (size_t)k->hbuflen, conn);
+      Curl_debug(data, CURLINFO_HEADER_IN, k->p, (size_t)k->hbuflen);
 
     result = Curl_client_write(conn, writetype, k->p, k->hbuflen);
     if(result)
diff --git a/Utilities/cmcurl/lib/http2.c b/Utilities/cmcurl/lib/http2.c
index da001df..d769193 100644
--- a/Utilities/cmcurl/lib/http2.c
+++ b/Utilities/cmcurl/lib/http2.c
@@ -42,7 +42,6 @@
 #include "memdebug.h"
 
 #define H2_BUFSIZE 32768
-#define MIN(x,y) ((x)<(y)?(x):(y))
 
 #if (NGHTTP2_VERSION_NUM < 0x010000)
 #error too old nghttp2 version, upgrade!
@@ -154,6 +153,11 @@
   }
 }
 
+/*
+ * Disconnects *a* connection used for HTTP/2. It might be an old one from the
+ * connection cache and not the "main" one. Don't touch the easy handle!
+ */
+
 static CURLcode http2_disconnect(struct connectdata *conn,
                                  bool dead_connection)
 {
@@ -164,8 +168,6 @@
 
   nghttp2_session_del(c->h2);
   Curl_safefree(c->inbuf);
-  http2_stream_free(conn->data->req.protop);
-  conn->data->state.drain = 0;
 
   H2BUGF(infof(conn->data, "HTTP/2 DISCONNECT done\n"));
 
@@ -345,7 +347,7 @@
     "INADEQUATE_SECURITY",  /* 0xC */
     "HTTP_1_1_REQUIRED"     /* 0xD */
   };
-  return (err < sizeof str / sizeof str[0]) ? str[err] : "unknown";
+  return (err < sizeof(str) / sizeof(str[0])) ? str[err] : "unknown";
 #else
   return nghttp2_http2_strerror(err);
 #endif
@@ -368,6 +370,10 @@
   (void)h2;
   (void)flags;
 
+  if(!c->send_underlying)
+    /* called before setup properly! */
+    return NGHTTP2_ERR_CALLBACK_FAILURE;
+
   written = ((Curl_send*)c->send_underlying)(conn, FIRSTSOCKET,
                                              data, length, &result);
 
@@ -441,6 +447,28 @@
   return NULL;
 }
 
+/*
+ * This specific transfer on this connection has been "drained".
+ */
+static void drained_transfer(struct Curl_easy *data,
+                             struct http_conn *httpc)
+{
+  DEBUGASSERT(httpc->drain_total >= data->state.drain);
+  httpc->drain_total -= data->state.drain;
+  data->state.drain = 0;
+}
+
+/*
+ * Mark this transfer to get "drained".
+ */
+static void drain_this(struct Curl_easy *data,
+                       struct http_conn *httpc)
+{
+  data->state.drain++;
+  httpc->drain_total++;
+  DEBUGASSERT(httpc->drain_total >= data->state.drain);
+}
+
 static struct Curl_easy *duphandle(struct Curl_easy *data)
 {
   struct Curl_easy *second = curl_easy_duphandle(data);
@@ -520,6 +548,7 @@
     if(rv) {
       /* denied, kill off the new handle again */
       http2_stream_free(newhandle->req.protop);
+      newhandle->req.protop = NULL;
       (void)Curl_close(newhandle);
       goto fail;
     }
@@ -535,14 +564,22 @@
     if(rc) {
       infof(data, "failed to add handle to multi\n");
       http2_stream_free(newhandle->req.protop);
+      newhandle->req.protop = NULL;
       Curl_close(newhandle);
       rv = 1;
       goto fail;
     }
 
     httpc = &conn->proto.httpc;
-    nghttp2_session_set_stream_user_data(httpc->h2,
-                                         frame->promised_stream_id, newhandle);
+    rv = nghttp2_session_set_stream_user_data(httpc->h2,
+                                              frame->promised_stream_id,
+                                              newhandle);
+    if(rv) {
+      infof(data, "failed to set user_data for stream %d\n",
+            frame->promised_stream_id);
+      DEBUGASSERT(0);
+      goto fail;
+    }
   }
   else {
     H2BUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n"));
@@ -581,7 +618,7 @@
       if(max_conn != httpc->settings.max_concurrent_streams) {
         /* only signal change if the value actually changed */
         infof(conn->data,
-              "Connection state changed (MAX_CONCURRENT_STREAMS == %d)!\n",
+              "Connection state changed (MAX_CONCURRENT_STREAMS == %u)!\n",
               httpc->settings.max_concurrent_streams);
         Curl_multi_connchanged(conn->data->multi);
       }
@@ -640,7 +677,7 @@
     Curl_add_buffer(stream->header_recvbuf, "\r\n", 2);
 
     left = stream->header_recvbuf->size_used - stream->nread_header_recvbuf;
-    ncopy = MIN(stream->len, left);
+    ncopy = CURLMIN(stream->len, left);
 
     memcpy(&stream->mem[stream->memlen],
            stream->header_recvbuf->buffer + stream->nread_header_recvbuf,
@@ -653,8 +690,7 @@
     stream->len -= ncopy;
     stream->memlen += ncopy;
 
-    data_s->state.drain++;
-    httpc->drain_total++;
+    drain_this(data_s, httpc);
     {
       /* get the pointer from userp again since it was re-assigned above */
       struct connectdata *conn_s = (struct connectdata *)userp;
@@ -683,25 +719,6 @@
   return 0;
 }
 
-static int on_invalid_frame_recv(nghttp2_session *session,
-                                 const nghttp2_frame *frame,
-                                 int lib_error_code, void *userp)
-{
-  struct Curl_easy *data_s = NULL;
-  (void)userp;
-#if !defined(DEBUG_HTTP2) || defined(CURL_DISABLE_VERBOSE_STRINGS)
-  (void)lib_error_code;
-#endif
-
-  data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
-  if(data_s) {
-    H2BUGF(infof(data_s,
-                 "on_invalid_frame_recv() was called, error=%d:%s\n",
-                 lib_error_code, nghttp2_strerror(lib_error_code)));
-  }
-  return 0;
-}
-
 static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
                               int32_t stream_id,
                               const uint8_t *data, size_t len, void *userp)
@@ -727,14 +744,13 @@
   if(!stream)
     return NGHTTP2_ERR_CALLBACK_FAILURE;
 
-  nread = MIN(stream->len, len);
+  nread = CURLMIN(stream->len, len);
   memcpy(&stream->mem[stream->memlen], data, nread);
 
   stream->len -= nread;
   stream->memlen += nread;
 
-  data_s->state.drain++;
-  conn->proto.httpc.drain_total++;
+  drain_this(data_s, &conn->proto.httpc);
 
   /* if we receive data for another handle, wake that up */
   if(conn->data != data_s)
@@ -768,58 +784,13 @@
   return 0;
 }
 
-static int before_frame_send(nghttp2_session *session,
-                             const nghttp2_frame *frame,
-                             void *userp)
-{
-  struct Curl_easy *data_s;
-  (void)userp;
-
-  data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
-  if(data_s) {
-    H2BUGF(infof(data_s, "before_frame_send() was called\n"));
-  }
-
-  return 0;
-}
-static int on_frame_send(nghttp2_session *session,
-                         const nghttp2_frame *frame,
-                         void *userp)
-{
-  struct Curl_easy *data_s;
-  (void)userp;
-
-  data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
-  if(data_s) {
-    H2BUGF(infof(data_s, "on_frame_send() was called, length = %zd\n",
-                 frame->hd.length));
-  }
-  return 0;
-}
-static int on_frame_not_send(nghttp2_session *session,
-                             const nghttp2_frame *frame,
-                             int lib_error_code, void *userp)
-{
-  struct Curl_easy *data_s;
-  (void)userp;
-#if !defined(DEBUG_HTTP2) || defined(CURL_DISABLE_VERBOSE_STRINGS)
-  (void)lib_error_code;
-#endif
-
-  data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
-  if(data_s) {
-    H2BUGF(infof(data_s,
-                 "on_frame_not_send() was called, lib_error_code = %d\n",
-                 lib_error_code));
-  }
-  return 0;
-}
 static int on_stream_close(nghttp2_session *session, int32_t stream_id,
                            uint32_t error_code, void *userp)
 {
   struct Curl_easy *data_s;
   struct HTTP *stream;
   struct connectdata *conn = (struct connectdata *)userp;
+  int rv;
   (void)session;
   (void)stream_id;
 
@@ -840,14 +811,19 @@
       return NGHTTP2_ERR_CALLBACK_FAILURE;
 
     stream->closed = TRUE;
-    data_s->state.drain++;
     httpc = &conn->proto.httpc;
-    httpc->drain_total++;
+    drain_this(data_s, httpc);
     httpc->error_code = error_code;
 
     /* remove the entry from the hash as the stream is now gone */
-    nghttp2_session_set_stream_user_data(session, stream_id, 0);
+    rv = nghttp2_session_set_stream_user_data(session, stream_id, 0);
+    if(rv) {
+      infof(data_s, "http/2: failed to clear user_data for stream %d!\n",
+            stream_id);
+      DEBUGASSERT(0);
+    }
     H2BUGF(infof(data_s, "Removed stream %u hash!\n", stream_id));
+    stream->stream_id = 0; /* cleared */
   }
   return 0;
 }
@@ -1052,7 +1028,7 @@
   else
     return NGHTTP2_ERR_INVALID_ARGUMENT;
 
-  nread = MIN(stream->upload_len, length);
+  nread = CURLMIN(stream->upload_len, length);
   if(nread > 0) {
     memcpy(buf, stream->upload_mem, nread);
     stream->upload_mem += nread;
@@ -1109,6 +1085,12 @@
   struct HTTP *http = data->req.protop;
   struct http_conn *httpc = &conn->proto.httpc;
 
+  if(!httpc->h2) /* not HTTP/2 ? */
+    return;
+
+  if(data->state.drain)
+    drained_transfer(data, httpc);
+
   if(http->header_recvbuf) {
     Curl_add_buffer_free(http->header_recvbuf);
     http->header_recvbuf = NULL; /* clear the pointer */
@@ -1126,15 +1108,24 @@
 
   if(premature) {
     /* RST_STREAM */
-    nghttp2_submit_rst_stream(httpc->h2, NGHTTP2_FLAG_NONE, http->stream_id,
-                              NGHTTP2_STREAM_CLOSED);
+    if(!nghttp2_submit_rst_stream(httpc->h2, NGHTTP2_FLAG_NONE,
+                                  http->stream_id, NGHTTP2_STREAM_CLOSED))
+      (void)nghttp2_session_send(httpc->h2);
+
     if(http->stream_id == httpc->pause_stream_id) {
       infof(data, "stopped the pause stream!\n");
       httpc->pause_stream_id = 0;
     }
   }
-  if(http->stream_id) {
-    nghttp2_session_set_stream_user_data(httpc->h2, http->stream_id, 0);
+  /* -1 means unassigned and 0 means cleared */
+  if(http->stream_id > 0) {
+    int rv = nghttp2_session_set_stream_user_data(httpc->h2,
+                                                  http->stream_id, 0);
+    if(rv) {
+      infof(data, "http/2: failed to clear user_data for stream %d!\n",
+            http->stream_id);
+      DEBUGASSERT(0);
+    }
     http->stream_id = 0;
   }
 }
@@ -1164,21 +1155,9 @@
     /* nghttp2_on_frame_recv_callback */
     nghttp2_session_callbacks_set_on_frame_recv_callback
       (callbacks, on_frame_recv);
-    /* nghttp2_on_invalid_frame_recv_callback */
-    nghttp2_session_callbacks_set_on_invalid_frame_recv_callback
-      (callbacks, on_invalid_frame_recv);
     /* nghttp2_on_data_chunk_recv_callback */
     nghttp2_session_callbacks_set_on_data_chunk_recv_callback
       (callbacks, on_data_chunk_recv);
-    /* nghttp2_before_frame_send_callback */
-    nghttp2_session_callbacks_set_before_frame_send_callback
-      (callbacks, before_frame_send);
-    /* nghttp2_on_frame_send_callback */
-    nghttp2_session_callbacks_set_on_frame_send_callback
-      (callbacks, on_frame_send);
-    /* nghttp2_on_frame_not_send_callback */
-    nghttp2_session_callbacks_set_on_frame_not_send_callback
-      (callbacks, on_frame_not_send);
     /* nghttp2_on_stream_close_callback */
     nghttp2_session_callbacks_set_on_stream_close_callback
       (callbacks, on_stream_close);
@@ -1280,7 +1259,7 @@
   if(rv < 0) {
     failf(data,
           "h2_process_pending_input: nghttp2_session_mem_recv() returned "
-          "%d:%s\n", rv, nghttp2_strerror((int)rv));
+          "%zd:%s\n", rv, nghttp2_strerror((int)rv));
     *err = CURLE_RECV_ERROR;
     return -1;
   }
@@ -1352,7 +1331,6 @@
   return result;
 }
 
-
 static ssize_t http2_handle_stream_close(struct connectdata *conn,
                                          struct Curl_easy *data,
                                          struct HTTP *stream, CURLcode *err)
@@ -1365,9 +1343,7 @@
     httpc->pause_stream_id = 0;
   }
 
-  DEBUGASSERT(httpc->drain_total >= data->state.drain);
-  httpc->drain_total -= data->state.drain;
-  data->state.drain = 0;
+  drained_transfer(data, httpc);
 
   if(httpc->pause_stream_id == 0) {
     if(h2_process_pending_input(conn, httpc, err) != 0) {
@@ -1388,7 +1364,7 @@
     return -1;
   }
   else if(httpc->error_code != NGHTTP2_NO_ERROR) {
-    failf(data, "HTTP/2 stream %u was not closed cleanly: %s (err %d)",
+    failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)",
           stream->stream_id, Curl_http2_strerror(httpc->error_code),
           httpc->error_code);
     *err = CURLE_HTTP2_STREAM;
@@ -1396,7 +1372,7 @@
   }
 
   if(!stream->bodystarted) {
-    failf(data, "HTTP/2 stream %u was closed cleanly, but before getting "
+    failf(data, "HTTP/2 stream %d was closed cleanly, but before getting "
           " all response header fields, treated as error",
           stream->stream_id);
     *err = CURLE_HTTP2_STREAM;
@@ -1510,7 +1486,7 @@
     /* If there is body data pending for this stream to return, do that */
     size_t left =
       stream->header_recvbuf->size_used - stream->nread_header_recvbuf;
-    size_t ncopy = MIN(len, left);
+    size_t ncopy = CURLMIN(len, left);
     memcpy(mem, stream->header_recvbuf->buffer + stream->nread_header_recvbuf,
            ncopy);
     stream->nread_header_recvbuf += ncopy;
@@ -1546,13 +1522,13 @@
   }
   else if(stream->pausedata) {
     DEBUGASSERT(httpc->pause_stream_id == stream->stream_id);
-    nread = MIN(len, stream->pauselen);
+    nread = CURLMIN(len, stream->pauselen);
     memcpy(mem, stream->pausedata, nread);
 
     stream->pausedata += nread;
     stream->pauselen -= nread;
 
-    infof(data, "%zu data bytes written\n", nread);
+    infof(data, "%zd data bytes written\n", nread);
     if(stream->pauselen == 0) {
       H2BUGF(infof(data, "Unpaused by stream %u\n", stream->stream_id));
       DEBUGASSERT(httpc->pause_stream_id == stream->stream_id);
@@ -1635,7 +1611,7 @@
     rv = nghttp2_session_mem_recv(httpc->h2, (const uint8_t *)inbuf, nread);
 
     if(nghttp2_is_fatal((int)rv)) {
-      failf(data, "nghttp2_session_mem_recv() returned %d:%s\n",
+      failf(data, "nghttp2_session_mem_recv() returned %zd:%s\n",
             rv, nghttp2_strerror((int)rv));
       *err = CURLE_RECV_ERROR;
       return -1;
@@ -1678,9 +1654,7 @@
                    stream->stream_id));
     }
     else if(!stream->closed) {
-      DEBUGASSERT(httpc->drain_total >= data->state.drain);
-      httpc->drain_total -= data->state.drain;
-      data->state.drain = 0; /* this stream is hereby drained */
+      drained_transfer(data, httpc);
     }
 
     return retlen;
@@ -2040,7 +2014,7 @@
   }
 
   infof(conn->data, "Using Stream ID: %x (easy handle %p)\n",
-        stream_id, conn->data);
+        stream_id, (void *)conn->data);
   stream->stream_id = stream_id;
 
   /* this does not call h2_session_send() since there can not have been any
@@ -2154,9 +2128,14 @@
       return CURLE_HTTP2;
     }
 
-    nghttp2_session_set_stream_user_data(httpc->h2,
-                                         stream->stream_id,
-                                         conn->data);
+    rv = nghttp2_session_set_stream_user_data(httpc->h2,
+                                              stream->stream_id,
+                                              data);
+    if(rv) {
+      infof(data, "http/2: failed to set user_data for stream %d!\n",
+            stream->stream_id);
+      DEBUGASSERT(0);
+    }
   }
   else {
     populate_settings(conn, httpc);
diff --git a/Utilities/cmcurl/lib/http2.h b/Utilities/cmcurl/lib/http2.h
index f597c80..21cd9b8 100644
--- a/Utilities/cmcurl/lib/http2.h
+++ b/Utilities/cmcurl/lib/http2.h
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -65,7 +65,7 @@
 #define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL
 #define Curl_http2_setup(x) CURLE_UNSUPPORTED_PROTOCOL
 #define Curl_http2_switched(x,y,z) CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_http2_setup_conn(x)
+#define Curl_http2_setup_conn(x) Curl_nop_stmt
 #define Curl_http2_setup_req(x)
 #define Curl_http2_init_state(x)
 #define Curl_http2_init_userset(x)
diff --git a/Utilities/cmcurl/lib/http_ntlm.c b/Utilities/cmcurl/lib/http_ntlm.c
index fd5540b..a9b33f9 100644
--- a/Utilities/cmcurl/lib/http_ntlm.c
+++ b/Utilities/cmcurl/lib/http_ntlm.c
@@ -228,7 +228,7 @@
     /* connection is already authenticated,
      * don't send a header in future requests */
     ntlm->state = NTLMSTATE_LAST;
-    /* fall-through */
+    /* FALLTHROUGH */
   case NTLMSTATE_LAST:
     Curl_safefree(*allocuserpwd);
     authp->done = TRUE;
diff --git a/Utilities/cmcurl/lib/http_proxy.c b/Utilities/cmcurl/lib/http_proxy.c
index e10a488..c8c445b 100644
--- a/Utilities/cmcurl/lib/http_proxy.c
+++ b/Utilities/cmcurl/lib/http_proxy.c
@@ -188,12 +188,10 @@
   struct SingleRequest *k = &data->req;
   CURLcode result;
   curl_socket_t tunnelsocket = conn->sock[sockindex];
-  timediff_t check;
   struct http_connect_state *s = conn->connect_state;
 
 #define SELECT_OK      0
 #define SELECT_ERROR   1
-#define SELECT_TIMEOUT 2
 
   if(Curl_connect_complete(conn))
     return CURLE_OK; /* CONNECT is already completed */
@@ -201,12 +199,13 @@
   conn->bits.proxy_connect_closed = FALSE;
 
   do {
+    timediff_t check;
     if(TUNNEL_INIT == s->tunnel_state) {
       /* BEGIN CONNECT PHASE */
       char *host_port;
       Curl_send_buffer *req_buffer;
 
-      infof(data, "Establish HTTP proxy tunnel to %s:%hu\n",
+      infof(data, "Establish HTTP proxy tunnel to %s:%d\n",
             hostname, remote_port);
 
         /* This only happens if we've looped here due to authentication
@@ -419,7 +418,7 @@
         /* output debug if that is requested */
         if(data->set.verbose)
           Curl_debug(data, CURLINFO_HEADER_IN,
-                     s->line_start, (size_t)s->perline, conn);
+                     s->line_start, (size_t)s->perline);
 
         if(!data->set.suppress_connect_headers) {
           /* send the header to the callback */
diff --git a/Utilities/cmcurl/lib/imap.c b/Utilities/cmcurl/lib/imap.c
index cf278a2..942fe7d 100644
--- a/Utilities/cmcurl/lib/imap.c
+++ b/Utilities/cmcurl/lib/imap.c
@@ -609,7 +609,6 @@
   CURLcode result = CURLE_OK;
   struct Curl_easy *data = conn->data;
   struct IMAP *imap = data->req.protop;
-  char *mailbox;
 
   if(imap->custom)
     /* Send the custom request */
@@ -617,7 +616,8 @@
                         imap->custom_params ? imap->custom_params : "");
   else {
     /* Make sure the mailbox is in the correct atom format if necessary */
-    mailbox = imap->mailbox ? imap_atom(imap->mailbox, true) : strdup("");
+    char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, true)
+                                  : strdup("");
     if(!mailbox)
       return CURLE_OUT_OF_MEMORY;
 
@@ -854,7 +854,6 @@
   struct Curl_easy *data = conn->data;
   struct imap_conn *imapc = &conn->proto.imapc;
   const char *line = data->state.buffer;
-  size_t wordlen;
 
   (void)instate; /* no use for this yet */
 
@@ -864,6 +863,7 @@
 
     /* Loop through the data line */
     for(;;) {
+      size_t wordlen;
       while(*line &&
             (*line == ' ' || *line == '\t' ||
               *line == '\r' || *line == '\n')) {
@@ -1046,12 +1046,12 @@
   struct IMAP *imap = conn->data->req.protop;
   struct imap_conn *imapc = &conn->proto.imapc;
   const char *line = data->state.buffer;
-  char tmp[20];
 
   (void)instate; /* no use for this yet */
 
   if(imapcode == '*') {
     /* See if this is an UIDVALIDITY response */
+    char tmp[20];
     if(sscanf(line + 2, "OK [UIDVALIDITY %19[0123456789]]", tmp) == 1) {
       Curl_safefree(imapc->mailbox_uidvalidity);
       imapc->mailbox_uidvalidity = strdup(tmp);
@@ -1119,7 +1119,7 @@
   }
 
   if(parsed) {
-    infof(data, "Found %" CURL_FORMAT_CURL_OFF_TU " bytes to download\n",
+    infof(data, "Found %" CURL_FORMAT_CURL_OFF_T " bytes to download\n",
           size);
     Curl_pgrsSetDownloadSize(data, size);
 
@@ -1144,10 +1144,8 @@
 
       data->req.bytecount += chunk;
 
-      infof(data, "Written %" CURL_FORMAT_CURL_OFF_TU
-            " bytes, %" CURL_FORMAT_CURL_OFF_TU
-            " bytes are left for transfer\n", (curl_off_t)chunk,
-            size - chunk);
+      infof(data, "Written %zu bytes, %" CURL_FORMAT_CURL_OFF_TU
+            " bytes are left for transfer\n", chunk, size - chunk);
 
       /* Have we used the entire cache or just part of it?*/
       if(pp->cache_size > chunk) {
diff --git a/Utilities/cmcurl/lib/inet_ntop.c b/Utilities/cmcurl/lib/inet_ntop.c
index fb91a50..ac5d2d4 100644
--- a/Utilities/cmcurl/lib/inet_ntop.c
+++ b/Utilities/cmcurl/lib/inet_ntop.c
@@ -49,7 +49,7 @@
  */
 static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
 {
-  char tmp[sizeof "255.255.255.255"];
+  char tmp[sizeof("255.255.255.255")];
   size_t len;
 
   DEBUGASSERT(size >= 16);
diff --git a/Utilities/cmcurl/lib/ldap.c b/Utilities/cmcurl/lib/ldap.c
index 89047bc..4d8f4fa 100644
--- a/Utilities/cmcurl/lib/ldap.c
+++ b/Utilities/cmcurl/lib/ldap.c
@@ -54,15 +54,6 @@
 # endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */
 #endif
 
-/* These are macros in both <wincrypt.h> (in above <winldap.h>) and typedefs
- * in BoringSSL's <openssl/x509.h>
- */
-#ifdef HAVE_BORINGSSL
-# undef X509_NAME
-# undef X509_CERT_PAIR
-# undef X509_EXTENSIONS
-#endif
-
 #include "urldata.h"
 #include <curl/curl.h>
 #include "sendf.h"
diff --git a/Utilities/cmcurl/lib/md5.c b/Utilities/cmcurl/lib/md5.c
index 3096602..b819d39 100644
--- a/Utilities/cmcurl/lib/md5.c
+++ b/Utilities/cmcurl/lib/md5.c
@@ -484,29 +484,35 @@
 
 #endif /* CRYPTO LIBS */
 
-/* Disable this picky gcc-8 compiler warning */
-#if defined(__GNUC__) && (__GNUC__ >= 8)
-#pragma GCC diagnostic ignored "-Wcast-function-type"
-#endif
-
 const HMAC_params Curl_HMAC_MD5[] = {
   {
-    (HMAC_hinit_func) MD5_Init,           /* Hash initialization function. */
-    (HMAC_hupdate_func) MD5_Update,       /* Hash update function. */
-    (HMAC_hfinal_func) MD5_Final,         /* Hash computation end function. */
-    sizeof(MD5_CTX),                      /* Size of hash context structure. */
-    64,                                   /* Maximum key length. */
-    16                                    /* Result size. */
+    /* Hash initialization function. */
+    CURLX_FUNCTION_CAST(HMAC_hinit_func, MD5_Init),
+    /* Hash update function. */
+    CURLX_FUNCTION_CAST(HMAC_hupdate_func, MD5_Update),
+    /* Hash computation end function. */
+    CURLX_FUNCTION_CAST(HMAC_hfinal_func, MD5_Final),
+    /* Size of hash context structure. */
+    sizeof(MD5_CTX),
+    /* Maximum key length. */
+    64,
+    /* Result size. */
+    16
   }
 };
 
 const MD5_params Curl_DIGEST_MD5[] = {
   {
-    (Curl_MD5_init_func) MD5_Init,      /* Digest initialization function */
-    (Curl_MD5_update_func) MD5_Update,  /* Digest update function */
-    (Curl_MD5_final_func) MD5_Final,    /* Digest computation end function */
-    sizeof(MD5_CTX),                    /* Size of digest context struct */
-    16                                  /* Result size */
+    /* Digest initialization function */
+    CURLX_FUNCTION_CAST(Curl_MD5_init_func, MD5_Init),
+    /* Digest update function */
+    CURLX_FUNCTION_CAST(Curl_MD5_update_func, MD5_Update),
+    /* Digest computation end function */
+    CURLX_FUNCTION_CAST(Curl_MD5_final_func, MD5_Final),
+    /* Size of digest context struct */
+    sizeof(MD5_CTX),
+    /* Result size */
+    16
   }
 };
 
@@ -527,7 +533,7 @@
   MD5_context *ctxt;
 
   /* Create MD5 context */
-  ctxt = malloc(sizeof *ctxt);
+  ctxt = malloc(sizeof(*ctxt));
 
   if(!ctxt)
     return ctxt;
diff --git a/Utilities/cmcurl/lib/memdebug.h b/Utilities/cmcurl/lib/memdebug.h
index 6fb8b68..233de65 100644
--- a/Utilities/cmcurl/lib/memdebug.h
+++ b/Utilities/cmcurl/lib/memdebug.h
@@ -8,7 +8,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -137,13 +137,6 @@
 #endif
 #endif /* HAVE_GETADDRINFO */
 
-#ifdef HAVE_GETNAMEINFO
-#undef getnameinfo
-#define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \
-  curl_dogetnameinfo(sa, salen, host, hostlen, serv, servlen, flags, \
-                     __LINE__, __FILE__)
-#endif /* HAVE_GETNAMEINFO */
-
 #ifdef HAVE_FREEADDRINFO
 #undef freeaddrinfo
 #define freeaddrinfo(data) \
diff --git a/Utilities/cmcurl/lib/mime.c b/Utilities/cmcurl/lib/mime.c
index 4c0d2eeb..ca492d1 100644
--- a/Utilities/cmcurl/lib/mime.c
+++ b/Utilities/cmcurl/lib/mime.c
@@ -505,9 +505,6 @@
   mime_encoder_state *st = &part->encstate;
   char *ptr = buffer;
   size_t cursize = 0;
-  int i;
-  size_t len;
-  size_t consumed;
   int softlinebreak;
   char buf[4];
 
@@ -516,9 +513,9 @@
      character constants that can be interpreted as non-ascii on some
      platforms. Preserve ASCII encoding on output too. */
   while(st->bufbeg < st->bufend) {
-    len = 1;
-    consumed = 1;
-    i = st->buf[st->bufbeg];
+    size_t len = 1;
+    size_t consumed = 1;
+    int i = st->buf[st->bufbeg];
     buf[0] = (char) i;
     buf[1] = aschex[(i >> 4) & 0xF];
     buf[2] = aschex[i & 0xF];
@@ -787,10 +784,10 @@
       st->bufbeg = 0;
       st->bufend = len;
     }
-    if(st->bufend >= sizeof st->buf)
+    if(st->bufend >= sizeof(st->buf))
       return cursize? cursize: READ_ERROR;    /* Buffer full. */
     sz = read_part_content(part, st->buf + st->bufend,
-                           sizeof st->buf - st->bufend);
+                           sizeof(st->buf) - st->bufend);
     switch(sz) {
     case 0:
       ateof = TRUE;
@@ -813,8 +810,6 @@
                             char *buffer, size_t bufsize)
 {
   size_t cursize = 0;
-  size_t sz;
-  struct curl_slist *hdr;
 #ifdef CURL_DOES_CONVERSIONS
   char *convbuf = buffer;
 #endif
@@ -822,8 +817,8 @@
   /* Readback from part. */
 
   while(bufsize) {
-    sz = 0;
-    hdr = (struct curl_slist *) part->state.ptr;
+    size_t sz = 0;
+    struct curl_slist *hdr = (struct curl_slist *) part->state.ptr;
     switch(part->state.state) {
     case MIMESTATE_BEGIN:
       mimesetstate(&part->state, part->flags & MIME_BODY_ONLY? MIMESTATE_BODY:
@@ -918,8 +913,6 @@
 {
   curl_mime *mime = (curl_mime *) instream;
   size_t cursize = 0;
-  size_t sz;
-  curl_mimepart *part;
 #ifdef CURL_DOES_CONVERSIONS
   char *convbuf = buffer;
 #endif
@@ -927,8 +920,8 @@
   (void) size;   /* Always 1. */
 
   while(nitems) {
-    sz = 0;
-    part = mime->state.ptr;
+    size_t sz = 0;
+    curl_mimepart *part = mime->state.ptr;
     switch(mime->state.state) {
     case MIMESTATE_BEGIN:
     case MIMESTATE_BODY:
@@ -1044,7 +1037,6 @@
   curl_mime *mime = (curl_mime *) instream;
   curl_mimepart *part;
   int result = CURL_SEEKFUNC_OK;
-  int res;
 
   if(whence != SEEK_SET || offset)
     return CURL_SEEKFUNC_CANTSEEK;    /* Only support full rewind. */
@@ -1053,7 +1045,7 @@
    return CURL_SEEKFUNC_OK;           /* Already rewound. */
 
   for(part = mime->firstpart; part; part = part->nextpart) {
-    res = mime_part_rewind(part);
+    int res = mime_part_rewind(part);
     if(res != CURL_SEEKFUNC_OK)
       result = res;
   }
@@ -1220,7 +1212,7 @@
 {
   curl_mime *mime;
 
-  mime = (curl_mime *) malloc(sizeof *mime);
+  mime = (curl_mime *) malloc(sizeof(*mime));
 
   if(mime) {
     mime->easy = easy;
@@ -1236,8 +1228,13 @@
     }
 
     memset(mime->boundary, '-', 24);
-    Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24,
-                  MIME_RAND_BOUNDARY_CHARS + 1);
+    if(Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24,
+                     MIME_RAND_BOUNDARY_CHARS + 1)) {
+      /* failed to get random separator, bail out */
+      free(mime->boundary);
+      free(mime);
+      return NULL;
+    }
     mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL);
   }
 
@@ -1247,7 +1244,7 @@
 /* Initialize a mime part. */
 void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
 {
-  memset((char *) part, 0, sizeof *part);
+  memset((char *) part, 0, sizeof(*part));
   part->easy = easy;
   mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
 }
@@ -1260,7 +1257,7 @@
   if(!mime)
     return NULL;
 
-  part = (curl_mimepart *) malloc(sizeof *part);
+  part = (curl_mimepart *) malloc(sizeof(*part));
 
   if(part) {
     Curl_mime_initpart(part, mime->easy);
@@ -1349,7 +1346,6 @@
 CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
 {
   CURLcode result = CURLE_OK;
-  char *base;
 
   if(!part)
     return CURLE_BAD_FUNCTION_ARGUMENT;
@@ -1357,6 +1353,7 @@
   cleanup_part_content(part);
 
   if(filename) {
+    char *base;
     struct_stat sbuf;
 
     if(stat(filename, &sbuf) || access(filename, R_OK))
@@ -1564,7 +1561,6 @@
 static curl_off_t multipart_size(curl_mime *mime)
 {
   curl_off_t size;
-  curl_off_t sz;
   size_t boundarysize;
   curl_mimepart *part;
 
@@ -1575,7 +1571,7 @@
   size = boundarysize;  /* Final boundary - CRLF after headers. */
 
   for(part = mime->firstpart; part; part = part->nextpart) {
-    sz = Curl_mime_size(part);
+    curl_off_t sz = Curl_mime_size(part);
 
     if(sz < 0)
       size = sz;
@@ -1643,8 +1639,6 @@
 
 const char *Curl_mime_contenttype(const char *filename)
 {
-  unsigned int i;
-
   /*
    * If no content type was specified, we scan through a few well-known
    * extensions and pick the first we match!
@@ -1669,8 +1663,9 @@
   if(filename) {
     size_t len1 = strlen(filename);
     const char *nameend = filename + len1;
+    unsigned int i;
 
-    for(i = 0; i < sizeof ctts / sizeof ctts[0]; i++) {
+    for(i = 0; i < sizeof(ctts) / sizeof(ctts[0]); i++) {
       size_t len2 = strlen(ctts[i].extension);
 
       if(len1 >= len2 && strcasecompare(nameend - len2, ctts[i].extension))
diff --git a/Utilities/cmcurl/lib/multi.c b/Utilities/cmcurl/lib/multi.c
index f852846..0caf943 100644
--- a/Utilities/cmcurl/lib/multi.c
+++ b/Utilities/cmcurl/lib/multi.c
@@ -31,6 +31,7 @@
 #include "progress.h"
 #include "easyif.h"
 #include "share.h"
+#include "psl.h"
 #include "multiif.h"
 #include "sendf.h"
 #include "timeval.h"
@@ -68,8 +69,8 @@
 #define GOOD_MULTI_HANDLE(x) \
   ((x) && (x)->type == CURL_MULTI_HANDLE)
 
-static void singlesocket(struct Curl_multi *multi,
-                         struct Curl_easy *data);
+static CURLMcode singlesocket(struct Curl_multi *multi,
+                              struct Curl_easy *data);
 static int update_timer(struct Curl_multi *multi);
 
 static CURLMcode add_next_timeout(struct curltime now,
@@ -106,6 +107,16 @@
 /* function pointer called once when switching TO a state */
 typedef void (*init_multistate_func)(struct Curl_easy *data);
 
+static void Curl_init_completed(struct Curl_easy *data)
+{
+  /* this is a completed transfer */
+
+  /* Important: reset the conn pointer so that we don't point to memory
+     that could be freed anytime */
+  data->easy_conn = NULL;
+  Curl_expire_clear(data); /* stop all timers */
+}
+
 /* always use this function to change state, to make debugging easier */
 static void mstate(struct Curl_easy *data, CURLMstate state
 #ifdef DEBUGBUILD
@@ -115,17 +126,25 @@
 {
   CURLMstate oldstate = data->mstate;
   static const init_multistate_func finit[CURLM_STATE_LAST] = {
-    NULL,
-    NULL,
+    NULL,              /* INIT */
+    NULL,              /* CONNECT_PEND */
     Curl_init_CONNECT, /* CONNECT */
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    Curl_connect_free /* DO */
-    /* the rest is NULL too */
+    NULL,              /* WAITRESOLVE */
+    NULL,              /* WAITCONNECT */
+    NULL,              /* WAITPROXYCONNECT */
+    NULL,              /* SENDPROTOCONNECT */
+    NULL,              /* PROTOCONNECT */
+    NULL,              /* WAITDO */
+    Curl_connect_free, /* DO */
+    NULL,              /* DOING */
+    NULL,              /* DO_MORE */
+    NULL,              /* DO_DONE */
+    NULL,              /* WAITPERFORM */
+    NULL,              /* PERFORM */
+    NULL,              /* TOOFAST */
+    NULL,              /* DONE */
+    Curl_init_completed, /* COMPLETED */
+    NULL               /* MSGSENT */
   };
 
 #if defined(DEBUGBUILD) && defined(CURL_DISABLE_VERBOSE_STRINGS)
@@ -409,6 +428,14 @@
   else
     data->state.conn_cache = &multi->conn_cache;
 
+#ifdef USE_LIBPSL
+  /* Do the same for PSL. */
+  if(data->share && (data->share->specifier & (1 << CURL_LOCK_DATA_PSL)))
+    data->psl = &data->share->psl;
+  else
+    data->psl = &multi->psl;
+#endif
+
   /* This adds the new entry at the 'end' of the doubly-linked circular
      list of Curl_easy structs to try and maintain a FIFO queue so
      the pipelined requests are in order. */
@@ -449,7 +476,7 @@
      happens if the lastcall time is set to the same time when the handle is
      removed as when the next handle is added, as then the check in
      update_timer() that prevents calling the application multiple times with
-     the same timer infor will not trigger and then the new handle's timeout
+     the same timer info will not trigger and then the new handle's timeout
      will not be notified to the app.
 
      The work-around is thus simply to clear the 'lastcall' variable to force
@@ -506,6 +533,11 @@
     /* Stop if multi_done() has already been called */
     return CURLE_OK;
 
+  if(data->mstate == CURLM_STATE_WAITRESOLVE) {
+    /* still waiting for the resolve to complete */
+    (void)Curl_resolver_wait_resolv(conn, NULL);
+  }
+
   Curl_getoff_all_pipelines(data, conn);
 
   /* Cleanup possible redirect junk */
@@ -546,7 +578,7 @@
   if(conn->send_pipe.size || conn->recv_pipe.size) {
     /* Stop if pipeline is not empty . */
     data->easy_conn = NULL;
-    DEBUGF(infof(data, "Connection still in use %d/%d, "
+    DEBUGF(infof(data, "Connection still in use %zu/%zu, "
                  "no more multi_done now!\n",
                  conn->send_pipe.size, conn->recv_pipe.size));
     return CURLE_OK;
@@ -560,6 +592,7 @@
     conn->dns_entry = NULL;
   }
   Curl_hostcache_prune(data);
+  Curl_safefree(data->state.ulbuf);
 
   /* if the transfer was completed in a paused state there can be buffered
      data left to free */
@@ -590,7 +623,7 @@
 #endif
      ) || conn->bits.close
        || (premature && !(conn->handler->flags & PROTOPT_STREAM))) {
-    CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */
+    CURLcode res2 = Curl_disconnect(data, conn, premature);
 
     /* If we had an error already, make sure we return that one. But
        if we got a new error, return that. */
@@ -608,7 +641,7 @@
              conn->bits.conn_to_host ? conn->conn_to_host.dispname :
              conn->host.dispname);
 
-    /* the connection is no longer in use */
+    /* the connection is no longer in use by this transfer */
     if(Curl_conncache_return_conn(conn)) {
       /* remember the most recently used connection */
       data->state.lastconnect = conn;
@@ -698,6 +731,11 @@
       Curl_getoff_all_pipelines(data, data->easy_conn);
   }
 
+  if(data->connect_queue.ptr)
+    /* the handle was in the pending list waiting for an available connection,
+       so go ahead and remove it */
+    Curl_llist_remove(&multi->pending, &data->connect_queue, NULL);
+
   if(data->dns.hostcachetype == HCACHE_MULTI) {
     /* stop using the multi handle's DNS cache, *after* the possible
        multi_done() call above */
@@ -727,6 +765,12 @@
     data->easy_conn = NULL;
   }
 
+#ifdef USE_LIBPSL
+  /* Remove the PSL association. */
+  if(data->psl == &multi->psl)
+    data->psl = NULL;
+#endif
+
   data->multi = NULL; /* clear the association to this multi handle */
 
   /* make sure there's no pending message in the queue sent from this easy
@@ -831,12 +875,10 @@
                                                   of sockets */
                          int numsocks)
 {
-  /* If the pipe broke, or if there's no connection left for this easy handle,
-     then we MUST bail out now with no bitmask set. The no connection case can
-     happen when this is called from curl_multi_remove_handle() =>
-     singlesocket() => multi_getsock().
+  /* The no connection case can happen when this is called from
+     curl_multi_remove_handle() => singlesocket() => multi_getsock().
   */
-  if(data->state.pipe_broke || !data->easy_conn)
+  if(!data->easy_conn)
     return 0;
 
   if(data->mstate > CURLM_STATE_CONNECT &&
@@ -902,7 +944,6 @@
   struct Curl_easy *data;
   int this_max_fd = -1;
   curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
-  int bitmap;
   int i;
   (void)exc_fd_set; /* not used */
 
@@ -914,7 +955,7 @@
 
   data = multi->easyp;
   while(data) {
-    bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
+    int bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
 
     for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
       curl_socket_t s = CURL_SOCKET_BAD;
@@ -1068,8 +1109,6 @@
     int pollrc;
     /* wait... */
     pollrc = Curl_poll(ufds, nfds, timeout_ms);
-    DEBUGF(infof(data, "Curl_poll(%d ds, %d ms) == %d\n",
-                 nfds, timeout_ms, pollrc));
 
     if(pollrc > 0) {
       retcode = pollrc;
@@ -1312,24 +1351,6 @@
     bool stream_error = FALSE;
     rc = CURLM_OK;
 
-    /* Handle the case when the pipe breaks, i.e., the connection
-       we're using gets cleaned up and we're left with nothing. */
-    if(data->state.pipe_broke) {
-      infof(data, "Pipe broke: handle %p, url = %s\n",
-            (void *)data, data->state.path);
-
-      if(data->mstate < CURLM_STATE_COMPLETED) {
-        /* Head back to the CONNECT state */
-        multistate(data, CURLM_STATE_CONNECT);
-        rc = CURLM_CALL_MULTI_PERFORM;
-        result = CURLE_OK;
-      }
-
-      data->state.pipe_broke = FALSE;
-      data->easy_conn = NULL;
-      continue;
-    }
-
     if(!data->easy_conn &&
        data->mstate > CURLM_STATE_CONNECT &&
        data->mstate < CURLM_STATE_DONE) {
@@ -1555,6 +1576,8 @@
           multistate(data, CURLM_STATE_SENDPROTOCONNECT);
         }
       }
+      else if(result)
+        stream_error = TRUE;
       break;
 #endif
 
@@ -1909,6 +1932,8 @@
         CURLcode ret = Curl_retry_request(data->easy_conn, &newurl);
         if(!ret)
           retry = (newurl)?TRUE:FALSE;
+        else if(!result)
+          result = ret;
 
         if(retry) {
           /* if we are to retry, set the result to OK and consider the
@@ -2040,16 +2065,6 @@
       break;
 
     case CURLM_STATE_COMPLETED:
-      /* this is a completed transfer, it is likely to still be connected */
-
-      /* This node should be delinked from the list now and we should post
-         an information message that we are complete. */
-
-      /* Important: reset the conn pointer so that we don't point to memory
-         that could be freed anytime */
-      data->easy_conn = NULL;
-
-      Curl_expire_clear(data); /* stop all timers */
       break;
 
     case CURLM_STATE_MSGSENT:
@@ -2071,8 +2086,6 @@
         /* NOTE: no attempt to disconnect connections must be made
            in the case blocks above - cleanup happens only here */
 
-        data->state.pipe_broke = FALSE;
-
         /* Check if we can move pending requests to send pipe */
         process_pending_handles(multi); /* connection */
 
@@ -2087,7 +2100,7 @@
             /* Don't attempt to send data over a connection that timed out */
             bool dead_connection = result == CURLE_OPERATION_TIMEDOUT;
             /* disconnect properly */
-            Curl_disconnect(data->easy_conn, dead_connection);
+            Curl_disconnect(data, data->easy_conn, dead_connection);
 
             /* This is where we make sure that the easy_conn pointer is reset.
                We don't have to do this in every case block above where a
@@ -2101,6 +2114,7 @@
         }
 
         multistate(data, CURLM_STATE_COMPLETED);
+        rc = CURLM_CALL_MULTI_PERFORM;
       }
       /* if there's still a connection to use, call the progress function */
       else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) {
@@ -2125,14 +2139,12 @@
       msg->extmsg.data.result = result;
 
       rc = multi_addmsg(multi, msg);
-
+      DEBUGASSERT(!data->easy_conn);
       multistate(data, CURLM_STATE_MSGSENT);
     }
   } while((rc == CURLM_CALL_MULTI_PERFORM) || multi_ischanged(multi, FALSE));
 
   data->result = result;
-
-
   return rc;
 }
 
@@ -2220,6 +2232,11 @@
       data->state.conn_cache = NULL;
       data->multi = NULL; /* clear the association */
 
+#ifdef USE_LIBPSL
+      if(data->psl == &multi->psl)
+        data->psl = NULL;
+#endif
+
       data = nextdata;
     }
 
@@ -2232,6 +2249,7 @@
     Curl_llist_destroy(&multi->pending, NULL);
 
     Curl_hash_destroy(&multi->hostcache);
+    Curl_psl_destroy(&multi->psl);
 
     /* Free the blacklists by setting them to NULL */
     Curl_pipeline_set_site_blacklist(NULL, &multi->pipelining_site_bl);
@@ -2286,8 +2304,8 @@
  * and if we have a different state in any of those sockets from last time we
  * call the callback accordingly.
  */
-static void singlesocket(struct Curl_multi *multi,
-                         struct Curl_easy *data)
+static CURLMcode singlesocket(struct Curl_multi *multi,
+                              struct Curl_easy *data)
 {
   curl_socket_t socks[MAX_SOCKSPEREASYHANDLE];
   int i;
@@ -2334,7 +2352,7 @@
       entry = sh_addentry(&multi->sockhash, s, data);
       if(!entry)
         /* fatal */
-        return;
+        return CURLM_OUT_OF_MEMORY;
     }
 
     /* we know (entry != NULL) at this point, see the logic above */
@@ -2422,6 +2440,7 @@
 
   memcpy(data->sockets, socks, num*sizeof(curl_socket_t));
   data->numsocks = num;
+  return CURLM_OK;
 }
 
 void Curl_updatesocket(struct Curl_easy *data)
@@ -2442,20 +2461,23 @@
 
 void Curl_multi_closed(struct connectdata *conn, curl_socket_t s)
 {
-  struct Curl_multi *multi = conn->data->multi;
-  if(multi) {
-    /* this is set if this connection is part of a handle that is added to
-       a multi handle, and only then this is necessary */
-    struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s);
+  if(conn->data) {
+    /* if there's still an easy handle associated with this connection */
+    struct Curl_multi *multi = conn->data->multi;
+    if(multi) {
+      /* this is set if this connection is part of a handle that is added to
+         a multi handle, and only then this is necessary */
+      struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s);
 
-    if(entry) {
-      if(multi->socket_cb)
-        multi->socket_cb(conn->data, s, CURL_POLL_REMOVE,
-                         multi->socket_userp,
-                         entry->socketp);
+      if(entry) {
+        if(multi->socket_cb)
+          multi->socket_cb(conn->data, s, CURL_POLL_REMOVE,
+                           multi->socket_userp,
+                           entry->socketp);
 
-      /* now remove it from the socket hash */
-      sh_delentry(&multi->sockhash, s);
+        /* now remove it from the socket hash */
+        sh_delentry(&multi->sockhash, s);
+      }
     }
   }
 }
@@ -2535,8 +2557,8 @@
        and callbacks */
     if(result != CURLM_BAD_HANDLE) {
       data = multi->easyp;
-      while(data) {
-        singlesocket(multi, data);
+      while(data && !result) {
+        result = singlesocket(multi, data);
         data = data->next;
       }
     }
@@ -2590,10 +2612,13 @@
         /* clear the bitmask only if not locked */
         data->easy_conn->cselect_bits = 0;
 
-      if(CURLM_OK >= result)
+      if(CURLM_OK >= result) {
         /* get the socket(s) and check if the state has been changed since
            last */
-        singlesocket(multi, data);
+        result = singlesocket(multi, data);
+        if(result)
+          return result;
+      }
 
       /* Now we fall-through and do the timer-based stuff, since we don't want
          to force the user to have to deal with timeouts as long as at least
@@ -2627,10 +2652,13 @@
       result = multi_runsingle(multi, now, data);
       sigpipe_restore(&pipe_st);
 
-      if(CURLM_OK >= result)
+      if(CURLM_OK >= result) {
         /* get the socket(s) and check if the state has been changed since
            last */
-        singlesocket(multi, data);
+        result = singlesocket(multi, data);
+        if(result)
+          return result;
+      }
     }
 
     /* Check if there's one (more) expired timer to deal with! This function
@@ -2924,7 +2952,6 @@
 {
   struct Curl_multi *multi = data->multi;
   struct curltime *nowp = &data->state.expiretime;
-  int rc;
   struct curltime set;
 
   /* this is only interesting while there is still an associated multi struct
@@ -2955,6 +2982,7 @@
        Compare if the new time is earlier, and only remove-old/add-new if it
        is. */
     timediff_t diff = Curl_timediff(set, *nowp);
+    int rc;
 
     if(diff > 0) {
       /* The current splay tree entry is sooner than this new expiry time.
@@ -3000,7 +3028,6 @@
 {
   struct Curl_multi *multi = data->multi;
   struct curltime *nowp = &data->state.expiretime;
-  int rc;
 
   /* this is only interesting while there is still an associated multi struct
      remaining! */
@@ -3011,6 +3038,7 @@
     /* Since this is an cleared time, we must remove the previous entry from
        the splay tree */
     struct curl_llist *list = &data->state.timeoutlist;
+    int rc;
 
     rc = Curl_splayremovebyaddr(multi->timetree,
                                 &data->state.timenode,
@@ -3100,12 +3128,15 @@
   }
 }
 
-void Curl_set_in_callback(struct Curl_easy *easy, bool value)
+void Curl_set_in_callback(struct Curl_easy *data, bool value)
 {
-  if(easy->multi_easy)
-    easy->multi_easy->in_callback = value;
-  else if(easy->multi)
-      easy->multi->in_callback = value;
+  /* might get called when there is no data pointer! */
+  if(data) {
+    if(data->multi_easy)
+      data->multi_easy->in_callback = value;
+    else if(data->multi)
+      data->multi->in_callback = value;
+  }
 }
 
 bool Curl_is_in_callback(struct Curl_easy *easy)
diff --git a/Utilities/cmcurl/lib/multihandle.h b/Utilities/cmcurl/lib/multihandle.h
index 1a5017f..ea2bf35 100644
--- a/Utilities/cmcurl/lib/multihandle.h
+++ b/Utilities/cmcurl/lib/multihandle.h
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -23,6 +23,7 @@
  ***************************************************************************/
 
 #include "conncache.h"
+#include "psl.h"
 
 struct Curl_message {
   struct curl_llist_element list;
@@ -97,6 +98,11 @@
   /* Hostname cache */
   struct curl_hash hostcache;
 
+#ifdef USE_LIBPSL
+  /* PSL cache. */
+  struct PslCache psl;
+#endif
+
   /* timetree points to the splay-tree of time nodes to figure out expire
      times of all currently set timers */
   struct Curl_tree *timetree;
diff --git a/Utilities/cmcurl/lib/netrc.c b/Utilities/cmcurl/lib/netrc.c
index dbcc59a..a407bda 100644
--- a/Utilities/cmcurl/lib/netrc.c
+++ b/Utilities/cmcurl/lib/netrc.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -115,7 +115,7 @@
     char *tok;
     char *tok_buf;
     bool done = FALSE;
-    char netrcbuffer[256];
+    char netrcbuffer[4096];
     int  netrcbuffsize = (int)sizeof(netrcbuffer);
 
     while(!done && fgets(netrcbuffer, netrcbuffsize, file)) {
diff --git a/Utilities/cmcurl/lib/pingpong.c b/Utilities/cmcurl/lib/pingpong.c
index ad370ee..2e93d20 100644
--- a/Utilities/cmcurl/lib/pingpong.c
+++ b/Utilities/cmcurl/lib/pingpong.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -49,7 +49,6 @@
   struct connectdata *conn = pp->conn;
   struct Curl_easy *data = conn->data;
   time_t timeout_ms; /* in milliseconds */
-  time_t timeout2_ms; /* in milliseconds */
   long response_time = (data->set.server_response_timeout)?
     data->set.server_response_timeout: pp->response_time;
 
@@ -65,7 +64,7 @@
 
   if(data->set.timeout) {
     /* if timeout is requested, find out how much remaining time we have */
-    timeout2_ms = data->set.timeout - /* timeout time */
+    time_t timeout2_ms = data->set.timeout - /* timeout time */
       Curl_timediff(Curl_now(), conn->now); /* spent time */
 
     /* pick the lowest number */
@@ -222,8 +221,7 @@
   }
 
   if(conn->data->set.verbose)
-    Curl_debug(conn->data, CURLINFO_HEADER_OUT,
-               s, (size_t)bytes_written, conn);
+    Curl_debug(conn->data, CURLINFO_HEADER_OUT, s, (size_t)bytes_written);
 
   if(bytes_written != (ssize_t)write_len) {
     /* the whole chunk was not sent, keep it around and adjust sizes */
@@ -371,7 +369,7 @@
 #endif
             if(data->set.verbose)
               Curl_debug(data, CURLINFO_HEADER_IN,
-                         pp->linestart_resp, (size_t)perline, conn);
+                         pp->linestart_resp, (size_t)perline);
 
           /*
            * We pass all response-lines to the callback function registered
diff --git a/Utilities/cmcurl/lib/pipeline.c b/Utilities/cmcurl/lib/pipeline.c
index 4d41b04..8de3bab 100644
--- a/Utilities/cmcurl/lib/pipeline.c
+++ b/Utilities/cmcurl/lib/pipeline.c
@@ -6,7 +6,7 @@
  *                             \___|\___/|_| \_\_____|
  *
  * Copyright (C) 2013, Linus Nielsen Feltzing, <linus@haxx.se>
- * Copyright (C) 2013 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2013 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -82,7 +82,8 @@
       penalized = TRUE;
 
     infof(data, "Conn: %ld (%p) Receive pipe weight: (%"
-          CURL_FORMAT_CURL_OFF_T "/%zu), penalized: %s\n",
+          CURL_FORMAT_CURL_OFF_T "/%" CURL_FORMAT_CURL_OFF_T
+          "), penalized: %s\n",
           conn->connection_id, (void *)conn, recv_size,
           conn->chunk.datasize, penalized?"TRUE":"FALSE");
     return penalized;
@@ -109,8 +110,8 @@
   pipeline = &conn->send_pipe;
 
   result = addHandleToPipeline(handle, pipeline);
-
-  if(pipeline == &conn->send_pipe && sendhead != conn->send_pipe.head) {
+  if((conn->bundle->multiuse == BUNDLE_PIPELINING) &&
+     (pipeline == &conn->send_pipe && sendhead != conn->send_pipe.head)) {
     /* this is a new one as head, expire it */
     Curl_pipeline_leave_write(conn); /* not in use yet */
     Curl_expire(conn->send_pipe.head->ptr, 0, EXPIRE_RUN_NOW);
diff --git a/Utilities/cmcurl/lib/pop3.c b/Utilities/cmcurl/lib/pop3.c
index 78f6afe..cd994f6 100644
--- a/Utilities/cmcurl/lib/pop3.c
+++ b/Utilities/cmcurl/lib/pop3.c
@@ -613,7 +613,6 @@
   struct pop3_conn *pop3c = &conn->proto.pop3c;
   const char *line = data->state.buffer;
   size_t len = strlen(line);
-  size_t i;
 
   (void)instate; /* no use for this yet */
 
@@ -625,6 +624,7 @@
     /* Does the server support APOP authentication? */
     if(len >= 4 && line[len - 2] == '>') {
       /* Look for the APOP timestamp */
+      size_t i;
       for(i = 3; i < len - 2; ++i) {
         if(line[i] == '<') {
           /* Calculate the length of the timestamp */
@@ -664,7 +664,6 @@
   struct pop3_conn *pop3c = &conn->proto.pop3c;
   const char *line = data->state.buffer;
   size_t len = strlen(line);
-  size_t wordlen;
 
   (void)instate; /* no use for this yet */
 
@@ -689,6 +688,7 @@
       /* Loop through the data line */
       for(;;) {
         size_t llen;
+        size_t wordlen;
         unsigned int mechbit;
 
         while(len &&
diff --git a/Utilities/cmcurl/lib/progress.c b/Utilities/cmcurl/lib/progress.c
index f59faa3..a94668d 100644
--- a/Utilities/cmcurl/lib/progress.c
+++ b/Utilities/cmcurl/lib/progress.c
@@ -35,22 +35,22 @@
    byte) */
 static void time2str(char *r, curl_off_t seconds)
 {
-  curl_off_t d, h, m, s;
+  curl_off_t h;
   if(seconds <= 0) {
     strcpy(r, "--:--:--");
     return;
   }
   h = seconds / CURL_OFF_T_C(3600);
   if(h <= CURL_OFF_T_C(99)) {
-    m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
-    s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
+    curl_off_t m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
+    curl_off_t s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
     snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
              ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
   }
   else {
     /* this equals to more than 99 hours, switch to a more suitable output
        format to fit within the limits. */
-    d = seconds / CURL_OFF_T_C(86400);
+    curl_off_t d = seconds / CURL_OFF_T_C(86400);
     h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600);
     if(d <= CURL_OFF_T_C(999))
       snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
@@ -369,25 +369,10 @@
 int Curl_pgrsUpdate(struct connectdata *conn)
 {
   struct curltime now;
-  int result;
-  char max5[6][10];
-  curl_off_t dlpercen = 0;
-  curl_off_t ulpercen = 0;
-  curl_off_t total_percen = 0;
-  curl_off_t total_transfer;
-  curl_off_t total_expected_transfer;
   curl_off_t timespent;
   curl_off_t timespent_ms; /* milliseconds */
   struct Curl_easy *data = conn->data;
   int nowindex = data->progress.speeder_c% CURR_TIME;
-  int checkindex;
-  int countindex; /* amount of seconds stored in the speeder array */
-  char time_left[10];
-  char time_total[10];
-  char time_spent[10];
-  curl_off_t ulestimate = 0;
-  curl_off_t dlestimate = 0;
-  curl_off_t total_estimate;
   bool shownow = FALSE;
   curl_off_t dl = data->progress.downloaded;
   curl_off_t ul = data->progress.uploaded;
@@ -413,6 +398,7 @@
 
   /* Calculations done at most once a second, unless end is reached */
   if(data->progress.lastshow != now.tv_sec) {
+    int countindex; /* amount of seconds stored in the speeder array */
     shownow = TRUE;
 
     data->progress.lastshow = now.tv_sec;
@@ -438,6 +424,7 @@
 
     /* first of all, we don't do this if there's no counted seconds yet */
     if(countindex) {
+      int checkindex;
       timediff_t span_ms;
 
       /* Get the index position to compare with the 'nowindex' position.
@@ -477,8 +464,21 @@
 
   if(!(data->progress.flags & PGRS_HIDE)) {
     /* progress meter has not been shut off */
+    char max5[6][10];
+    curl_off_t dlpercen = 0;
+    curl_off_t ulpercen = 0;
+    curl_off_t total_percen = 0;
+    curl_off_t total_transfer;
+    curl_off_t total_expected_transfer;
+    char time_left[10];
+    char time_total[10];
+    char time_spent[10];
+    curl_off_t ulestimate = 0;
+    curl_off_t dlestimate = 0;
+    curl_off_t total_estimate;
 
     if(data->set.fxferinfo) {
+      int result;
       /* There's a callback set, call that */
       Curl_set_in_callback(data, true);
       result = data->set.fxferinfo(data->set.progress_client,
@@ -492,6 +492,7 @@
       return result;
     }
     if(data->set.fprogress) {
+      int result;
       /* The older deprecated callback is set, call that */
       Curl_set_in_callback(data, true);
       result = data->set.fprogress(data->set.progress_client,
diff --git a/Utilities/cmcurl/lib/progress.h b/Utilities/cmcurl/lib/progress.h
index 2baa925..92dbcbd 100644
--- a/Utilities/cmcurl/lib/progress.h
+++ b/Utilities/cmcurl/lib/progress.h
@@ -56,23 +56,10 @@
                                   struct curltime start,
                                   struct curltime now);
 
-/* Don't show progress for sizes smaller than: */
-#define LEAST_SIZE_PROGRESS BUFSIZE
-
-#define PROGRESS_DOWNLOAD (1<<0)
-#define PROGRESS_UPLOAD   (1<<1)
-#define PROGRESS_DOWN_AND_UP (PROGRESS_UPLOAD | PROGRESS_DOWNLOAD)
-
-#define PGRS_SHOW_DL (1<<0)
-#define PGRS_SHOW_UL (1<<1)
-#define PGRS_DONE_DL (1<<2)
-#define PGRS_DONE_UL (1<<3)
 #define PGRS_HIDE    (1<<4)
 #define PGRS_UL_SIZE_KNOWN (1<<5)
 #define PGRS_DL_SIZE_KNOWN (1<<6)
-
 #define PGRS_HEADERS_OUT (1<<7) /* set when the headers have been written */
 
-
 #endif /* HEADER_CURL_PROGRESS_H */
 
diff --git a/Utilities/cmcurl/lib/psl.c b/Utilities/cmcurl/lib/psl.c
new file mode 100644
index 0000000..568baff
--- /dev/null
+++ b/Utilities/cmcurl/lib/psl.c
@@ -0,0 +1,111 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include <curl/curl.h>
+
+#ifdef USE_LIBPSL
+
+#include "psl.h"
+#include "share.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+void Curl_psl_destroy(struct PslCache *pslcache)
+{
+  if(pslcache->psl) {
+    if(pslcache->dynamic)
+      psl_free((psl_ctx_t *) pslcache->psl);
+    pslcache->psl = NULL;
+    pslcache->dynamic = FALSE;
+  }
+}
+
+static time_t now_seconds(void)
+{
+  struct curltime now = Curl_now();
+
+  return now.tv_sec;
+}
+
+const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy)
+{
+  struct PslCache *pslcache = easy->psl;
+  const psl_ctx_t *psl;
+  time_t now;
+
+  if(!pslcache)
+    return NULL;
+
+  Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED);
+  now = now_seconds();
+  if(!pslcache->psl || pslcache->expires <= now) {
+    /* Let a chance to other threads to do the job: avoids deadlock. */
+    Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);
+
+    /* Update cache: this needs an exclusive lock. */
+    Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SINGLE);
+
+    /* Recheck in case another thread did the job. */
+    now = now_seconds();
+    if(!pslcache->psl || pslcache->expires <= now) {
+      bool dynamic = FALSE;
+      time_t expires = TIME_T_MAX;
+
+#if defined(PSL_VERSION_NUMBER) && PSL_VERSION_NUMBER >= 0x001000
+      psl = psl_latest(NULL);
+      dynamic = psl != NULL;
+      /* Take care of possible time computation overflow. */
+      expires = now < TIME_T_MAX - PSL_TTL? now + PSL_TTL: TIME_T_MAX;
+
+      /* Only get the built-in PSL if we do not already have the "latest". */
+      if(!psl && !pslcache->dynamic)
+#endif
+
+        psl = psl_builtin();
+
+      if(psl) {
+        Curl_psl_destroy(pslcache);
+        pslcache->psl = psl;
+        pslcache->dynamic = dynamic;
+        pslcache->expires = expires;
+      }
+    }
+    Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);  /* Release exclusive lock. */
+    Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED);
+  }
+  psl = pslcache->psl;
+  if(!psl)
+    Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);
+  return psl;
+}
+
+void Curl_psl_release(struct Curl_easy *easy)
+{
+  Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);
+}
+
+#endif /* USE_LIBPSL */
diff --git a/Utilities/cmcurl/lib/psl.h b/Utilities/cmcurl/lib/psl.h
new file mode 100644
index 0000000..e9f99d0
--- /dev/null
+++ b/Utilities/cmcurl/lib/psl.h
@@ -0,0 +1,47 @@
+#ifndef HEADER_PSL_H
+#define HEADER_PSL_H
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#ifdef USE_LIBPSL
+#include <libpsl.h>
+
+#define PSL_TTL (72 * 3600)     /* PSL time to live before a refresh. */
+
+struct PslCache {
+  const psl_ctx_t *psl; /* The PSL. */
+  time_t expires; /* Time this PSL life expires. */
+  bool dynamic; /* PSL should be released when no longer needed. */
+};
+
+const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy);
+void Curl_psl_release(struct Curl_easy *easy);
+void Curl_psl_destroy(struct PslCache *pslcache);
+
+#else
+
+#define Curl_psl_use(easy) NULL
+#define Curl_psl_release(easy)
+#define Curl_psl_destroy(pslcache)
+
+#endif /* USE_LIBPSL */
+#endif /* HEADER_PSL_H */
diff --git a/Utilities/cmcurl/lib/rand.c b/Utilities/cmcurl/lib/rand.c
index 0769ed1..1dc2504 100644
--- a/Utilities/cmcurl/lib/rand.c
+++ b/Utilities/cmcurl/lib/rand.c
@@ -158,7 +158,7 @@
   DEBUGASSERT(num > 1);
 
 #ifdef __clang_analyzer__
-  /* This silences a scan-build warning about accesssing this buffer with
+  /* This silences a scan-build warning about accessing this buffer with
      uninitialized memory. */
   memset(buffer, 0, sizeof(buffer));
 #endif
diff --git a/Utilities/cmcurl/lib/rtsp.c b/Utilities/cmcurl/lib/rtsp.c
index 41f3000..182ee29 100644
--- a/Utilities/cmcurl/lib/rtsp.c
+++ b/Utilities/cmcurl/lib/rtsp.c
@@ -218,8 +218,6 @@
   struct Curl_easy *data = conn->data;
   struct RTSP *rtsp = data->req.protop;
   CURLcode httpStatus;
-  long CSeq_sent;
-  long CSeq_recv;
 
   /* Bypass HTTP empty-reply checks on receive */
   if(data->set.rtspreq == RTSPREQ_RECEIVE)
@@ -229,8 +227,8 @@
 
   if(rtsp) {
     /* Check the sequence numbers */
-    CSeq_sent = rtsp->CSeq_sent;
-    CSeq_recv = rtsp->CSeq_recv;
+    long CSeq_sent = rtsp->CSeq_sent;
+    long CSeq_recv = rtsp->CSeq_recv;
     if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
       failf(data,
             "The CSeq of this request %ld did not match the response %ld",
diff --git a/Utilities/cmcurl/lib/security.c b/Utilities/cmcurl/lib/security.c
index d171985..4034115 100644
--- a/Utilities/cmcurl/lib/security.c
+++ b/Utilities/cmcurl/lib/security.c
@@ -390,7 +390,7 @@
 
   if(conn->data->set.verbose) {
     buf[decoded_len] = '\n';
-    Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1, conn);
+    Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1);
   }
 
   buf[decoded_len] = '\0';
@@ -488,7 +488,7 @@
 
   tmp_allocation = realloc(conn->app_data, mech->size);
   if(tmp_allocation == NULL) {
-    failf(data, "Failed realloc of size %u", mech->size);
+    failf(data, "Failed realloc of size %zu", mech->size);
     mech = NULL;
     return CURLE_OUT_OF_MEMORY;
   }
diff --git a/Utilities/cmcurl/lib/select.c b/Utilities/cmcurl/lib/select.c
index 0406dd2..6e73890 100644
--- a/Utilities/cmcurl/lib/select.c
+++ b/Utilities/cmcurl/lib/select.c
@@ -80,7 +80,6 @@
 #endif
   struct curltime initial_tv;
   int pending_ms;
-  int error;
 #endif
   int r = 0;
 
@@ -98,6 +97,7 @@
   pending_ms = timeout_ms;
   initial_tv = Curl_now();
   do {
+    int error;
 #if defined(HAVE_POLL_FINE)
     r = poll(NULL, 0, pending_ms);
 #else
@@ -160,7 +160,6 @@
 #endif
   struct curltime initial_tv = {0, 0};
   int pending_ms = 0;
-  int error;
   int r;
   int ret;
 
@@ -210,6 +209,7 @@
   }
 
   do {
+    int error;
     if(timeout_ms < 0)
       pending_ms = -1;
     else if(!timeout_ms)
@@ -291,6 +291,7 @@
   ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
 
   do {
+    int error;
     if(timeout_ms > 0) {
       pending_tv.tv_sec = pending_ms / 1000;
       pending_tv.tv_usec = (pending_ms % 1000) * 1000;
@@ -402,7 +403,6 @@
   bool fds_none = TRUE;
   unsigned int i;
   int pending_ms = 0;
-  int error;
   int r;
 
   if(ufds) {
@@ -431,6 +431,7 @@
 #ifdef HAVE_POLL_FINE
 
   do {
+    int error;
     if(timeout_ms < 0)
       pending_ms = -1;
     else if(!timeout_ms)
@@ -502,6 +503,7 @@
   ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
 
   do {
+    int error;
     if(timeout_ms > 0) {
       pending_tv.tv_sec = pending_ms / 1000;
       pending_tv.tv_usec = (pending_ms % 1000) * 1000;
diff --git a/Utilities/cmcurl/lib/sendf.c b/Utilities/cmcurl/lib/sendf.c
index 27c0ccc..d3c10b3 100644
--- a/Utilities/cmcurl/lib/sendf.c
+++ b/Utilities/cmcurl/lib/sendf.c
@@ -240,7 +240,7 @@
     vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap);
     va_end(ap);
     len = strlen(print_buffer);
-    Curl_debug(data, CURLINFO_TEXT, print_buffer, len, NULL);
+    Curl_debug(data, CURLINFO_TEXT, print_buffer, len);
   }
 }
 
@@ -265,7 +265,7 @@
     if(data->set.verbose) {
       error[len] = '\n';
       error[++len] = '\0';
-      Curl_debug(data, CURLINFO_TEXT, error, len, NULL);
+      Curl_debug(data, CURLINFO_TEXT, error, len);
     }
     va_end(ap);
   }
@@ -300,7 +300,7 @@
       break;
 
     if(data->set.verbose)
-      Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written, conn);
+      Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written);
 
     if((size_t)bytes_written != write_len) {
       /* if not all was written at once, we must advance the pointer, decrease
@@ -762,8 +762,8 @@
 }
 
 /* return 0 on success */
-static int showit(struct Curl_easy *data, curl_infotype type,
-                  char *ptr, size_t size)
+int Curl_debug(struct Curl_easy *data, curl_infotype type,
+               char *ptr, size_t size)
 {
   static const char s_infotype[CURLINFO_END][3] = {
     "* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
@@ -834,41 +834,3 @@
 #endif
   return rc;
 }
-
-int Curl_debug(struct Curl_easy *data, curl_infotype type,
-               char *ptr, size_t size,
-               struct connectdata *conn)
-{
-  int rc;
-  if(data->set.printhost && conn && conn->host.dispname) {
-    char buffer[160];
-    const char *t = NULL;
-    const char *w = "Data";
-    switch(type) {
-    case CURLINFO_HEADER_IN:
-      w = "Header";
-      /* FALLTHROUGH */
-    case CURLINFO_DATA_IN:
-      t = "from";
-      break;
-    case CURLINFO_HEADER_OUT:
-      w = "Header";
-      /* FALLTHROUGH */
-    case CURLINFO_DATA_OUT:
-      t = "to";
-      break;
-    default:
-      break;
-    }
-
-    if(t) {
-      snprintf(buffer, sizeof(buffer), "[%s %s %s]", w, t,
-               conn->host.dispname);
-      rc = showit(data, CURLINFO_TEXT, buffer, strlen(buffer));
-      if(rc)
-        return rc;
-    }
-  }
-  rc = showit(data, type, ptr, size);
-  return rc;
-}
diff --git a/Utilities/cmcurl/lib/sendf.h b/Utilities/cmcurl/lib/sendf.h
index 7c9134d..7627fe6 100644
--- a/Utilities/cmcurl/lib/sendf.h
+++ b/Utilities/cmcurl/lib/sendf.h
@@ -84,9 +84,8 @@
                           ssize_t *written);
 
 /* the function used to output verbose information */
-int Curl_debug(struct Curl_easy *handle, curl_infotype type,
-               char *data, size_t size,
-               struct connectdata *conn);
+int Curl_debug(struct Curl_easy *data, curl_infotype type,
+               char *ptr, size_t size);
 
 
 #endif /* HEADER_CURL_SENDF_H */
diff --git a/Utilities/cmcurl/lib/setopt.c b/Utilities/cmcurl/lib/setopt.c
index af53ee3..5c5f4b3 100644
--- a/Utilities/cmcurl/lib/setopt.c
+++ b/Utilities/cmcurl/lib/setopt.c
@@ -142,6 +142,25 @@
                             va_arg(param, char *));
     break;
 
+  case CURLOPT_TLS13_CIPHERS:
+    if(Curl_ssl_tls13_ciphersuites()) {
+      /* set preferred list of TLS 1.3 cipher suites */
+      result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_ORIG],
+                              va_arg(param, char *));
+    }
+    else
+      return CURLE_NOT_BUILT_IN;
+    break;
+  case CURLOPT_PROXY_TLS13_CIPHERS:
+    if(Curl_ssl_tls13_ciphersuites()) {
+      /* set preferred list of TLS 1.3 cipher suites for proxy */
+      result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_PROXY],
+                              va_arg(param, char *));
+    }
+    else
+      return CURLE_NOT_BUILT_IN;
+    break;
+
   case CURLOPT_RANDOM_FILE:
     /*
      * This is the path name to a file that contains random data to seed
@@ -1584,14 +1603,19 @@
      * String that holds the SSL crypto engine.
      */
     argptr = va_arg(param, char *);
-    if(argptr && argptr[0])
-      result = Curl_ssl_set_engine(data, argptr);
+    if(argptr && argptr[0]) {
+      result = Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], argptr);
+      if(!result) {
+        result = Curl_ssl_set_engine(data, argptr);
+      }
+    }
     break;
 
   case CURLOPT_SSLENGINE_DEFAULT:
     /*
      * flag to set engine as default.
      */
+    Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], NULL);
     result = Curl_ssl_set_engine_default(data);
     break;
   case CURLOPT_CRLF:
@@ -1942,6 +1966,11 @@
       if(data->share->sslsession == data->state.session)
         data->state.session = NULL;
 
+#ifdef USE_LIBPSL
+      if(data->psl == &data->share->psl)
+        data->psl = data->multi? &data->multi->psl: NULL;
+#endif
+
       data->share->dirty--;
 
       Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
@@ -1973,8 +2002,12 @@
         data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions;
         data->state.session = data->share->sslsession;
       }
-      Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
+#ifdef USE_LIBPSL
+      if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL))
+        data->psl = &data->share->psl;
+#endif
 
+      Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
     }
     /* check for host cache not needed,
      * it will be done by curl_easy_perform */
@@ -2562,6 +2595,10 @@
   case CURLOPT_DNS_SHUFFLE_ADDRESSES:
     data->set.dns_shuffle_addresses = (0 != va_arg(param, long)) ? TRUE:FALSE;
     break;
+  case CURLOPT_DISALLOW_USERNAME_IN_URL:
+    data->set.disallow_username_in_url =
+      (0 != va_arg(param, long)) ? TRUE : FALSE;
+    break;
   default:
     /* unknown tag and its companion, just ignore: */
     result = CURLE_UNKNOWN_OPTION;
diff --git a/Utilities/cmcurl/lib/sha256.c b/Utilities/cmcurl/lib/sha256.c
index 55716c6..f9287af 100644
--- a/Utilities/cmcurl/lib/sha256.c
+++ b/Utilities/cmcurl/lib/sha256.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2016, Florin Petriuc, <petriuc.florin@gmail.com>
+ * Copyright (C) 1998 - 2018, Florin Petriuc, <petriuc.florin@gmail.com>
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -123,15 +123,11 @@
 #define Sigma1(x)   (S(x, 6) ^ S(x, 11) ^ S(x, 25))
 #define Gamma0(x)   (S(x, 7) ^ S(x, 18) ^ R(x, 3))
 #define Gamma1(x)   (S(x, 17) ^ S(x, 19) ^ R(x, 10))
-#ifndef MIN
-#define MIN(x, y)   (((x) < (y)) ? (x) : (y))
-#endif
 /* compress 512-bits */
 static int sha256_compress(struct sha256_state *md,
                            unsigned char *buf)
 {
-  unsigned long S[8], W[64], t0, t1;
-  unsigned long t;
+  unsigned long S[8], W[64];
   int i;
   /* copy state into S */
   for(i = 0; i < 8; i++) {
@@ -146,12 +142,13 @@
       W[i - 16];
   }
   /* Compress */
-#define RND(a,b,c,d,e,f,g,h,i)                    \
-  t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
-  t1 = Sigma0(a) + Maj(a, b, c);                  \
-  d += t0;                                        \
+#define RND(a,b,c,d,e,f,g,h,i)                                  \
+  unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
+  unsigned long t1 = Sigma0(a) + Maj(a, b, c);                  \
+  d += t0;                                                      \
   h = t0 + t1;
   for(i = 0; i < 64; ++i) {
+    unsigned long t;
     RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
     t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
     S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
@@ -200,7 +197,7 @@
       inlen -= block_size;
     }
     else {
-      n = MIN(inlen, (block_size - md->curlen));
+      n = CURLMIN(inlen, (block_size - md->curlen));
       memcpy(md->buf + md->curlen, in, n);
       md->curlen += n;
       in += n;
diff --git a/Utilities/cmcurl/lib/share.c b/Utilities/cmcurl/lib/share.c
index 870b191..3d51086 100644
--- a/Utilities/cmcurl/lib/share.c
+++ b/Utilities/cmcurl/lib/share.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -25,6 +25,7 @@
 #include <curl/curl.h>
 #include "urldata.h"
 #include "share.h"
+#include "psl.h"
 #include "vtls/vtls.h"
 #include "curl_memory.h"
 
@@ -106,6 +107,12 @@
         res = CURLSHE_NOMEM;
       break;
 
+    case CURL_LOCK_DATA_PSL:
+#ifndef USE_LIBPSL
+      res = CURLSHE_NOT_BUILT_IN;
+#endif
+      break;
+
     default:
       res = CURLSHE_BAD_OPTION;
     }
@@ -205,6 +212,8 @@
   }
 #endif
 
+  Curl_psl_destroy(&share->psl);
+
   if(share->unlockfunc)
     share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
   free(share);
diff --git a/Utilities/cmcurl/lib/share.h b/Utilities/cmcurl/lib/share.h
index 4b13406..a7dea41 100644
--- a/Utilities/cmcurl/lib/share.h
+++ b/Utilities/cmcurl/lib/share.h
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -25,6 +25,7 @@
 #include "curl_setup.h"
 #include <curl/curl.h>
 #include "cookie.h"
+#include "psl.h"
 #include "urldata.h"
 #include "conncache.h"
 
@@ -49,6 +50,9 @@
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
   struct CookieInfo *cookies;
 #endif
+#ifdef USE_LIBPSL
+  struct PslCache psl;
+#endif
 
   struct curl_ssl_session *sslsession;
   size_t max_ssl_sessions;
diff --git a/Utilities/cmcurl/lib/smb.c b/Utilities/cmcurl/lib/smb.c
index 9ac6150..e4b18fc 100644
--- a/Utilities/cmcurl/lib/smb.c
+++ b/Utilities/cmcurl/lib/smb.c
@@ -59,6 +59,7 @@
 static CURLcode smb_setup_connection(struct connectdata *conn);
 static CURLcode smb_connect(struct connectdata *conn, bool *done);
 static CURLcode smb_connection_state(struct connectdata *conn, bool *done);
+static CURLcode smb_do(struct connectdata *conn, bool *done);
 static CURLcode smb_request_state(struct connectdata *conn, bool *done);
 static CURLcode smb_done(struct connectdata *conn, CURLcode status,
                          bool premature);
@@ -73,7 +74,7 @@
 const struct Curl_handler Curl_handler_smb = {
   "SMB",                                /* scheme */
   smb_setup_connection,                 /* setup_connection */
-  ZERO_NULL,                            /* do_it */
+  smb_do,                               /* do_it */
   smb_done,                             /* done */
   ZERO_NULL,                            /* do_more */
   smb_connect,                          /* connect_it */
@@ -98,7 +99,7 @@
 const struct Curl_handler Curl_handler_smbs = {
   "SMBS",                               /* scheme */
   smb_setup_connection,                 /* setup_connection */
-  ZERO_NULL,                            /* do_it */
+  smb_do,                               /* do_it */
   smb_done,                             /* done */
   ZERO_NULL,                            /* do_more */
   smb_connect,                          /* connect_it */
@@ -173,7 +174,6 @@
 /* SMB request data */
 struct smb_request {
   enum smb_req_state state;
-  char *share;
   char *path;
   unsigned short tid; /* Even if we connect to the same tree as another */
   unsigned short fid; /* request, the tid will be different */
@@ -182,7 +182,7 @@
 
 static void conn_state(struct connectdata *conn, enum smb_conn_state newstate)
 {
-  struct smb_conn *smb = &conn->proto.smbc;
+  struct smb_conn *smbc = &conn->proto.smbc;
 #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
   /* For debug purposes */
   static const char * const names[] = {
@@ -194,12 +194,12 @@
     /* LAST */
   };
 
-  if(smb->state != newstate)
+  if(smbc->state != newstate)
     infof(conn->data, "SMB conn %p state change from %s to %s\n",
-          (void *)smb, names[smb->state], names[newstate]);
+          (void *)smbc, names[smbc->state], names[newstate]);
 #endif
 
-  smb->state = newstate;
+  smbc->state = newstate;
 }
 
 static void request_state(struct connectdata *conn,
@@ -228,6 +228,8 @@
   req->state = newstate;
 }
 
+/* this should setup things in the connection, not in the easy
+   handle */
 static CURLcode smb_setup_connection(struct connectdata *conn)
 {
   struct smb_request *req;
@@ -253,7 +255,6 @@
     return CURLE_LOGIN_DENIED;
 
   /* Initialize the connection state */
-  memset(smbc, 0, sizeof(*smbc));
   smbc->state = SMB_CONNECTING;
   smbc->recv_buf = malloc(MAX_MESSAGE_SIZE);
   if(!smbc->recv_buf)
@@ -366,7 +367,7 @@
   ssize_t bytes_written;
   CURLcode result;
 
-  result = Curl_write(conn, FIRSTSOCKET, conn->data->state.uploadbuffer,
+  result = Curl_write(conn, FIRSTSOCKET, conn->data->state.ulbuf,
                       len, &bytes_written);
   if(result)
     return result;
@@ -392,7 +393,7 @@
     return CURLE_OK;
 
   result = Curl_write(conn, FIRSTSOCKET,
-                      conn->data->state.uploadbuffer + smbc->sent,
+                      conn->data->state.ulbuf + smbc->sent,
                       len, &bytes_written);
   if(result)
     return result;
@@ -408,9 +409,12 @@
 static CURLcode smb_send_message(struct connectdata *conn, unsigned char cmd,
                                  const void *msg, size_t msg_len)
 {
-  smb_format_message(conn, (struct smb_header *)conn->data->state.uploadbuffer,
+  CURLcode result = Curl_get_upload_buffer(conn->data);
+  if(result)
+    return result;
+  smb_format_message(conn, (struct smb_header *)conn->data->state.ulbuf,
                      cmd, msg_len);
-  memcpy(conn->data->state.uploadbuffer + sizeof(struct smb_header),
+  memcpy(conn->data->state.ulbuf + sizeof(struct smb_header),
          msg, msg_len);
 
   return smb_send(conn, sizeof(struct smb_header) + msg_len, 0);
@@ -475,11 +479,11 @@
 
 static CURLcode smb_send_tree_connect(struct connectdata *conn)
 {
-  struct smb_request *req = conn->data->req.protop;
   struct smb_tree_connect msg;
+  struct smb_conn *smbc = &conn->proto.smbc;
   char *p = msg.bytes;
 
-  size_t byte_count = strlen(conn->host.name) + strlen(req->share);
+  size_t byte_count = strlen(conn->host.name) + strlen(smbc->share);
   byte_count += strlen(SERVICENAME) + 5; /* 2 nulls and 3 backslashes */
   if(byte_count > sizeof(msg.bytes))
     return CURLE_FILESIZE_EXCEEDED;
@@ -491,7 +495,7 @@
   MSGCAT("\\\\");
   MSGCAT(conn->host.name);
   MSGCAT("\\");
-  MSGCATNULL(req->share);
+  MSGCATNULL(smbc->share);
   MSGCATNULL(SERVICENAME); /* Match any type of service */
   byte_count = p - msg.bytes;
   msg.byte_count = smb_swap16((unsigned short)byte_count);
@@ -571,11 +575,15 @@
 
 static CURLcode smb_send_write(struct connectdata *conn)
 {
-  struct smb_write *msg = (struct smb_write *)conn->data->state.uploadbuffer;
+  struct smb_write *msg;
   struct smb_request *req = conn->data->req.protop;
   curl_off_t offset = conn->data->req.offset;
-
   curl_off_t upload_size = conn->data->req.size - conn->data->req.bytecount;
+  CURLcode result = Curl_get_upload_buffer(conn->data);
+  if(result)
+    return result;
+  msg = (struct smb_write *)conn->data->state.ulbuf;
+
   if(upload_size >= MAX_PAYLOAD_SIZE - 1) /* There is one byte of padding */
     upload_size = MAX_PAYLOAD_SIZE - 1;
 
@@ -602,9 +610,9 @@
 
   /* Check if there is data in the transfer buffer */
   if(!smbc->send_size && smbc->upload_size) {
-    int nread = smbc->upload_size > UPLOAD_BUFSIZE ? UPLOAD_BUFSIZE :
-      (int) smbc->upload_size;
-    conn->data->req.upload_fromhere = conn->data->state.uploadbuffer;
+    size_t nread = smbc->upload_size > UPLOAD_BUFSIZE ? UPLOAD_BUFSIZE :
+      smbc->upload_size;
+    conn->data->req.upload_fromhere = conn->data->state.ulbuf;
     result = Curl_fillreadbuffer(conn, nread, &nread);
     if(result && result != CURLE_AGAIN)
       return result;
@@ -910,55 +918,52 @@
 static CURLcode smb_done(struct connectdata *conn, CURLcode status,
                          bool premature)
 {
-  struct smb_request *req = conn->data->req.protop;
-
   (void) premature;
-
-  Curl_safefree(req->share);
   Curl_safefree(conn->data->req.protop);
-
   return status;
 }
 
 static CURLcode smb_disconnect(struct connectdata *conn, bool dead)
 {
   struct smb_conn *smbc = &conn->proto.smbc;
-  struct smb_request *req = conn->data->req.protop;
-
   (void) dead;
-
+  Curl_safefree(smbc->share);
   Curl_safefree(smbc->domain);
   Curl_safefree(smbc->recv_buf);
-
-  /* smb_done is not always called, so cleanup the request */
-  if(req) {
-    Curl_safefree(req->share);
-  }
-
   return CURLE_OK;
 }
 
 static int smb_getsock(struct connectdata *conn, curl_socket_t *socks,
                        int numsocks)
 {
-  struct smb_conn *smbc = &conn->proto.smbc;
-
   if(!numsocks)
     return GETSOCK_BLANK;
 
   socks[0] = conn->sock[FIRSTSOCKET];
+  return GETSOCK_READSOCK(0) | GETSOCK_WRITESOCK(0);
+}
 
-  if(smbc->send_size || smbc->upload_size)
-    return GETSOCK_WRITESOCK(0);
+static CURLcode smb_do(struct connectdata *conn, bool *done)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  struct smb_request *req = conn->data->req.protop;
 
-  return GETSOCK_READSOCK(0);
+  *done = FALSE;
+  if(smbc->share) {
+    req->path = strchr(smbc->share, '\0');
+    if(req->path) {
+      req->path++;
+      return CURLE_OK;
+    }
+  }
+  return CURLE_URL_MALFORMAT;
 }
 
 static CURLcode smb_parse_url_path(struct connectdata *conn)
 {
   CURLcode result = CURLE_OK;
   struct Curl_easy *data = conn->data;
-  struct smb_request *req = data->req.protop;
+  struct smb_conn *smbc = &conn->proto.smbc;
   char *path;
   char *slash;
 
@@ -968,35 +973,29 @@
     return result;
 
   /* Parse the path for the share */
-  req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
-  if(!req->share) {
-    free(path);
-
+  smbc->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
+  free(path);
+  if(!smbc->share)
     return CURLE_OUT_OF_MEMORY;
-  }
 
-  slash = strchr(req->share, '/');
+  slash = strchr(smbc->share, '/');
   if(!slash)
-    slash = strchr(req->share, '\\');
+    slash = strchr(smbc->share, '\\');
 
   /* The share must be present */
   if(!slash) {
-    free(path);
-
+    Curl_safefree(smbc->share);
     return CURLE_URL_MALFORMAT;
   }
 
   /* Parse the path for the file path converting any forward slashes into
      backslashes */
   *slash++ = 0;
-  req->path = slash;
+
   for(; *slash; slash++) {
     if(*slash == '/')
       *slash = '\\';
   }
-
-  free(path);
-
   return CURLE_OK;
 }
 
diff --git a/Utilities/cmcurl/lib/smb.h b/Utilities/cmcurl/lib/smb.h
index c3ee7ae..9ce6b56 100644
--- a/Utilities/cmcurl/lib/smb.h
+++ b/Utilities/cmcurl/lib/smb.h
@@ -35,6 +35,7 @@
   enum smb_conn_state state;
   char *user;
   char *domain;
+  char *share;
   unsigned char challenge[8];
   unsigned int session_key;
   unsigned short uid;
diff --git a/Utilities/cmcurl/lib/smtp.c b/Utilities/cmcurl/lib/smtp.c
index 3f3b45a..ecf10a4 100644
--- a/Utilities/cmcurl/lib/smtp.c
+++ b/Utilities/cmcurl/lib/smtp.c
@@ -704,7 +704,6 @@
   struct smtp_conn *smtpc = &conn->proto.smtpc;
   const char *line = data->state.buffer;
   size_t len = strlen(line);
-  size_t wordlen;
 
   (void)instate; /* no use for this yet */
 
@@ -739,6 +738,7 @@
       /* Loop through the data line */
       for(;;) {
         size_t llen;
+        size_t wordlen;
         unsigned int mechbit;
 
         while(len &&
@@ -1563,13 +1563,14 @@
   if(!scratch || data->set.crlf) {
     oldscratch = scratch;
 
-    scratch = newscratch = malloc(2 * data->set.buffer_size);
+    scratch = newscratch = malloc(2 * UPLOAD_BUFSIZE);
     if(!newscratch) {
       failf(data, "Failed to alloc scratch buffer!");
 
       return CURLE_OUT_OF_MEMORY;
     }
   }
+  DEBUGASSERT(UPLOAD_BUFSIZE >= nread);
 
   /* Have we already sent part of the EOB? */
   eob_sent = smtp->eob;
diff --git a/Utilities/cmcurl/lib/socks.c b/Utilities/cmcurl/lib/socks.c
index ac4270e..81f3eda 100644
--- a/Utilities/cmcurl/lib/socks.c
+++ b/Utilities/cmcurl/lib/socks.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -57,10 +57,9 @@
   ssize_t nread;
   ssize_t allread = 0;
   int result;
-  timediff_t timeleft;
   *n = 0;
   for(;;) {
-    timeleft = Curl_timeleft(conn->data, NULL, TRUE);
+    timediff_t timeleft = Curl_timeleft(conn->data, NULL, TRUE);
     if(timeleft < 0) {
       /* we already got the timeout */
       result = CURLE_OPERATION_TIMEDOUT;
@@ -116,7 +115,6 @@
 #define SOCKS4REQLEN 262
   unsigned char socksreq[SOCKS4REQLEN]; /* room for SOCKS4 request incl. user
                                            id */
-  int result;
   CURLcode code;
   curl_socket_t sock = conn->sock[sockindex];
   struct Curl_easy *data = conn->data;
@@ -220,11 +218,12 @@
    * Make connection
    */
   {
+    int result;
     ssize_t actualread;
     ssize_t written;
     ssize_t hostnamelen = 0;
-    int packetsize = 9 +
-      (int)strlen((char *)socksreq + 8); /* size including NUL */
+    ssize_t packetsize = 9 +
+      strlen((char *)socksreq + 8); /* size including NUL */
 
     /* If SOCKS4a, set special invalid IP address 0.0.0.x */
     if(protocol4a) {
@@ -617,11 +616,11 @@
     if(dns)
       hp = dns->addr;
     if(hp) {
-      int i;
       char buf[64];
       Curl_printable_address(hp, buf, sizeof(buf));
 
       if(hp->ai_family == AF_INET) {
+        int i;
         struct sockaddr_in *saddr_in;
         socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
 
@@ -634,6 +633,7 @@
       }
 #ifdef ENABLE_IPV6
       else if(hp->ai_family == AF_INET6) {
+        int i;
         struct sockaddr_in6 *saddr_in6;
         socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
 
diff --git a/Utilities/cmcurl/lib/splay.c b/Utilities/cmcurl/lib/splay.c
index 69af446..c54a63b 100644
--- a/Utilities/cmcurl/lib/splay.c
+++ b/Utilities/cmcurl/lib/splay.c
@@ -41,7 +41,6 @@
                              struct Curl_tree *t)
 {
   struct Curl_tree N, *l, *r, *y;
-  long comp;
 
   if(t == NULL)
     return t;
@@ -49,7 +48,7 @@
   l = r = &N;
 
   for(;;) {
-    comp = compare(i, t->key);
+    long comp = compare(i, t->key);
     if(comp < 0) {
       if(t->smaller == NULL)
         break;
diff --git a/Utilities/cmcurl/lib/ssh-libssh.c b/Utilities/cmcurl/lib/ssh-libssh.c
index 34ef490..7d59089 100644
--- a/Utilities/cmcurl/lib/ssh-libssh.c
+++ b/Utilities/cmcurl/lib/ssh-libssh.c
@@ -204,11 +204,21 @@
   return CURLE_SSH;
 }
 
+#ifndef DEBUGBUILD
+#define state(x,y) mystate(x,y)
+#else
+#define state(x,y) mystate(x,y, __LINE__)
+#endif
+
 /*
  * SSH State machine related code
  */
 /* This is the ONLY way to change SSH state! */
-static void state(struct connectdata *conn, sshstate nowstate)
+static void mystate(struct connectdata *conn, sshstate nowstate
+#ifdef DEBUGBUILD
+                    , int lineno
+#endif
+  )
 {
   struct ssh_conn *sshc = &conn->proto.sshc;
 #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
@@ -278,8 +288,9 @@
 
 
   if(sshc->state != nowstate) {
-    infof(conn->data, "SSH %p state change from %s to %s\n",
-          (void *) sshc, names[sshc->state], names[nowstate]);
+    infof(conn->data, "SSH %p state change from %s to %s (line %d)\n",
+          (void *) sshc, names[sshc->state], names[nowstate],
+          lineno);
   }
 #endif
 
@@ -418,7 +429,7 @@
 }
 
 #define MOVE_TO_ERROR_STATE(_r) { \
-  state(conn, SSH_SESSION_FREE); \
+  state(conn, SSH_SESSION_DISCONNECT); \
   sshc->actualcode = _r; \
   rc = SSH_ERROR; \
   break; \
@@ -486,7 +497,7 @@
       if(rc < 0)
         return SSH_ERROR;
 
-    /* fallthrough */
+    /* FALLTHROUGH */
     case 1:
       sshc->kbd_state = 1;
 
@@ -561,7 +572,7 @@
       ssh_set_blocking(sshc->ssh_session, 0);
 
       state(conn, SSH_S_STARTUP);
-      /* fall-through */
+      /* FALLTHROUGH */
 
     case SSH_S_STARTUP:
       rc = ssh_connect(sshc->ssh_session);
@@ -575,7 +586,7 @@
 
       state(conn, SSH_HOSTKEY);
 
-      /* fall-through */
+      /* FALLTHROUGH */
     case SSH_HOSTKEY:
 
       rc = myssh_is_known(conn);
@@ -584,7 +595,7 @@
       }
 
       state(conn, SSH_AUTHLIST);
-      /* fall through */
+      /* FALLTHROUGH */
     case SSH_AUTHLIST:{
         sshc->authed = FALSE;
 
@@ -607,6 +618,7 @@
         sshc->auth_methods = ssh_userauth_list(sshc->ssh_session, NULL);
         if(sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
           state(conn, SSH_AUTH_PKEY_INIT);
+          infof(data, "Authentication using SSH public key file\n");
         }
         else if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) {
           state(conn, SSH_AUTH_GSSAPI);
@@ -651,6 +663,7 @@
         if(rc != SSH_OK) {
           failf(data, "Could not load private key file %s",
                 data->set.str[STRING_SSH_PRIVATE_KEY]);
+          MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
           break;
         }
 
@@ -659,8 +672,6 @@
 
       }
       else {
-        infof(data, "Authentication using SSH public key file\n");
-
         rc = ssh_userauth_publickey_auto(sshc->ssh_session, NULL,
                                          data->set.ssl.key_passwd);
         if(rc == SSH_AUTH_AGAIN) {
@@ -748,7 +759,7 @@
         MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
       }
       state(conn, SSH_AUTH_PASS);
-      /* fall through */
+      /* FALLTHROUGH */
 
     case SSH_AUTH_PASS:
       rc = ssh_userauth_password(sshc->ssh_session, NULL, conn->passwd);
@@ -812,7 +823,7 @@
         break;
       }
       state(conn, SSH_SFTP_REALPATH);
-      /* fall through */
+      /* FALLTHROUGH */
     case SSH_SFTP_REALPATH:
       /*
        * Get the "home" directory
@@ -1279,7 +1290,7 @@
       if(sshc->readdir_attrs) {
         sshc->readdir_filename = sshc->readdir_attrs->name;
         sshc->readdir_longentry = sshc->readdir_attrs->longname;
-        sshc->readdir_len = (int)strlen(sshc->readdir_filename);
+        sshc->readdir_len = strlen(sshc->readdir_filename);
 
         if(data->set.ftp_list_only) {
           char *tmpLine;
@@ -1306,11 +1317,11 @@
           if(data->set.verbose) {
             Curl_debug(data, CURLINFO_DATA_OUT,
                        (char *)sshc->readdir_filename,
-                       sshc->readdir_len, conn);
+                       sshc->readdir_len);
           }
         }
         else {
-          sshc->readdir_currLen = (int)strlen(sshc->readdir_longentry);
+          sshc->readdir_currLen = strlen(sshc->readdir_longentry);
           sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
           sshc->readdir_line = calloc(sshc->readdir_totalLen, 1);
           if(!sshc->readdir_line) {
@@ -1371,12 +1382,12 @@
         if(sshc->readdir_filename == NULL)
           sshc->readdir_len = 0;
         else
-          sshc->readdir_len = (int)strlen(sshc->readdir_tmp);
+          sshc->readdir_len = strlen(sshc->readdir_tmp);
         sshc->readdir_longentry = NULL;
         sshc->readdir_filename = sshc->readdir_tmp;
       }
       else {
-        sshc->readdir_len = (int)strlen(sshc->readdir_link_attrs->name);
+        sshc->readdir_len = strlen(sshc->readdir_link_attrs->name);
         sshc->readdir_filename = sshc->readdir_link_attrs->name;
         sshc->readdir_longentry = sshc->readdir_link_attrs->longname;
       }
@@ -1408,7 +1419,7 @@
       sshc->readdir_longentry = NULL;
 
       state(conn, SSH_SFTP_READDIR_BOTTOM);
-      /* fall through */
+      /* FALLTHROUGH */
     case SSH_SFTP_READDIR_BOTTOM:
       sshc->readdir_currLen += snprintf(sshc->readdir_line +
                                         sshc->readdir_currLen,
@@ -1423,7 +1434,7 @@
         /* output debug output if that is requested */
         if(data->set.verbose) {
           Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
-                     sshc->readdir_currLen, conn);
+                     sshc->readdir_currLen);
         }
         data->req.bytecount += sshc->readdir_currLen;
       }
@@ -1740,7 +1751,7 @@
         MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
       }
       state(conn, SSH_SCP_DOWNLOAD);
-      /* fall through */
+      /* FALLTHROUGH */
 
     case SSH_SCP_DOWNLOAD:{
         curl_off_t bytecount;
@@ -1805,7 +1816,7 @@
       ssh_set_blocking(sshc->ssh_session, 0);
 
       state(conn, SSH_SESSION_DISCONNECT);
-      /* fall through */
+      /* FALLTHROUGH */
 
     case SSH_SESSION_DISCONNECT:
       /* during weird times when we've been prematurely aborted, the channel
@@ -1822,7 +1833,7 @@
       conn->data->state.most_recent_ftp_entrypath = NULL;
 
       state(conn, SSH_SESSION_FREE);
-      /* fall through */
+      /* FALLTHROUGH */
     case SSH_SESSION_FREE:
       if(sshc->ssh_session) {
         ssh_free(sshc->ssh_session);
@@ -2379,7 +2390,8 @@
     /* Post quote commands are executed after the SFTP_CLOSE state to avoid
        errors that could happen due to open file handles during POSTQUOTE
        operation */
-    if(!status && !premature && conn->data->set.postquote) {
+    if(!status && !premature && conn->data->set.postquote &&
+       !conn->bits.retry) {
       sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT;
       state(conn, SSH_SFTP_CLOSE);
     }
@@ -2437,7 +2449,7 @@
         return -1;
       }
 
-      /* fall-through */
+      /* FALLTHROUGH */
     case 1:
       conn->proto.sshc.sftp_recv_state = 1;
 
@@ -2500,8 +2512,8 @@
       return;
     }
     if(data->set.verbose) {
-      Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4, conn);
-      Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp), conn);
+      Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4);
+      Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
     }
     /* this sends an FTP-like "header" to the header callback so that the
        current directory can be read very similar to how it is read when
diff --git a/Utilities/cmcurl/lib/ssh.c b/Utilities/cmcurl/lib/ssh.c
index bf7bd54..a4b2ca4 100644
--- a/Utilities/cmcurl/lib/ssh.c
+++ b/Utilities/cmcurl/lib/ssh.c
@@ -659,7 +659,7 @@
       libssh2_session_set_blocking(sshc->ssh_session, 0);
 
       state(conn, SSH_S_STARTUP);
-      /* fall-through */
+      /* FALLTHROUGH */
 
     case SSH_S_STARTUP:
       rc = libssh2_session_startup(sshc->ssh_session, (int)sock);
@@ -675,7 +675,7 @@
 
       state(conn, SSH_HOSTKEY);
 
-      /* fall-through */
+      /* FALLTHROUGH */
     case SSH_HOSTKEY:
       /*
        * Before we authenticate we should check the hostkey's fingerprint
@@ -1175,8 +1175,8 @@
           break;
         }
         if(data->set.verbose) {
-          Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4, conn);
-          Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp), conn);
+          Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4);
+          Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
         }
         /* this sends an FTP-like "header" to the header callback so that the
            current directory can be read very similar to how it is read when
@@ -1933,17 +1933,17 @@
       break;
 
     case SSH_SFTP_READDIR:
-      sshc->readdir_len = libssh2_sftp_readdir_ex(sshc->sftp_handle,
-                                                  sshc->readdir_filename,
-                                                  PATH_MAX,
-                                                  sshc->readdir_longentry,
-                                                  PATH_MAX,
-                                                  &sshc->readdir_attrs);
-      if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
-        rc = LIBSSH2_ERROR_EAGAIN;
+      rc = libssh2_sftp_readdir_ex(sshc->sftp_handle,
+                                   sshc->readdir_filename,
+                                   PATH_MAX,
+                                   sshc->readdir_longentry,
+                                   PATH_MAX,
+                                   &sshc->readdir_attrs);
+      if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(sshc->readdir_len > 0) {
+      if(rc > 0) {
+        sshc->readdir_len = (size_t) rc;
         sshc->readdir_filename[sshc->readdir_len] = '\0';
 
         if(data->set.ftp_list_only) {
@@ -1970,11 +1970,11 @@
           /* output debug output if that is requested */
           if(data->set.verbose) {
             Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_filename,
-                       sshc->readdir_len, conn);
+                       sshc->readdir_len);
           }
         }
         else {
-          sshc->readdir_currLen = (int)strlen(sshc->readdir_longentry);
+          sshc->readdir_currLen = strlen(sshc->readdir_longentry);
           sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
           sshc->readdir_line = calloc(sshc->readdir_totalLen, 1);
           if(!sshc->readdir_line) {
@@ -2008,13 +2008,13 @@
           break;
         }
       }
-      else if(sshc->readdir_len == 0) {
+      else if(rc == 0) {
         Curl_safefree(sshc->readdir_filename);
         Curl_safefree(sshc->readdir_longentry);
         state(conn, SSH_SFTP_READDIR_DONE);
         break;
       }
-      else if(sshc->readdir_len <= 0) {
+      else if(rc < 0) {
         err = sftp_libssh2_last_error(sshc->sftp_session);
         result = sftp_libssh2_error_to_CURLE(err);
         sshc->actualcode = result?result:CURLE_SSH;
@@ -2029,16 +2029,16 @@
       break;
 
     case SSH_SFTP_READDIR_LINK:
-      sshc->readdir_len =
+      rc =
         libssh2_sftp_symlink_ex(sshc->sftp_session,
                                 sshc->readdir_linkPath,
                                 curlx_uztoui(strlen(sshc->readdir_linkPath)),
                                 sshc->readdir_filename,
                                 PATH_MAX, LIBSSH2_SFTP_READLINK);
-      if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
-        rc = LIBSSH2_ERROR_EAGAIN;
+      if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
+      sshc->readdir_len = (size_t) rc;
       Curl_safefree(sshc->readdir_linkPath);
 
       /* get room for the filename and extra output */
@@ -2079,7 +2079,7 @@
         /* output debug output if that is requested */
         if(data->set.verbose) {
           Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
-                     sshc->readdir_currLen, conn);
+                     sshc->readdir_currLen);
         }
         data->req.bytecount += sshc->readdir_currLen;
       }
@@ -3219,7 +3219,8 @@
     /* Post quote commands are executed after the SFTP_CLOSE state to avoid
        errors that could happen due to open file handles during POSTQUOTE
        operation */
-    if(!status && !premature && conn->data->set.postquote) {
+    if(!status && !premature && conn->data->set.postquote &&
+       !conn->bits.retry) {
       sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT;
       state(conn, SSH_SFTP_CLOSE);
     }
diff --git a/Utilities/cmcurl/lib/ssh.h b/Utilities/cmcurl/lib/ssh.h
index 1c13550..0620aac 100644
--- a/Utilities/cmcurl/lib/ssh.h
+++ b/Utilities/cmcurl/lib/ssh.h
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -131,7 +131,7 @@
                                  quote command fails) */
   char *homedir;              /* when doing SFTP we figure out home dir in the
                                  connect phase */
-  int readdir_len, readdir_totalLen, readdir_currLen;
+  size_t readdir_len, readdir_totalLen, readdir_currLen;
   char *readdir_line;
   char *readdir_linkPath;
   /* end of READDIR stuff */
diff --git a/Utilities/cmcurl/lib/strcase.h b/Utilities/cmcurl/lib/strcase.h
index ea2abc8..6fee384 100644
--- a/Utilities/cmcurl/lib/strcase.h
+++ b/Utilities/cmcurl/lib/strcase.h
@@ -46,6 +46,5 @@
 #define checkprefix(a,b)    curl_strnequal(a,b,strlen(a))
 
 void Curl_strntoupper(char *dest, const char *src, size_t n);
-char Curl_raw_toupper(char in);
 
 #endif /* HEADER_CURL_STRCASE_H */
diff --git a/Utilities/cmcurl/lib/system_win32.c b/Utilities/cmcurl/lib/system_win32.c
index cfbbf32..6b8004e 100644
--- a/Utilities/cmcurl/lib/system_win32.c
+++ b/Utilities/cmcurl/lib/system_win32.c
@@ -26,6 +26,7 @@
 
 #include <curl/curl.h>
 #include "system_win32.h"
+#include "warnless.h"
 
 /* The last #include files should be: */
 #include "curl_memory.h"
@@ -134,8 +135,9 @@
       break;
 
     case VERSION_LESS_THAN_EQUAL:
-      if(osver.dwMajorVersion <= majorVersion &&
-         osver.dwMinorVersion <= minorVersion)
+      if(osver.dwMajorVersion < majorVersion ||
+        (osver.dwMajorVersion == majorVersion &&
+         osver.dwMinorVersion <= minorVersion))
         matched = TRUE;
       break;
 
@@ -146,8 +148,9 @@
       break;
 
     case VERSION_GREATER_THAN_EQUAL:
-      if(osver.dwMajorVersion >= majorVersion &&
-         osver.dwMinorVersion >= minorVersion)
+      if(osver.dwMajorVersion > majorVersion ||
+        (osver.dwMajorVersion == majorVersion &&
+         osver.dwMinorVersion >= minorVersion))
         matched = TRUE;
       break;
 
@@ -278,7 +281,9 @@
 
   /* Attempt to find LoadLibraryEx() which is only available on Windows 2000
      and above */
-  pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX);
+  pLoadLibraryEx =
+    CURLX_FUNCTION_CAST(LOADLIBRARYEX_FN,
+                        (GetProcAddress(hKernel32, LOADLIBARYEX)));
 
   /* Detect if there's already a path in the filename and load the library if
      there is. Note: Both back slashes and forward slashes have been supported
diff --git a/Utilities/cmcurl/lib/telnet.c b/Utilities/cmcurl/lib/telnet.c
index d71c8e0..05fe744 100644
--- a/Utilities/cmcurl/lib/telnet.c
+++ b/Utilities/cmcurl/lib/telnet.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -52,10 +52,6 @@
 #include "connect.h"
 #include "progress.h"
 #include "system_win32.h"
-
-#define  TELOPTS
-#define  TELCMDS
-
 #include "arpa_telnet.h"
 #include "select.h"
 #include "strcase.h"
@@ -74,10 +70,10 @@
     x->subend = x->subpointer;                          \
     CURL_SB_CLEAR(x);                                   \
   } WHILE_FALSE
-#define CURL_SB_ACCUM(x,c)                                   \
-  do {                                                       \
-    if(x->subpointer < (x->subbuffer + sizeof x->subbuffer)) \
-      *x->subpointer++ = (c);                                \
+#define CURL_SB_ACCUM(x,c)                                      \
+  do {                                                          \
+    if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer)))   \
+      *x->subpointer++ = (c);                                   \
   } WHILE_FALSE
 
 #define  CURL_SB_GET(x) ((*x->subpointer++)&0xff)
@@ -92,6 +88,7 @@
 #endif
 
 #ifdef USE_WINSOCK
+typedef WSAEVENT (WINAPI *WSOCK2_EVENT)(void);
 typedef FARPROC WSOCK2_FUNC;
 static CURLcode check_wsock2(struct Curl_easy *data);
 #endif
@@ -109,8 +106,10 @@
 
 static void negotiate(struct connectdata *);
 static void send_negotiation(struct connectdata *, int cmd, int option);
-static void set_local_option(struct connectdata *, int cmd, int option);
-static void set_remote_option(struct connectdata *, int cmd, int option);
+static void set_local_option(struct connectdata *conn,
+                             int option, int newstate);
+static void set_remote_option(struct connectdata *conn,
+                              int option, int newstate);
 
 static void printsub(struct Curl_easy *data,
                      int direction, unsigned char *pointer,
@@ -311,9 +310,6 @@
 static void printoption(struct Curl_easy *data,
                         const char *direction, int cmd, int option)
 {
-  const char *fmt;
-  const char *opt;
-
   if(data->set.verbose) {
     if(cmd == CURL_IAC) {
       if(CURL_TELCMD_OK(option))
@@ -322,9 +318,12 @@
         infof(data, "%s IAC %d\n", direction, option);
     }
     else {
-      fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
-        (cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
+      const char *fmt = (cmd == CURL_WILL) ? "WILL" :
+                        (cmd == CURL_WONT) ? "WONT" :
+                        (cmd == CURL_DO) ? "DO" :
+                        (cmd == CURL_DONT) ? "DONT" : 0;
       if(fmt) {
+        const char *opt;
         if(CURL_TELOPT_OK(option))
           opt = CURL_TELOPT(option);
         else if(option == CURL_TELOPT_EXOPL)
@@ -348,7 +347,6 @@
 {
    unsigned char buf[3];
    ssize_t bytes_written;
-   int err;
    struct Curl_easy *data = conn->data;
 
    buf[0] = CURL_IAC;
@@ -357,7 +355,7 @@
 
    bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
    if(bytes_written < 0) {
-     err = SOCKERRNO;
+     int err = SOCKERRNO;
      failf(data,"Sending data failed (%d)",err);
    }
 
@@ -710,9 +708,8 @@
                      unsigned char *pointer,    /* where suboption data is */
                      size_t length)             /* length of suboption data */
 {
-  unsigned int i = 0;
-
   if(data->set.verbose) {
+    unsigned int i = 0;
     if(direction) {
       infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
       if(length >= 3) {
@@ -764,7 +761,7 @@
     switch(pointer[0]) {
     case CURL_TELOPT_NAWS:
       if(length > 4)
-        infof(data, "Width: %hu ; Height: %hu", (pointer[1]<<8) | pointer[2],
+        infof(data, "Width: %d ; Height: %d", (pointer[1]<<8) | pointer[2],
               (pointer[3]<<8) | pointer[4]);
       break;
     default:
@@ -928,7 +925,6 @@
   unsigned char temp[2048];
   ssize_t bytes_written;
   size_t len;
-  size_t tmplen;
   int err;
   char varname[128] = "";
   char varval[128] = "";
@@ -968,7 +964,7 @@
       len = 4;
 
       for(v = tn->telnet_vars; v; v = v->next) {
-        tmplen = (strlen(v->data) + 1);
+        size_t tmplen = (strlen(v->data) + 1);
         /* Add the variable only if it fits */
         if(len + tmplen < (int)sizeof(temp)-6) {
           if(sscanf(v->data, "%127[^,],%127s", varname, varval)) {
@@ -1017,7 +1013,7 @@
     CURL_SB_ACCUM(tn, CURL_IAC);
     CURL_SB_ACCUM(tn, CURL_SB);
     CURL_SB_ACCUM(tn, CURL_TELOPT_NAWS);
-    /* We must deal either with litte or big endian processors */
+    /* We must deal either with little or big endian processors */
     /* Window size must be sent according to the 'network order' */
     x = htons(tn->subopt_wsx);
     y = htons(tn->subopt_wsy);
@@ -1223,7 +1219,7 @@
 static CURLcode send_telnet_data(struct connectdata *conn,
                                  char *buffer, ssize_t nread)
 {
-  ssize_t escapes, i, j, outlen;
+  ssize_t escapes, i, outlen;
   unsigned char *outbuf = NULL;
   CURLcode result = CURLE_OK;
   ssize_t bytes_written, total_written;
@@ -1238,6 +1234,7 @@
   if(outlen == nread)
     outbuf = (unsigned char *)buffer;
   else {
+    ssize_t j;
     outbuf = malloc(nread + escapes + 1);
     if(!outbuf)
       return CURLE_OUT_OF_MEMORY;
@@ -1306,7 +1303,7 @@
 #ifdef USE_WINSOCK
   HMODULE wsock2;
   WSOCK2_FUNC close_event_func;
-  WSOCK2_FUNC create_event_func;
+  WSOCK2_EVENT create_event_func;
   WSOCK2_FUNC event_select_func;
   WSOCK2_FUNC enum_netevents_func;
   WSAEVENT event_handle;
@@ -1315,7 +1312,6 @@
   HANDLE objs[2];
   DWORD  obj_count;
   DWORD  wait_timeout;
-  DWORD waitret;
   DWORD readfile_read;
   int err;
 #else
@@ -1361,7 +1357,9 @@
   }
 
   /* Grab a pointer to WSACreateEvent */
-  create_event_func = GetProcAddress(wsock2, "WSACreateEvent");
+  create_event_func =
+    CURLX_FUNCTION_CAST(WSOCK2_EVENT,
+                        (GetProcAddress(wsock2, "WSACreateEvent")));
   if(create_event_func == NULL) {
     failf(data, "failed to find WSACreateEvent function (%u)", GetLastError());
     FreeLibrary(wsock2);
@@ -1438,7 +1436,8 @@
   /* Keep on listening and act on events */
   while(keepon) {
     const DWORD buf_size = (DWORD)data->set.buffer_size;
-    waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout);
+    DWORD waitret = WaitForMultipleObjects(obj_count, objs,
+                                           FALSE, wait_timeout);
     switch(waitret) {
     case WAIT_TIMEOUT:
     {
@@ -1607,7 +1606,7 @@
     case 0:                     /* timeout */
       pfd[0].revents = 0;
       pfd[1].revents = 0;
-      /* fall through */
+      /* FALLTHROUGH */
     default:                    /* read! */
       if(pfd[0].revents & POLLIN) {
         /* read data from network */
diff --git a/Utilities/cmcurl/lib/tftp.c b/Utilities/cmcurl/lib/tftp.c
index b32960f..e5bc80b 100644
--- a/Utilities/cmcurl/lib/tftp.c
+++ b/Utilities/cmcurl/lib/tftp.c
@@ -451,7 +451,6 @@
   ssize_t senddata;
   const char *mode = "octet";
   char *filename;
-  char buf[64];
   struct Curl_easy *data = state->conn->data;
   CURLcode result = CURLE_OK;
 
@@ -504,6 +503,7 @@
 
     /* optional addition of TFTP options */
     if(!data->set.tftp_no_options) {
+      char buf[64];
       /* add tsize option */
       if(data->set.upload && (data->state.infilesize != -1))
         snprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T,
@@ -710,10 +710,9 @@
 {
   struct Curl_easy *data = state->conn->data;
   ssize_t sbytes;
-  int rblock;
   CURLcode result = CURLE_OK;
   struct SingleRequest *k = &data->req;
-  int cb; /* Bytes currently read */
+  size_t cb; /* Bytes currently read */
 
   switch(event) {
 
@@ -721,7 +720,7 @@
   case TFTP_EVENT_OACK:
     if(event == TFTP_EVENT_ACK) {
       /* Ack the packet */
-      rblock = getrpacketblock(&state->rpacket);
+      int rblock = getrpacketblock(&state->rpacket);
 
       if(rblock != state->block &&
          /* There's a bug in tftpd-hpa that causes it to send us an ack for
@@ -766,7 +765,7 @@
     state->retries = 0;
     setpacketevent(&state->spacket, TFTP_EVENT_DATA);
     setpacketblock(&state->spacket, state->block);
-    if(state->block > 1 && state->sbytes < (int)state->blksize) {
+    if(state->block > 1 && state->sbytes < state->blksize) {
       state->state = TFTP_STATE_FIN;
       return CURLE_OK;
     }
@@ -782,7 +781,7 @@
                                    &cb);
       if(result)
         return result;
-      state->sbytes += cb;
+      state->sbytes += (int)cb;
       state->conn->data->req.upload_fromhere += cb;
     } while(state->sbytes < state->blksize && cb != 0);
 
@@ -969,7 +968,7 @@
 static CURLcode tftp_connect(struct connectdata *conn, bool *done)
 {
   tftp_state_data_t *state;
-  int blksize, rc;
+  int blksize;
 
   blksize = TFTP_BLKSIZE_DEFAULT;
 
@@ -1028,8 +1027,8 @@
      * assume uses the same IP version and thus hopefully this works for both
      * IPv4 and IPv6...
      */
-    rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
-              conn->ip_addr->ai_addrlen);
+    int rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
+                  conn->ip_addr->ai_addrlen);
     if(rc) {
       failf(conn->data, "bind() failed; %s",
             Curl_strerror(conn, SOCKERRNO));
@@ -1148,8 +1147,11 @@
     case TFTP_EVENT_ERROR:
     {
       unsigned short error = getrpacketblock(&state->rpacket);
+      char *str = (char *)state->rpacket.data + 4;
+      size_t strn = state->rbytes - 4;
       state->error = (tftp_error_t)error;
-      infof(data, "%s\n", (const char *)state->rpacket.data + 4);
+      if(Curl_strnlen(str, strn) < strn)
+        infof(data, "TFTP error: %s\n", str);
       break;
     }
     case TFTP_EVENT_ACK:
@@ -1221,7 +1223,6 @@
  **********************************************************/
 static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
 {
-  int                   rc;
   tftp_event_t          event;
   CURLcode              result = CURLE_OK;
   struct Curl_easy  *data = conn->data;
@@ -1245,7 +1246,7 @@
   }
   else {
     /* no timeouts to handle, check our socket */
-    rc = SOCKET_READABLE(state->sockfd, 0);
+    int rc = SOCKET_READABLE(state->sockfd, 0);
 
     if(rc == -1) {
       /* bail out */
@@ -1368,7 +1369,6 @@
 {
   struct Curl_easy *data = conn->data;
   char *type;
-  char command;
 
   conn->socktype = SOCK_DGRAM;   /* UDP datagram based */
 
@@ -1380,6 +1380,7 @@
     type = strstr(conn->host.rawalloc, ";mode=");
 
   if(type) {
+    char command;
     *type = 0;                   /* it was in the middle of the hostname */
     command = Curl_raw_toupper(type[6]);
 
diff --git a/Utilities/cmcurl/lib/transfer.c b/Utilities/cmcurl/lib/transfer.c
index 131f2dc..7159d5c 100644
--- a/Utilities/cmcurl/lib/transfer.c
+++ b/Utilities/cmcurl/lib/transfer.c
@@ -106,15 +106,26 @@
 }
 #endif
 
+CURLcode Curl_get_upload_buffer(struct Curl_easy *data)
+{
+  if(!data->state.ulbuf) {
+    data->state.ulbuf = malloc(data->set.upload_buffer_size);
+    if(!data->state.ulbuf)
+      return CURLE_OUT_OF_MEMORY;
+  }
+  return CURLE_OK;
+}
+
 /*
  * This function will call the read callback to fill our buffer with data
  * to upload.
  */
-CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
+CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
+                             size_t *nreadp)
 {
   struct Curl_easy *data = conn->data;
-  size_t buffersize = (size_t)bytes;
-  int nread;
+  size_t buffersize = bytes;
+  size_t nread;
 #ifdef CURL_DOES_CONVERSIONS
   bool sending_http_headers = FALSE;
 
@@ -134,11 +145,9 @@
     data->req.upload_fromhere += (8 + 2); /* 32bit hex + CRLF */
   }
 
-  /* this function returns a size_t, so we typecast to int to prevent warnings
-     with picky compilers */
   Curl_set_in_callback(data, true);
-  nread = (int)data->state.fread_func(data->req.upload_fromhere, 1,
-                                      buffersize, data->state.in);
+  nread = data->state.fread_func(data->req.upload_fromhere, 1,
+                                 buffersize, data->state.in);
   Curl_set_in_callback(data, false);
 
   if(nread == CURL_READFUNC_ABORT) {
@@ -167,7 +176,7 @@
 
     return CURLE_OK; /* nothing was read */
   }
-  else if((size_t)nread > buffersize) {
+  else if(nread > buffersize) {
     /* the read function returned a too large value */
     *nreadp = 0;
     failf(data, "read function returned funny value");
@@ -226,13 +235,13 @@
 #ifdef CURL_DOES_CONVERSIONS
     {
       CURLcode result;
-      int length;
+      size_t length;
       if(data->set.prefer_ascii)
         /* translate the protocol and data */
         length = nread;
       else
         /* just translate the protocol portion */
-        length = (int)strlen(hexbuffer);
+        length = strlen(hexbuffer);
       result = Curl_convert_to_network(data, data->req.upload_fromhere,
                                        length);
       /* Curl_convert_to_network calls failf if unsuccessful */
@@ -247,7 +256,7 @@
       infof(data, "Signaling end of chunked upload via terminating chunk.\n");
     }
 
-    nread += (int)strlen(endofline_native); /* for the added end of line */
+    nread += strlen(endofline_native); /* for the added end of line */
   }
 #ifdef CURL_DOES_CONVERSIONS
   else if((data->set.prefer_ascii) && (!sending_http_headers)) {
@@ -444,7 +453,6 @@
   CURLcode result = CURLE_OK;
   ssize_t nread; /* number of bytes read */
   size_t excess = 0; /* excess bytes read */
-  bool is_empty_data = FALSE;
   bool readmore = FALSE; /* used by RTP to signal for more data */
   int maxloops = 100;
 
@@ -454,6 +462,7 @@
   /* This is where we loop until we have read everything there is to
      read or we get a CURLE_AGAIN */
   do {
+    bool is_empty_data = FALSE;
     size_t buffersize = data->set.buffer_size;
     size_t bytestoread = buffersize;
 
@@ -660,14 +669,14 @@
       if(data->set.verbose) {
         if(k->badheader) {
           Curl_debug(data, CURLINFO_DATA_IN, data->state.headerbuff,
-                     (size_t)k->hbuflen, conn);
+                     (size_t)k->hbuflen);
           if(k->badheader == HEADER_PARTHEADER)
             Curl_debug(data, CURLINFO_DATA_IN,
-                       k->str, (size_t)nread, conn);
+                       k->str, (size_t)nread);
         }
         else
           Curl_debug(data, CURLINFO_DATA_IN,
-                     k->str, (size_t)nread, conn);
+                     k->str, (size_t)nread);
       }
 
 #ifndef CURL_DISABLE_HTTP
@@ -797,7 +806,7 @@
                                            nread);
             }
           }
-          else
+          else if(!k->ignorebody)
             result = Curl_unencode_write(conn, k->writer_stack, k->str, nread);
         }
         k->badheader = HEADER_NORMAL; /* taken care of now */
@@ -869,6 +878,26 @@
   return CURLE_OK;
 }
 
+#ifdef WIN32
+#ifndef SIO_IDEAL_SEND_BACKLOG_QUERY
+#define SIO_IDEAL_SEND_BACKLOG_QUERY 0x4004747B
+#endif
+
+static void win_update_buffer_size(curl_socket_t sockfd)
+{
+  int result;
+  ULONG ideal;
+  DWORD ideallen;
+  result = WSAIoctl(sockfd, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0,
+                    &ideal, sizeof(ideal), &ideallen, 0, 0);
+  if(result == 0) {
+    setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF,
+               (const char *)&ideal, sizeof(ideal));
+  }
+}
+#else
+#define win_update_buffer_size(x)
+#endif
 
 /*
  * Send data to upload to the server, when the socket is writable.
@@ -894,13 +923,16 @@
     /* only read more data if there's no upload data already
        present in the upload buffer */
     if(0 == k->upload_present) {
+      result = Curl_get_upload_buffer(data);
+      if(result)
+        return result;
       /* init the "upload from here" pointer */
-      k->upload_fromhere = data->state.uploadbuffer;
+      k->upload_fromhere = data->state.ulbuf;
 
       if(!k->upload_done) {
         /* HTTP pollution, this should be written nicer to become more
            protocol agnostic. */
-        int fillcount;
+        size_t fillcount;
         struct HTTP *http = k->protop;
 
         if((k->exp100 == EXP100_SENDING_REQUEST) &&
@@ -931,7 +963,7 @@
         if(result)
           return result;
 
-        nread = (ssize_t)fillcount;
+        nread = fillcount;
       }
       else
         nread = 0; /* we're done uploading/reading */
@@ -959,7 +991,7 @@
          (data->set.crlf))) {
         /* Do we need to allocate a scratch buffer? */
         if(!data->state.scratch) {
-          data->state.scratch = malloc(2 * data->set.buffer_size);
+          data->state.scratch = malloc(2 * UPLOAD_BUFSIZE);
           if(!data->state.scratch) {
             failf(data, "Failed to alloc scratch buffer!");
 
@@ -1020,14 +1052,15 @@
                         k->upload_fromhere, /* buffer pointer */
                         k->upload_present,  /* buffer size */
                         &bytes_written);    /* actually sent */
-
     if(result)
       return result;
 
+    win_update_buffer_size(conn->writesockfd);
+
     if(data->set.verbose)
       /* show the data before we change the pointer upload_fromhere */
       Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere,
-                 (size_t)bytes_written, conn);
+                 (size_t)bytes_written);
 
     k->writebytecount += bytes_written;
 
@@ -1050,7 +1083,10 @@
     }
     else {
       /* we've uploaded that buffer now */
-      k->upload_fromhere = data->state.uploadbuffer;
+      result = Curl_get_upload_buffer(data);
+      if(result)
+        return result;
+      k->upload_fromhere = data->state.ulbuf;
       k->upload_present = 0; /* no more bytes left */
 
       if(k->upload_done) {
@@ -1482,7 +1518,7 @@
     switch(*ptr) {
     case '?':
       left = FALSE;
-      /* fall through */
+      /* FALLTHROUGH */
     default:
       if(urlchar_needs_escaping(*ptr))
         newlen += 2;
@@ -1527,7 +1563,7 @@
     switch(*iptr) {
     case '?':
       left = FALSE;
-      /* fall through */
+      /* FALLTHROUGH */
     default:
       if(urlchar_needs_escaping(*iptr)) {
         snprintf(optr, 4, "%%%02x", *iptr);
diff --git a/Utilities/cmcurl/lib/transfer.h b/Utilities/cmcurl/lib/transfer.h
index 9ba398d..9263e5b 100644
--- a/Utilities/cmcurl/lib/transfer.h
+++ b/Utilities/cmcurl/lib/transfer.h
@@ -51,9 +51,11 @@
                         curl_socket_t *socks,
                         int numsocks);
 CURLcode Curl_readrewind(struct connectdata *conn);
-CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp);
+CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
+                             size_t *nreadp);
 CURLcode Curl_retry_request(struct connectdata *conn, char **url);
 bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc);
+CURLcode Curl_get_upload_buffer(struct Curl_easy *data);
 
 /* This sets up a forthcoming transfer */
 void
diff --git a/Utilities/cmcurl/lib/url.c b/Utilities/cmcurl/lib/url.c
index 701f83a..f159008 100644
--- a/Utilities/cmcurl/lib/url.c
+++ b/Utilities/cmcurl/lib/url.c
@@ -127,7 +127,6 @@
 
 static void conn_free(struct connectdata *conn);
 static void free_fixed_hostname(struct hostname *host);
-static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke);
 static CURLcode parse_url_login(struct Curl_easy *data,
                                 struct connectdata *conn,
                                 char **userptr, char **passwdptr,
@@ -368,11 +367,9 @@
 
   Curl_safefree(data->state.buffer);
   Curl_safefree(data->state.headerbuff);
-
+  Curl_safefree(data->state.ulbuf);
   Curl_flush_cookies(data, 1);
-
   Curl_digest_cleanup(data);
-
   Curl_safefree(data->info.contenttype);
   Curl_safefree(data->info.wouldredirect);
 
@@ -535,6 +532,7 @@
   set->expect_100_timeout = 1000L; /* Wait for a second by default. */
   set->sep_headers = TRUE; /* separated header lists by default */
   set->buffer_size = READBUFFER_SIZE;
+  set->upload_buffer_size = UPLOAD_BUFSIZE;
   set->happy_eyeballs_timeout = CURL_HET_DEFAULT;
 
   Curl_http2_init_userset(set);
@@ -734,20 +732,23 @@
  * primary connection, like when freeing room in the connection cache or
  * killing of a dead old connection.
  *
+ * A connection needs an easy handle when closing down. We support this passed
+ * in separately since the connection to get closed here is often already
+ * disassociated from an easy handle.
+ *
  * This function MUST NOT reset state in the Curl_easy struct if that
  * isn't strictly bound to the life-time of *this* particular connection.
  *
  */
 
-CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
+CURLcode Curl_disconnect(struct Curl_easy *data,
+                         struct connectdata *conn, bool dead_connection)
 {
-  struct Curl_easy *data;
   if(!conn)
     return CURLE_OK; /* this is closed and fine already */
-  data = conn->data;
 
   if(!data) {
-    DEBUGF(fprintf(stderr, "DISCONNECT without easy handle, ignoring\n"));
+    DEBUGF(infof(data, "DISCONNECT without easy handle, ignoring\n"));
     return CURLE_OK;
   }
 
@@ -755,13 +756,12 @@
    * If this connection isn't marked to force-close, leave it open if there
    * are other users of it
    */
-  if(!conn->bits.close &&
-     (conn->send_pipe.size + conn->recv_pipe.size)) {
-    DEBUGF(infof(data, "Curl_disconnect, usecounter: %d\n",
-                 conn->send_pipe.size + conn->recv_pipe.size));
+  if(CONN_INUSE(conn) && !dead_connection) {
+    DEBUGF(infof(data, "Curl_disconnect when inuse: %zu\n", CONN_INUSE(conn)));
     return CURLE_OK;
   }
 
+  conn->data = data;
   if(conn->dns_entry != NULL) {
     Curl_resolv_unlock(data, conn->dns_entry);
     conn->dns_entry = NULL;
@@ -787,16 +787,12 @@
   free_fixed_hostname(&conn->http_proxy.host);
   free_fixed_hostname(&conn->socks_proxy.host);
 
+  DEBUGASSERT(conn->data == data);
+  /* this assumes that the pointer is still there after the connection was
+     detected from the cache */
   Curl_ssl_close(conn, FIRSTSOCKET);
 
-  /* Indicate to all handles on the pipe that we're dead */
-  if(Curl_pipeline_wanted(data->multi, CURLPIPE_ANY)) {
-    signalPipeClose(&conn->send_pipe, TRUE);
-    signalPipeClose(&conn->recv_pipe, TRUE);
-  }
-
   conn_free(conn);
-
   return CURLE_OK;
 }
 
@@ -848,6 +844,7 @@
   return avail;
 }
 
+/* Returns non-zero if a handle was removed */
 int Curl_removeHandleFromPipeline(struct Curl_easy *handle,
                                   struct curl_llist *pipeline)
 {
@@ -884,6 +881,16 @@
 static struct Curl_easy* gethandleathead(struct curl_llist *pipeline)
 {
   struct curl_llist_element *curr = pipeline->head;
+#ifdef DEBUGBUILD
+  {
+    struct curl_llist_element *p = pipeline->head;
+    while(p) {
+      struct Curl_easy *e = p->ptr;
+      DEBUGASSERT(GOOD_EASY_HANDLE(e));
+      p = p->next;
+    }
+  }
+#endif
   if(curr) {
     return (struct Curl_easy *) curr->ptr;
   }
@@ -896,41 +903,22 @@
 void Curl_getoff_all_pipelines(struct Curl_easy *data,
                                struct connectdata *conn)
 {
-  bool recv_head = (conn->readchannel_inuse &&
-                    Curl_recvpipe_head(data, conn));
-  bool send_head = (conn->writechannel_inuse &&
-                    Curl_sendpipe_head(data, conn));
-
-  if(Curl_removeHandleFromPipeline(data, &conn->recv_pipe) && recv_head)
-    Curl_pipeline_leave_read(conn);
-  if(Curl_removeHandleFromPipeline(data, &conn->send_pipe) && send_head)
-    Curl_pipeline_leave_write(conn);
-}
-
-static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke)
-{
-  struct curl_llist_element *curr;
-
-  if(!pipeline)
+  if(!conn->bundle)
     return;
+  if(conn->bundle->multiuse == BUNDLE_PIPELINING) {
+    bool recv_head = (conn->readchannel_inuse &&
+                      Curl_recvpipe_head(data, conn));
+    bool send_head = (conn->writechannel_inuse &&
+                      Curl_sendpipe_head(data, conn));
 
-  curr = pipeline->head;
-  while(curr) {
-    struct curl_llist_element *next = curr->next;
-    struct Curl_easy *data = (struct Curl_easy *) curr->ptr;
-
-#ifdef DEBUGBUILD /* debug-only code */
-    if(data->magic != CURLEASY_MAGIC_NUMBER) {
-      /* MAJOR BADNESS */
-      infof(data, "signalPipeClose() found BAAD easy handle\n");
-    }
-#endif
-
-    if(pipe_broke)
-      data->state.pipe_broke = TRUE;
-    Curl_multi_handlePipeBreak(data);
-    Curl_llist_remove(pipeline, curr, NULL);
-    curr = next;
+    if(Curl_removeHandleFromPipeline(data, &conn->recv_pipe) && recv_head)
+      Curl_pipeline_leave_read(conn);
+    if(Curl_removeHandleFromPipeline(data, &conn->send_pipe) && send_head)
+      Curl_pipeline_leave_write(conn);
+  }
+  else {
+    (void)Curl_removeHandleFromPipeline(data, &conn->recv_pipe);
+    (void)Curl_removeHandleFromPipeline(data, &conn->send_pipe);
   }
 }
 
@@ -959,12 +947,13 @@
                             struct Curl_easy *data)
 {
   size_t pipeLen = conn->send_pipe.size + conn->recv_pipe.size;
-  if(!pipeLen && !conn->inuse) {
+  if(!pipeLen && !CONN_INUSE(conn)) {
     /* The check for a dead socket makes sense only if there are no
        handles in pipeline and the connection isn't already marked in
        use */
     bool dead;
 
+    conn->data = data;
     if(conn->handler->connection_check) {
       /* The protocol has a special method for checking the state of the
          connection. Use it to check if the connection is dead. */
@@ -979,9 +968,9 @@
     }
 
     if(dead) {
-      conn->data = data;
       infof(data, "Connection %ld seems to be dead!\n", conn->connection_id);
       Curl_conncache_remove_conn(conn, FALSE);
+      conn->data = NULL; /* detach */
       return TRUE;
     }
   }
@@ -1025,7 +1014,7 @@
     while(Curl_conncache_foreach(data, data->state.conn_cache, &prune,
                                  call_extract_if_dead)) {
       /* disconnect it */
-      (void)Curl_disconnect(prune.extracted, /* dead_connection */TRUE);
+      (void)Curl_disconnect(data, prune.extracted, /* dead_connection */TRUE);
     }
     data->state.conn_cache->last_cleanup = now;
   }
@@ -1139,7 +1128,7 @@
 
       if(extract_if_dead(check, data)) {
         /* disconnect it */
-        (void)Curl_disconnect(check, /* dead_connection */TRUE);
+        (void)Curl_disconnect(data, check, /* dead_connection */TRUE);
         continue;
       }
 
@@ -1267,12 +1256,12 @@
         }
       }
 
-      if(!canpipe && check->inuse)
+      if(!canpipe && CONN_INUSE(check))
         /* this request can't be pipelined but the checked connection is
            already in use so we skip it */
         continue;
 
-      if((check->inuse) && (check->data->multi != needle->data->multi))
+      if(CONN_INUSE(check) && (check->data->multi != needle->data->multi))
         /* this could be subject for pipeline/multiplex use, but only
            if they belong to the same multi handle */
         continue;
@@ -1464,7 +1453,7 @@
 
   if(chosen) {
     /* mark it as used before releasing the lock */
-    chosen->inuse = TRUE;
+    chosen->data = data; /* own it! */
     Curl_conncache_unlock(needle);
     *usethis = chosen;
     return TRUE; /* yes, we found one to use! */
@@ -1554,7 +1543,11 @@
 {
   if(conn->handler->proto_getsock)
     return conn->handler->proto_getsock(conn, socks, numsocks);
-  return GETSOCK_BLANK;
+  /* Backup getsock logic. Since there is a live socket in use, we must wait
+     for it or it will be removed from watching when the multi_socket API is
+     used. */
+  socks[0] = conn->sock[FIRSTSOCKET];
+  return GETSOCK_READSOCK(0) | GETSOCK_WRITESOCK(0);
 }
 
 int Curl_doing_getsock(struct connectdata *conn,
@@ -1999,7 +1992,6 @@
   char *fragment;
   char *path = data->state.path;
   char *query;
-  int i;
   int rc;
   const char *protop = "";
   CURLcode result;
@@ -2051,6 +2043,7 @@
     ; /* do nothing */
   }
   else { /* check for a scheme */
+    int i;
     for(i = 0; i < 16 && data->change.url[i]; ++i) {
       if(data->change.url[i] == '/')
         break;
@@ -2203,7 +2196,7 @@
       size_t s = strlen(slashbuf);
       protop = protobuf;
       if(s != 2) {
-        infof(data, "Unwillingly accepted illegal URL using %d slash%s!\n",
+        infof(data, "Unwillingly accepted illegal URL using %zu slash%s!\n",
               s, s>1?"es":"");
 
         if(data->change.url_alloc)
@@ -2449,7 +2442,7 @@
       free(s->range);
 
     if(s->resume_from)
-      s->range = aprintf("%" CURL_FORMAT_CURL_OFF_TU "-", s->resume_from);
+      s->range = aprintf("%" CURL_FORMAT_CURL_OFF_T "-", s->resume_from);
     else
       s->range = strdup(data->set.str[STRING_SET_RANGE]);
 
@@ -2481,18 +2474,6 @@
 {
   const struct Curl_handler * p;
   CURLcode result;
-  struct Curl_easy *data = conn->data;
-
-  /* in some case in the multi state-machine, we go back to the CONNECT state
-     and then a second (or third or...) call to this function will be made
-     without doing a DISCONNECT or DONE in between (since the connection is
-     yet in place) and therefore this function needs to first make sure
-     there's no lingering previous data allocated. */
-  Curl_free_request_state(data);
-
-  memset(&data->req, 0, sizeof(struct SingleRequest));
-  data->req.maxdownload = -1;
-
   conn->socktype = SOCK_STREAM; /* most of them are TCP streams */
 
   /* Perform setup complement if some. */
@@ -2539,14 +2520,13 @@
    *   not be proxied, or an asterisk to override
    *   all proxy variables)
    */
-  size_t tok_start;
-  size_t tok_end;
-  const char *separator = ", ";
-  size_t no_proxy_len;
-  size_t namelen;
-  char *endptr;
-
   if(no_proxy && no_proxy[0]) {
+    size_t tok_start;
+    size_t tok_end;
+    const char *separator = ", ";
+    size_t no_proxy_len;
+    size_t namelen;
+    char *endptr;
     if(strcasecompare("*", no_proxy)) {
       return TRUE;
     }
@@ -3166,6 +3146,13 @@
   if(userp) {
     char *newname;
 
+    if(data->set.disallow_username_in_url) {
+      failf(data, "Option DISALLOW_USERNAME_IN_URL is set "
+                  "and url contains username.");
+      result = CURLE_LOGIN_DENIED;
+      goto out;
+    }
+
     /* We have a user in the URL */
     conn->bits.userpwd_in_url = TRUE;
     conn->bits.user_passwd = TRUE; /* enable user+password */
@@ -3982,6 +3969,7 @@
 
   Curl_safefree(old_conn->user);
   Curl_safefree(old_conn->passwd);
+  Curl_safefree(old_conn->options);
   Curl_safefree(old_conn->http_proxy.user);
   Curl_safefree(old_conn->socks_proxy.user);
   Curl_safefree(old_conn->http_proxy.passwd);
@@ -4297,7 +4285,9 @@
       conn->data = data;
       conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
 
-      Curl_conncache_add_conn(data->state.conn_cache, conn);
+      result = Curl_conncache_add_conn(data->state.conn_cache, conn);
+      if(result)
+        goto out;
 
       /*
        * Setup whatever necessary for a resumed transfer
@@ -4343,6 +4333,10 @@
     data->set.str[STRING_SSL_CIPHER_LIST_ORIG];
   data->set.proxy_ssl.primary.cipher_list =
     data->set.str[STRING_SSL_CIPHER_LIST_PROXY];
+  data->set.ssl.primary.cipher_list13 =
+    data->set.str[STRING_SSL_CIPHER13_LIST_ORIG];
+  data->set.proxy_ssl.primary.cipher_list13 =
+    data->set.str[STRING_SSL_CIPHER13_LIST_PROXY];
 
   data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG];
   data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
@@ -4468,13 +4462,11 @@
         conn_candidate = Curl_conncache_extract_bundle(data, bundle);
         Curl_conncache_unlock(conn);
 
-        if(conn_candidate) {
-          /* Set the connection's owner correctly, then kill it */
-          conn_candidate->data = data;
-          (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE);
-        }
+        if(conn_candidate)
+          (void)Curl_disconnect(data, conn_candidate,
+                                /* dead_connection */ FALSE);
         else {
-          infof(data, "No more connections allowed to host: %d\n",
+          infof(data, "No more connections allowed to host: %zu\n",
                 max_host_connections);
           connections_available = FALSE;
         }
@@ -4491,12 +4483,9 @@
 
       /* The cache is full. Let's see if we can kill a connection. */
       conn_candidate = Curl_conncache_extract_oldest(data);
-
-      if(conn_candidate) {
-        /* Set the connection's owner correctly, then kill it */
-        conn_candidate->data = data;
-        (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE);
-      }
+      if(conn_candidate)
+        (void)Curl_disconnect(data, conn_candidate,
+                              /* dead_connection */ FALSE);
       else {
         infof(data, "No connections available in cache\n");
         connections_available = FALSE;
@@ -4513,14 +4502,13 @@
       goto out;
     }
     else {
-      /* Mark the connection as used, before we add it */
-      conn->inuse = TRUE;
-
       /*
        * This is a brand new connection, so let's store it in the connection
        * cache of ours!
        */
-      Curl_conncache_add_conn(data->state.conn_cache, conn);
+      result = Curl_conncache_add_conn(data->state.conn_cache, conn);
+      if(result)
+        goto out;
     }
 
 #if defined(USE_NTLM)
@@ -4656,12 +4644,16 @@
 
   *asyncp = FALSE; /* assume synchronous resolves by default */
 
+  /* init the single-transfer specific data */
+  Curl_free_request_state(data);
+  memset(&data->req, 0, sizeof(struct SingleRequest));
+  data->req.maxdownload = -1;
+
   /* call the stuff that needs to be called */
   result = create_conn(data, in_connect, asyncp);
 
   if(!result) {
-    /* no error */
-    if((*in_connect)->send_pipe.size || (*in_connect)->recv_pipe.size)
+    if(CONN_INUSE(*in_connect))
       /* pipelining */
       *protocol_done = TRUE;
     else if(!*asyncp) {
@@ -4676,12 +4668,11 @@
     *in_connect = NULL;
     return result;
   }
-
-  if(result && *in_connect) {
-    /* We're not allowed to return failure with memory left allocated
-       in the connectdata struct, free those here */
-    Curl_disconnect(*in_connect, FALSE); /* close the connection */
-    *in_connect = NULL;           /* return a NULL */
+  else if(result && *in_connect) {
+    /* We're not allowed to return failure with memory left allocated in the
+       connectdata struct, free those here */
+    Curl_disconnect(data, *in_connect, TRUE);
+    *in_connect = NULL; /* return a NULL */
   }
 
   return result;
@@ -4701,16 +4692,18 @@
 {
   struct SingleRequest *k = &data->req;
 
-  conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to
-                                 use */
+  if(conn) {
+    conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to
+                                   use */
+    /* if the protocol used doesn't support wildcards, switch it off */
+    if(data->state.wildcardmatch &&
+       !(conn->handler->flags & PROTOPT_WILDCARD))
+      data->state.wildcardmatch = FALSE;
+  }
 
   data->state.done = FALSE; /* *_done() is not called yet */
   data->state.expect100header = FALSE;
 
-  /* if the protocol used doesn't support wildcards, switch it off */
-  if(data->state.wildcardmatch &&
-     !(conn->handler->flags & PROTOPT_WILDCARD))
-    data->state.wildcardmatch = FALSE;
 
   if(data->set.opt_no_body)
     /* in HTTP lingo, no body means using the HEAD request... */
diff --git a/Utilities/cmcurl/lib/url.h b/Utilities/cmcurl/lib/url.h
index a70bd54..ef3ebf0 100644
--- a/Utilities/cmcurl/lib/url.h
+++ b/Utilities/cmcurl/lib/url.h
@@ -39,7 +39,8 @@
 CURLcode Curl_close(struct Curl_easy *data); /* opposite of curl_open() */
 CURLcode Curl_connect(struct Curl_easy *, struct connectdata **,
                       bool *async, bool *protocol_connect);
-CURLcode Curl_disconnect(struct connectdata *, bool dead_connection);
+CURLcode Curl_disconnect(struct Curl_easy *data,
+                         struct connectdata *, bool dead_connection);
 CURLcode Curl_protocol_connect(struct connectdata *conn, bool *done);
 CURLcode Curl_protocol_connecting(struct connectdata *conn, bool *done);
 CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done);
diff --git a/Utilities/cmcurl/lib/urldata.h b/Utilities/cmcurl/lib/urldata.h
index 7fae00f..67db3b2 100644
--- a/Utilities/cmcurl/lib/urldata.h
+++ b/Utilities/cmcurl/lib/urldata.h
@@ -80,6 +80,7 @@
 #define RESP_TIMEOUT (1800*1000)
 
 #include "cookie.h"
+#include "psl.h"
 #include "formdata.h"
 
 #ifdef HAVE_NETINET_IN_H
@@ -142,8 +143,13 @@
 #endif /* HAVE_LIBSSH2_H */
 
 /* The upload buffer size, should not be smaller than CURL_MAX_WRITE_SIZE, as
-   it needs to hold a full buffer as could be sent in a write callback */
-#define UPLOAD_BUFSIZE CURL_MAX_WRITE_SIZE
+   it needs to hold a full buffer as could be sent in a write callback.
+
+   The size was 16KB for many years but was bumped to 64KB because it makes
+   libcurl able to do significantly faster uploads in some circumstances. Even
+   larger buffers can help further, but this is deemed a fair memory/speed
+   compromise. */
+#define UPLOAD_BUFSIZE 65536
 
 /* The "master buffer" is for HTTP pipelining */
 #define MASTERBUF_SIZE 16384
@@ -156,11 +162,6 @@
 #define GOOD_EASY_HANDLE(x) \
   ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))
 
-/* Some convenience macros to get the larger/smaller value out of two given.
-   We prefix with CURL to prevent name collisions. */
-#define CURLMAX(x,y) ((x)>(y)?(x):(y))
-#define CURLMIN(x,y) ((x)<(y)?(x):(y))
-
 #ifdef HAVE_GSSAPI
 /* Types needed for krb5-ftp connections */
 struct krb5buffer {
@@ -226,6 +227,7 @@
   char *random_file;     /* path to file containing "random" data */
   char *egdsocket;       /* path to file containing the EGD daemon socket */
   char *cipher_list;     /* list of ciphers to use */
+  char *cipher_list13;   /* list of TLS 1.3 cipher suites to use */
 };
 
 struct ssl_config_data {
@@ -779,11 +781,12 @@
   curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
   void *closesocket_client;
 
-  bool inuse; /* This is a marker for the connection cache logic. If this is
-                 TRUE this handle is being used by one or more easy handles
-                 and can only used by any other easy handle without careful
-                 consideration (== only for pipelining/multiplexing) and it
-                 cannot be used by another multi handle! */
+  /* This is used by the connection cache logic. If this returns TRUE, this
+     handle is being used by one or more easy handles and can only used by any
+     other easy handle without careful consideration (== only for
+     pipelining/multiplexing) and it cannot be used by another multi
+     handle! */
+#define CONN_INUSE(c) ((c)->send_pipe.size + (c)->recv_pipe.size)
 
   /**** Fields set when inited and not modified again */
   long connection_id; /* Contains a unique number to make it easier to
@@ -1222,7 +1225,7 @@
   size_t headersize;   /* size of the allocation */
 
   char *buffer; /* download buffer */
-  char uploadbuffer[UPLOAD_BUFSIZE + 1]; /* upload buffer */
+  char *ulbuf; /* alloced upload buffer or NULL */
   curl_off_t current_speed;  /* the ProgressShow() function sets this,
                                 bytes / second */
   bool this_is_a_follow; /* this is a followed Location: request */
@@ -1265,7 +1268,7 @@
   void *resolver; /* resolver state, if it is used in the URL state -
                      ares_channel f.e. */
 
-#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
+#if defined(USE_OPENSSL)
   /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
   void *engine;
 #endif /* USE_OPENSSL */
@@ -1284,9 +1287,6 @@
                             involved in this request */
   bool expect100header;  /* TRUE if we added Expect: 100-continue */
 
-  bool pipe_broke; /* TRUE if the connection we were pipelined on broke
-                      and we need to restart from the beginning */
-
 #if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \
     !defined(__SYMBIAN32__)
 /* do FTP line-end conversions on most platforms */
@@ -1346,7 +1346,7 @@
   char *url;        /* work URL, copied from UserDefined */
   bool url_alloc;   /* URL string is malloc()'ed */
   char *referer;    /* referer string */
-  bool referer_alloc; /* referer sting is malloc()ed */
+  bool referer_alloc; /* referer string is malloc()ed */
   struct curl_slist *cookielist; /* list of cookie files set by
                                     curl_easy_setopt(COOKIEFILE) calls */
   struct curl_slist *resolve; /* set to point to the set.resolve list when
@@ -1400,6 +1400,8 @@
   STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
   STRING_SSL_CIPHER_LIST_ORIG, /* list of ciphers to use */
   STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
+  STRING_SSL_CIPHER13_LIST_ORIG, /* list of TLS 1.3 ciphers to use */
+  STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */
   STRING_SSL_EGDSOCKET,   /* path to file containing the EGD daemon socket */
   STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */
   STRING_USERAGENT,       /* User-Agent string */
@@ -1407,6 +1409,7 @@
   STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */
   STRING_SSL_ISSUERCERT_ORIG, /* issuer cert file to check certificate */
   STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
+  STRING_SSL_ENGINE,      /* name of ssl engine */
   STRING_USERNAME,        /* <username>, if used */
   STRING_PASSWORD,        /* <password>, if used */
   STRING_OPTIONS,         /* <options>, if used */
@@ -1559,6 +1562,8 @@
   curl_proxytype proxytype; /* what kind of proxy that is in use */
   long dns_cache_timeout; /* DNS cache timeout */
   long buffer_size;      /* size of receive buffer to use */
+  long upload_buffer_size; /* size of upload buffer to use,
+                              keep it >= CURL_MAX_WRITE_SIZE */
   void *private_data; /* application-private data */
 
   struct curl_slist *http200aliases; /* linked list of aliases for http200 */
@@ -1581,8 +1586,6 @@
 /* Here follows boolean settings that define how to behave during
    this session. They are STATIC, set by libcurl users or at least initially
    and they don't change during operations. */
-
-  bool printhost;        /* printing host name in debug info */
   bool get_filetime;     /* get the time and get of the remote file */
   bool tunnel_thru_httpproxy; /* use CONNECT through a HTTP proxy */
   bool prefer_ascii;     /* ASCII rather than binary */
@@ -1676,7 +1679,7 @@
   bool stream_depends_e; /* set or don't set the Exclusive bit */
   int stream_weight;
 
-  bool haproxyprotocol; /* whether to send HAProxy PROXY protocol header */
+  bool haproxyprotocol; /* whether to send HAProxy PROXY protocol v1 header */
 
   struct Curl_http2_dep *stream_dependents;
 
@@ -1685,6 +1688,7 @@
   curl_resolver_start_callback resolver_start; /* optional callback called
                                                   before resolver start */
   void *resolver_start_client; /* pointer to pass to resolver start callback */
+  bool disallow_username_in_url; /* disallow username in url */
 };
 
 struct Names {
@@ -1736,6 +1740,9 @@
                                     struct to which this "belongs" when used
                                     by the easy interface */
   struct Curl_share *share;    /* Share, handles global variable mutexing */
+#ifdef USE_LIBPSL
+  struct PslCache *psl;        /* The associated PSL cache. */
+#endif
   struct SingleRequest req;    /* Request-specific data */
   struct UserDefined set;      /* values set by the libcurl user */
   struct DynamicStatic change; /* possibly modified userdefined data */
diff --git a/Utilities/cmcurl/lib/vauth/digest.c b/Utilities/cmcurl/lib/vauth/digest.c
index 131d9da..cc6f169 100644
--- a/Utilities/cmcurl/lib/vauth/digest.c
+++ b/Utilities/cmcurl/lib/vauth/digest.c
@@ -158,7 +158,7 @@
 /* Perform quoted-string escaping as described in RFC2616 and its errata */
 static char *auth_digest_string_quoted(const char *source)
 {
-  char *dest, *d;
+  char *dest;
   const char *s = source;
   size_t n = 1; /* null terminator */
 
@@ -173,8 +173,8 @@
 
   dest = malloc(n);
   if(dest) {
+    char *d = dest;
     s = source;
-    d = dest;
     while(*s) {
       if(*s == '"' || *s == '\\') {
         *d++ = '\\';
@@ -696,7 +696,6 @@
   unsigned char ha1[65];    /* 64 digits and 1 zero byte */
   unsigned char ha2[65];    /* 64 digits and 1 zero byte */
   char userh[65];
-  char cnoncebuf[33];
   char *cnonce = NULL;
   size_t cnonce_sz = 0;
   char *userp_quoted;
@@ -707,6 +706,7 @@
     digest->nc = 1;
 
   if(!digest->cnonce) {
+    char cnoncebuf[33];
     result = Curl_rand_hex(data, (unsigned char *)cnoncebuf,
                            sizeof(cnoncebuf));
     if(result)
diff --git a/Utilities/cmcurl/lib/version.c b/Utilities/cmcurl/lib/version.c
index 5b0d05a..05c2cd8 100644
--- a/Utilities/cmcurl/lib/version.c
+++ b/Utilities/cmcurl/lib/version.c
@@ -445,7 +445,7 @@
 
 #ifdef HAVE_BROTLI
   version_info.brotli_ver_num = BrotliDecoderVersion();
-  brotli_version(brotli_buffer, sizeof brotli_buffer);
+  brotli_version(brotli_buffer, sizeof(brotli_buffer));
   version_info.brotli_version = brotli_buffer;
 #endif
 
diff --git a/Utilities/cmcurl/lib/vtls/axtls.c b/Utilities/cmcurl/lib/vtls/axtls.c
index 5ed898b..b262392 100644
--- a/Utilities/cmcurl/lib/vtls/axtls.c
+++ b/Utilities/cmcurl/lib/vtls/axtls.c
@@ -29,6 +29,11 @@
 #include "curl_setup.h"
 
 #ifdef USE_AXTLS
+
+#error axTLS support has been disabled in curl due to doubts about quality,
+#error user dedication and a lack of use/testing. We urge users to consider
+#error using a more established TLS backend instead.
+
 #include <axTLS/config.h>
 #include <axTLS/ssl.h>
 #include "axtls.h"
diff --git a/Utilities/cmcurl/lib/vtls/cyassl.c b/Utilities/cmcurl/lib/vtls/cyassl.c
index 20ce460..e10398a 100644
--- a/Utilities/cmcurl/lib/vtls/cyassl.c
+++ b/Utilities/cmcurl/lib/vtls/cyassl.c
@@ -569,7 +569,7 @@
       return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
     }
 
-    memset(&x509_parsed, 0, sizeof x509_parsed);
+    memset(&x509_parsed, 0, sizeof(x509_parsed));
     if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))
       return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
 
@@ -968,6 +968,8 @@
     return CURLE_FAILED_INIT;
   if(RNG_GenerateBlock(&rng, entropy, (unsigned)length))
     return CURLE_FAILED_INIT;
+  if(FreeRng(&rng))
+    return CURLE_FAILED_INIT;
   return CURLE_OK;
 }
 
diff --git a/Utilities/cmcurl/lib/vtls/darwinssl.c b/Utilities/cmcurl/lib/vtls/darwinssl.c
index 45fe49d..1aea0dc 100644
--- a/Utilities/cmcurl/lib/vtls/darwinssl.c
+++ b/Utilities/cmcurl/lib/vtls/darwinssl.c
@@ -1252,14 +1252,13 @@
       return CURLE_OK;
     case CURL_SSLVERSION_TLSv1_3:
       /* TLS 1.3 support first appeared in iOS 11 and macOS 10.13 */
-#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11
-      /* We can assume __builtin_available() will always work in the
-         10.13/11.0 SDK: */
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
       if(__builtin_available(macOS 10.13, iOS 11.0, *)) {
         *darwinver = kTLSProtocol13;
         return CURLE_OK;
       }
-#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */
+#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) &&
+          HAVE_BUILTIN_AVAILABLE == 1 */
       break;
   }
   return CURLE_SSL_CONNECT_ERROR;
@@ -1278,7 +1277,7 @@
   /* macOS 10.5-10.7 supported TLS 1.0 only.
      macOS 10.8 and later, and iOS 5 and later, added TLS 1.1 and 1.2.
      macOS 10.13 and later, and iOS 11 and later, added TLS 1.3. */
-#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
   if(__builtin_available(macOS 10.13, iOS 11.0, *)) {
     max_supported_version_by_os = CURL_SSLVERSION_MAX_TLSv1_3;
   }
@@ -1287,7 +1286,8 @@
   }
 #else
   max_supported_version_by_os = CURL_SSLVERSION_MAX_TLSv1_2;
-#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */
+#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) &&
+          HAVE_BUILTIN_AVAILABLE == 1 */
 
   switch(ssl_version) {
     case CURL_SSLVERSION_DEFAULT:
@@ -1430,7 +1430,7 @@
     case CURL_SSLVERSION_DEFAULT:
     case CURL_SSLVERSION_TLSv1:
       (void)SSLSetProtocolVersionMin(BACKEND->ssl_ctx, kTLSProtocol1);
-#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
       if(__builtin_available(macOS 10.13, iOS 11.0, *)) {
         (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kTLSProtocol13);
       }
@@ -1439,7 +1439,8 @@
       }
 #else
       (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kTLSProtocol12);
-#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */
+#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) &&
+          HAVE_BUILTIN_AVAILABLE == 1 */
       break;
     case CURL_SSLVERSION_TLSv1_0:
     case CURL_SSLVERSION_TLSv1_1:
@@ -1572,6 +1573,35 @@
   }
 #endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
 
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
+  if(conn->bits.tls_enable_alpn) {
+    if(__builtin_available(macOS 10.13.4, iOS 11, *)) {
+      CFMutableArrayRef alpnArr = CFArrayCreateMutable(NULL, 0,
+                                                       &kCFTypeArrayCallBacks);
+
+#ifdef USE_NGHTTP2
+      if(data->set.httpversion >= CURL_HTTP_VERSION_2 &&
+         (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) {
+        CFArrayAppendValue(alpnArr, CFSTR(NGHTTP2_PROTO_VERSION_ID));
+        infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID);
+      }
+#endif
+
+      CFArrayAppendValue(alpnArr, CFSTR(ALPN_HTTP_1_1));
+      infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
+
+      /* expects length prefixed preference ordered list of protocols in wire
+       * format
+       */
+      err = SSLSetALPNProtocols(BACKEND->ssl_ctx, alpnArr);
+      if(err != noErr)
+        infof(data, "WARNING: failed to set ALPN protocols; OSStatus %d\n",
+              err);
+      CFRelease(alpnArr);
+    }
+  }
+#endif
+
   if(SSL_SET_OPTION(key)) {
     infof(data, "WARNING: SSL: CURLOPT_SSLKEY is ignored by Secure "
           "Transport. The private key must be in the Keychain.\n");
@@ -2466,6 +2496,39 @@
         break;
     }
 
+#if(CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
+    if(conn->bits.tls_enable_alpn) {
+      if(__builtin_available(macOS 10.13.4, iOS 11, *)) {
+        CFArrayRef alpnArr = NULL;
+        CFStringRef chosenProtocol = NULL;
+        err = SSLCopyALPNProtocols(BACKEND->ssl_ctx, &alpnArr);
+
+        if(err == noErr && alpnArr && CFArrayGetCount(alpnArr) >= 1)
+          chosenProtocol = CFArrayGetValueAtIndex(alpnArr, 0);
+
+#ifdef USE_NGHTTP2
+        if(chosenProtocol &&
+           !CFStringCompare(chosenProtocol, CFSTR(NGHTTP2_PROTO_VERSION_ID),
+                            0)) {
+          conn->negnpn = CURL_HTTP_VERSION_2;
+        }
+        else
+#endif
+        if(chosenProtocol &&
+           !CFStringCompare(chosenProtocol, CFSTR(ALPN_HTTP_1_1), 0)) {
+          conn->negnpn = CURL_HTTP_VERSION_1_1;
+        }
+        else
+          infof(data, "ALPN, server did not agree to a protocol\n");
+
+        /* chosenProtocol is a reference to the string within alpnArr
+           and doesn't need to be freed separately */
+        if(alpnArr)
+          CFRelease(alpnArr);
+      }
+    }
+#endif
+
     return CURLE_OK;
   }
 }
diff --git a/Utilities/cmcurl/lib/vtls/gskit.c b/Utilities/cmcurl/lib/vtls/gskit.c
index b0856cd..a0b4960 100644
--- a/Utilities/cmcurl/lib/vtls/gskit.c
+++ b/Utilities/cmcurl/lib/vtls/gskit.c
@@ -328,7 +328,7 @@
      GSKit tokens are always shorter than their cipher names, allocated buffers
      will always be large enough to accommodate the result. */
   l = strlen(cipherlist) + 1;
-  memset((char *) ciphers, 0, sizeof ciphers);
+  memset((char *) ciphers, 0, sizeof(ciphers));
   for(i = 0; i < CURL_GSKPROTO_LAST; i++) {
     ciphers[i].buf = malloc(l);
     if(!ciphers[i].buf) {
@@ -536,18 +536,18 @@
   lfd = socket(AF_INET, SOCK_STREAM, 0);
   if(lfd < 0)
     return -1;
-  memset((char *) &addr1, 0, sizeof addr1);
+  memset((char *) &addr1, 0, sizeof(addr1));
   addr1.sin_family = AF_INET;
   addr1.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   addr1.sin_port = 0;
-  if(bind(lfd, (struct sockaddr *) &addr1, sizeof addr1) ||
+  if(bind(lfd, (struct sockaddr *) &addr1, sizeof(addr1)) ||
      listen(lfd, 2) < 0) {
     close(lfd);
     return -1;
   }
 
   /* Get the allocated port. */
-  len = sizeof addr1;
+  len = sizeof(addr1);
   if(getsockname(lfd, (struct sockaddr *) &addr1, &len) < 0) {
     close(lfd);
     return -1;
@@ -562,7 +562,7 @@
 
   /* Request unblocking connection to the listening socket. */
   curlx_nonblock(cfd, TRUE);
-  if(connect(cfd, (struct sockaddr *) &addr1, sizeof addr1) < 0 &&
+  if(connect(cfd, (struct sockaddr *) &addr1, sizeof(addr1)) < 0 &&
      errno != EINPROGRESS) {
     close(lfd);
     close(cfd);
@@ -570,7 +570,7 @@
   }
 
   /* Get the client dynamic port for intrusion check below. */
-  len = sizeof addr2;
+  len = sizeof(addr2);
   if(getsockname(cfd, (struct sockaddr *) &addr2, &len) < 0) {
     close(lfd);
     close(cfd);
@@ -580,7 +580,7 @@
   /* Accept the incoming connection and get the server socket. */
   curlx_nonblock(lfd, TRUE);
   for(;;) {
-    len = sizeof addr1;
+    len = sizeof(addr1);
     sfd = accept(lfd, (struct sockaddr *) &addr1, &len);
     if(sfd < 0) {
       close(lfd);
@@ -644,7 +644,7 @@
     /* Try getting data from HTTPS proxy and pipe it upstream. */
     n = 0;
     i = gsk_secure_soc_read(connproxyssl->backend->handle,
-                            buf, sizeof buf, &n);
+                            buf, sizeof(buf), &n);
     switch(i) {
     case GSK_OK:
       if(n) {
@@ -665,7 +665,7 @@
   if(FD_ISSET(BACKEND->remotefd, &fds_read) &&
      FD_ISSET(conn->sock[sockindex], &fds_write)) {
     /* Pipe data to HTTPS proxy. */
-    n = read(BACKEND->remotefd, buf, sizeof buf);
+    n = read(BACKEND->remotefd, buf, sizeof(buf));
     if(n < 0)
       return -1;
     if(n) {
@@ -864,13 +864,13 @@
     BACKEND->localfd = sockpair[0];
     BACKEND->remotefd = sockpair[1];
     setsockopt(BACKEND->localfd, SOL_SOCKET, SO_RCVBUF,
-               (void *) sobufsize, sizeof sobufsize);
+               (void *) sobufsize, sizeof(sobufsize));
     setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_RCVBUF,
-               (void *) sobufsize, sizeof sobufsize);
+               (void *) sobufsize, sizeof(sobufsize));
     setsockopt(BACKEND->localfd, SOL_SOCKET, SO_SNDBUF,
-               (void *) sobufsize, sizeof sobufsize);
+               (void *) sobufsize, sizeof(sobufsize));
     setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_SNDBUF,
-               (void *) sobufsize, sizeof sobufsize);
+               (void *) sobufsize, sizeof(sobufsize));
     curlx_nonblock(BACKEND->localfd, TRUE);
     curlx_nonblock(BACKEND->remotefd, TRUE);
   }
@@ -977,7 +977,7 @@
 
   if(!result) {
     /* Start handshake. Try asynchronous first. */
-    memset(&commarea, 0, sizeof commarea);
+    memset(&commarea, 0, sizeof(commarea));
     BACKEND->iocport = QsoCreateIOCompletionPort();
     if(BACKEND->iocport != -1) {
       result = gskit_status(data,
@@ -1333,11 +1333,11 @@
     return 0; /* connection has been closed */
 
   err = 0;
-  errlen = sizeof err;
+  errlen = sizeof(err);
 
   if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
                  (unsigned char *) &err, &errlen) ||
-     errlen != sizeof err || err)
+     errlen != sizeof(err) || err)
     return 0; /* connection has been closed */
 
   return -1;  /* connection status unknown */
diff --git a/Utilities/cmcurl/lib/vtls/nss.c b/Utilities/cmcurl/lib/vtls/nss.c
index 7cd450c..89f8183 100644
--- a/Utilities/cmcurl/lib/vtls/nss.c
+++ b/Utilities/cmcurl/lib/vtls/nss.c
@@ -394,7 +394,7 @@
 /* wrap 'ptr' as list node and tail-insert into 'list' */
 static CURLcode insert_wrapped_ptr(struct curl_llist *list, void *ptr)
 {
-  struct ptr_list_wrap *wrap = malloc(sizeof *wrap);
+  struct ptr_list_wrap *wrap = malloc(sizeof(*wrap));
   if(!wrap)
     return CURLE_OUT_OF_MEMORY;
 
@@ -914,11 +914,11 @@
   PRTime now;
   int i;
 
-  if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
-     SECSuccess && channel.length == sizeof channel &&
+  if(SSL_GetChannelInfo(sock, &channel, sizeof(channel)) ==
+     SECSuccess && channel.length == sizeof(channel) &&
      channel.cipherSuite) {
     if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
-                              &suite, sizeof suite) == SECSuccess) {
+                              &suite, sizeof(suite)) == SECSuccess) {
       infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
     }
   }
@@ -1345,7 +1345,8 @@
       return CURLE_OUT_OF_MEMORY;
 
     /* the default methods just call down to the lower I/O layer */
-    memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(), sizeof nspr_io_methods);
+    memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(),
+           sizeof(nspr_io_methods));
 
     /* override certain methods in the table by our wrappers */
     nspr_io_methods.recv  = nspr_io_recv;
diff --git a/Utilities/cmcurl/lib/vtls/openssl.c b/Utilities/cmcurl/lib/vtls/openssl.c
index f6a4bd3..a487f55 100644
--- a/Utilities/cmcurl/lib/vtls/openssl.c
+++ b/Utilities/cmcurl/lib/vtls/openssl.c
@@ -50,9 +50,6 @@
 #include "hostcheck.h"
 #include "curl_printf.h"
 #include <openssl/ssl.h>
-#ifdef HAVE_OPENSSL_ENGINE_H
-#include <openssl/engine.h>
-#endif
 #include <openssl/rand.h>
 #include <openssl/x509v3.h>
 #ifndef OPENSSL_NO_DSA
@@ -72,6 +69,12 @@
 #include <openssl/ocsp.h>
 #endif
 
+#if (OPENSSL_VERSION_NUMBER >= 0x10000000L) && /* 1.0.0 or later */     \
+  !defined(OPENSSL_NO_ENGINE)
+#define USE_OPENSSL_ENGINE
+#include <openssl/engine.h>
+#endif
+
 #include "warnless.h"
 #include "non-ascii.h" /* for Curl_convert_from_utf8 prototype */
 
@@ -83,7 +86,7 @@
 #error "OPENSSL_VERSION_NUMBER not defined"
 #endif
 
-#if defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
 #include <openssl/ui.h>
 #endif
 
@@ -166,6 +169,17 @@
 #define HAVE_KEYLOG_CALLBACK
 #endif
 
+/* Whether SSL_CTX_set_ciphersuites is available.
+ * OpenSSL: supported since 1.1.1 (commit a53b5be6a05)
+ * BoringSSL: no
+ * LibreSSL: no
+ */
+#if ((OPENSSL_VERSION_NUMBER >= 0x10101000L) && \
+     !defined(LIBRESSL_VERSION_NUMBER) &&       \
+     !defined(OPENSSL_IS_BORINGSSL))
+#define HAVE_SSL_CTX_SET_CIPHERSUITES
+#endif
+
 #if defined(LIBRESSL_VERSION_NUMBER)
 #define OSSL_PACKAGE "LibreSSL"
 #elif defined(OPENSSL_IS_BORINGSSL)
@@ -504,7 +518,7 @@
   return -1;
 }
 
-#if defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
 /*
  * Supply default password to the engine user interface conversation.
  * The password is passed by OpenSSL engine from ENGINE_load_private_key()
@@ -544,8 +558,20 @@
   }
   return (UI_method_get_writer(UI_OpenSSL()))(ui, uis);
 }
+
+/*
+ * Check if a given string is a PKCS#11 URI
+ */
+static bool is_pkcs11_uri(const char *string)
+{
+  return (string && strncasecompare(string, "pkcs11:", 7));
+}
+
 #endif
 
+static CURLcode Curl_ossl_set_engine(struct Curl_easy *data,
+                                     const char *engine);
+
 static
 int cert_stuff(struct connectdata *conn,
                SSL_CTX* ctx,
@@ -606,8 +632,18 @@
       }
       break;
     case SSL_FILETYPE_ENGINE:
-#if defined(HAVE_OPENSSL_ENGINE_H) && defined(ENGINE_CTRL_GET_CMD_FROM_NAME)
+#if defined(USE_OPENSSL_ENGINE) && defined(ENGINE_CTRL_GET_CMD_FROM_NAME)
       {
+        /* Implicitly use pkcs11 engine if none was provided and the
+         * cert_file is a PKCS#11 URI */
+        if(!data->state.engine) {
+          if(is_pkcs11_uri(cert_file)) {
+            if(Curl_ossl_set_engine(data, "pkcs11") != CURLE_OK) {
+              return 0;
+            }
+          }
+        }
+
         if(data->state.engine) {
           const char *cmd_name = "LOAD_CERT_CTRL";
           struct {
@@ -781,9 +817,20 @@
       }
       break;
     case SSL_FILETYPE_ENGINE:
-#ifdef HAVE_OPENSSL_ENGINE_H
+#ifdef USE_OPENSSL_ENGINE
       {                         /* XXXX still needs some work */
         EVP_PKEY *priv_key = NULL;
+
+        /* Implicitly use pkcs11 engine if none was provided and the
+         * key_file is a PKCS#11 URI */
+        if(!data->state.engine) {
+          if(is_pkcs11_uri(key_file)) {
+            if(Curl_ossl_set_engine(data, "pkcs11") != CURLE_OK) {
+              return 0;
+            }
+          }
+        }
+
         if(data->state.engine) {
           UI_METHOD *ui_method =
             UI_create_method((char *)"curl user interface");
@@ -1088,7 +1135,7 @@
 static CURLcode Curl_ossl_set_engine(struct Curl_easy *data,
                                      const char *engine)
 {
-#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
   ENGINE *e;
 
 #if OPENSSL_VERSION_NUMBER >= 0x00909000L
@@ -1133,7 +1180,7 @@
  */
 static CURLcode Curl_ossl_set_engine_default(struct Curl_easy *data)
 {
-#ifdef HAVE_OPENSSL_ENGINE_H
+#ifdef USE_OPENSSL_ENGINE
   if(data->state.engine) {
     if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
       infof(data, "set default crypto engine '%s'\n",
@@ -1156,7 +1203,7 @@
 static struct curl_slist *Curl_ossl_engines_list(struct Curl_easy *data)
 {
   struct curl_slist *list = NULL;
-#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
   struct curl_slist *beg;
   ENGINE *e;
 
@@ -1312,7 +1359,7 @@
  */
 static void Curl_ossl_close_all(struct Curl_easy *data)
 {
-#ifdef HAVE_OPENSSL_ENGINE_H
+#ifdef USE_OPENSSL_ENGINE
   if(data->state.engine) {
     ENGINE_finish(data->state.engine);
     ENGINE_free(data->state.engine);
@@ -1922,7 +1969,15 @@
     }
     else
 #endif
-    {
+    if(content_type == SSL3_RT_CHANGE_CIPHER_SPEC) {
+      msg_type = *(char *)buf;
+      msg_name = "Change cipher spec";
+    }
+    else if(content_type == SSL3_RT_ALERT) {
+      msg_type = (((char *)buf)[0] << 8) + ((char *)buf)[1];
+      msg_name = SSL_alert_desc_string_long(msg_type);
+    }
+    else {
       msg_type = *(char *)buf;
       msg_name = ssl_msg_type(ssl_ver, msg_type);
     }
@@ -1931,12 +1986,12 @@
                        verstr, direction?"OUT":"IN",
                        tls_rt_name, msg_name, msg_type);
     if(0 <= txt_len && (unsigned)txt_len < sizeof(ssl_buf)) {
-      Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len, NULL);
+      Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len);
     }
   }
 
   Curl_debug(data, (direction == 1) ? CURLINFO_SSL_DATA_OUT :
-             CURLINFO_SSL_DATA_IN, (char *)buf, len, NULL);
+             CURLINFO_SSL_DATA_IN, (char *)buf, len);
   (void) ssl;
 }
 #endif
@@ -2064,10 +2119,6 @@
   long ssl_version = SSL_CONN_CONFIG(version);
   long ssl_version_max = SSL_CONN_CONFIG(version_max);
 
-  if(ssl_version_max == CURL_SSLVERSION_MAX_NONE) {
-    ssl_version_max = ssl_version << 16;
-  }
-
   switch(ssl_version) {
     case CURL_SSLVERSION_TLSv1_3:
 #ifdef TLS1_3_VERSION
@@ -2099,8 +2150,7 @@
 #endif
       /* FALLTHROUGH */
     case CURL_SSLVERSION_TLSv1_0:
-      *ctx_options |= SSL_OP_NO_SSLv2;
-      *ctx_options |= SSL_OP_NO_SSLv3;
+    case CURL_SSLVERSION_TLSv1:
       break;
   }
 
@@ -2116,12 +2166,12 @@
 #endif
       /* FALLTHROUGH */
     case CURL_SSLVERSION_MAX_TLSv1_2:
-    case CURL_SSLVERSION_MAX_DEFAULT:
 #ifdef TLS1_3_VERSION
       *ctx_options |= SSL_OP_NO_TLSv1_3;
 #endif
       break;
     case CURL_SSLVERSION_MAX_TLSv1_3:
+    case CURL_SSLVERSION_MAX_DEFAULT:
 #ifdef TLS1_3_VERSION
       break;
 #else
@@ -2305,11 +2355,6 @@
 
   switch(ssl_version) {
   case CURL_SSLVERSION_SSLv3:
-#ifdef USE_TLS_SRP
-    if(ssl_authtype == CURL_TLSAUTH_SRP) {
-      infof(data, "Set version TLSv1.x for SRP authorisation\n");
-    }
-#endif
     ctx_options |= SSL_OP_NO_SSLv2;
     ctx_options |= SSL_OP_NO_TLSv1;
 #if OPENSSL_VERSION_NUMBER >= 0x1000100FL
@@ -2323,21 +2368,20 @@
 
   case CURL_SSLVERSION_DEFAULT:
   case CURL_SSLVERSION_TLSv1:
-    ctx_options |= SSL_OP_NO_SSLv2;
-    ctx_options |= SSL_OP_NO_SSLv3;
-    break;
-
   case CURL_SSLVERSION_TLSv1_0:
   case CURL_SSLVERSION_TLSv1_1:
   case CURL_SSLVERSION_TLSv1_2:
   case CURL_SSLVERSION_TLSv1_3:
+    /* asking for any TLS version as the minimum, means no SSL versions
+       allowed */
+    ctx_options |= SSL_OP_NO_SSLv2;
+    ctx_options |= SSL_OP_NO_SSLv3;
     result = set_ssl_version_min_max(&ctx_options, conn, sockindex);
     if(result != CURLE_OK)
        return result;
     break;
 
   case CURL_SSLVERSION_SSLv2:
-#ifndef OPENSSL_NO_SSL2
     ctx_options |= SSL_OP_NO_SSLv3;
     ctx_options |= SSL_OP_NO_TLSv1;
 #if OPENSSL_VERSION_NUMBER >= 0x1000100FL
@@ -2348,10 +2392,6 @@
 #endif
 #endif
     break;
-#else
-    failf(data, OSSL_PACKAGE " was built without SSLv2 support");
-    return CURLE_NOT_BUILT_IN;
-#endif
 
   default:
     failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
@@ -2414,6 +2454,19 @@
     infof(data, "Cipher selection: %s\n", ciphers);
   }
 
+#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
+  {
+    char *ciphers13 = SSL_CONN_CONFIG(cipher_list13);
+    if(ciphers13) {
+      if(!SSL_CTX_set_ciphersuites(BACKEND->ctx, ciphers13)) {
+        failf(data, "failed setting TLS 1.3 cipher suite: %s", ciphers);
+        return CURLE_SSL_CIPHER;
+      }
+      infof(data, "TLS 1.3 cipher selection: %s\n", ciphers13);
+    }
+  }
+#endif
+
 #ifdef USE_TLS_SRP
   if(ssl_authtype == CURL_TLSAUTH_SRP) {
     char * const ssl_username = SSL_SET_OPTION(username);
@@ -3754,6 +3807,9 @@
   SSLSUPP_CERTINFO |
   SSLSUPP_PINNEDPUBKEY |
   SSLSUPP_SSL_CTX |
+#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
+  SSLSUPP_TLS13_CIPHERSUITES |
+#endif
   SSLSUPP_HTTPS_PROXY,
 
   sizeof(struct ssl_backend_data),
diff --git a/Utilities/cmcurl/lib/vtls/schannel.c b/Utilities/cmcurl/lib/vtls/schannel.c
index 2cfd5c1..8f6c301 100644
--- a/Utilities/cmcurl/lib/vtls/schannel.c
+++ b/Utilities/cmcurl/lib/vtls/schannel.c
@@ -90,11 +90,17 @@
 #endif
 #endif
 
+#if defined(CryptStringToBinary) && defined(CRYPT_STRING_HEX)
+#define HAS_CLIENT_CERT_PATH
+#endif
+
+#ifdef HAS_CLIENT_CERT_PATH
 #ifdef UNICODE
 #define CURL_CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_W
 #else
 #define CURL_CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_A
 #endif
+#endif
 
 #ifndef SP_PROT_SSL2_CLIENT
 #define SP_PROT_SSL2_CLIENT             0x00000008
@@ -199,6 +205,155 @@
   return CURLE_OK;
 }
 
+/*longest is 26, buffer is slightly bigger*/
+#define LONGEST_ALG_ID 32
+#define CIPHEROPTION(X) \
+if(strcmp(#X, tmp) == 0) \
+  return X
+
+static int
+get_alg_id_by_name(char *name)
+{
+  char tmp[LONGEST_ALG_ID] = { 0 };
+  char *nameEnd = strchr(name, ':');
+  size_t n = nameEnd ? min((size_t)(nameEnd - name), LONGEST_ALG_ID - 1) : \
+    min(strlen(name), LONGEST_ALG_ID - 1);
+  strncpy(tmp, name, n);
+  tmp[n] = 0;
+  CIPHEROPTION(CALG_MD2);
+  CIPHEROPTION(CALG_MD4);
+  CIPHEROPTION(CALG_MD5);
+  CIPHEROPTION(CALG_SHA);
+  CIPHEROPTION(CALG_SHA1);
+  CIPHEROPTION(CALG_MAC);
+  CIPHEROPTION(CALG_RSA_SIGN);
+  CIPHEROPTION(CALG_DSS_SIGN);
+/*ifdefs for the options that are defined conditionally in wincrypt.h*/
+#ifdef CALG_NO_SIGN
+  CIPHEROPTION(CALG_NO_SIGN);
+#endif
+  CIPHEROPTION(CALG_RSA_KEYX);
+  CIPHEROPTION(CALG_DES);
+#ifdef CALG_3DES_112
+  CIPHEROPTION(CALG_3DES_112);
+#endif
+  CIPHEROPTION(CALG_3DES);
+  CIPHEROPTION(CALG_DESX);
+  CIPHEROPTION(CALG_RC2);
+  CIPHEROPTION(CALG_RC4);
+  CIPHEROPTION(CALG_SEAL);
+#ifdef CALG_DH_SF
+  CIPHEROPTION(CALG_DH_SF);
+#endif
+  CIPHEROPTION(CALG_DH_EPHEM);
+#ifdef CALG_AGREEDKEY_ANY
+  CIPHEROPTION(CALG_AGREEDKEY_ANY);
+#endif
+#ifdef CALG_HUGHES_MD5
+  CIPHEROPTION(CALG_HUGHES_MD5);
+#endif
+  CIPHEROPTION(CALG_SKIPJACK);
+#ifdef CALG_TEK
+  CIPHEROPTION(CALG_TEK);
+#endif
+  CIPHEROPTION(CALG_CYLINK_MEK);
+  CIPHEROPTION(CALG_SSL3_SHAMD5);
+#ifdef CALG_SSL3_MASTER
+  CIPHEROPTION(CALG_SSL3_MASTER);
+#endif
+#ifdef CALG_SCHANNEL_MASTER_HASH
+  CIPHEROPTION(CALG_SCHANNEL_MASTER_HASH);
+#endif
+#ifdef CALG_SCHANNEL_MAC_KEY
+  CIPHEROPTION(CALG_SCHANNEL_MAC_KEY);
+#endif
+#ifdef CALG_SCHANNEL_ENC_KEY
+  CIPHEROPTION(CALG_SCHANNEL_ENC_KEY);
+#endif
+#ifdef CALG_PCT1_MASTER
+  CIPHEROPTION(CALG_PCT1_MASTER);
+#endif
+#ifdef CALG_SSL2_MASTER
+  CIPHEROPTION(CALG_SSL2_MASTER);
+#endif
+#ifdef CALG_TLS1_MASTER
+  CIPHEROPTION(CALG_TLS1_MASTER);
+#endif
+#ifdef CALG_RC5
+  CIPHEROPTION(CALG_RC5);
+#endif
+#ifdef CALG_HMAC
+  CIPHEROPTION(CALG_HMAC);
+#endif
+#if !defined(__W32API_MAJOR_VERSION) || \
+    !defined(__W32API_MINOR_VERSION) || \
+    defined(__MINGW64_VERSION_MAJOR) || \
+    (__W32API_MAJOR_VERSION > 5)     || \
+    ((__W32API_MAJOR_VERSION == 5) && (__W32API_MINOR_VERSION > 0))
+  /* CALG_TLS1PRF has a syntax error in MinGW's w32api up to version 5.0,
+     see https://osdn.net/projects/mingw/ticket/38391 */
+  CIPHEROPTION(CALG_TLS1PRF);
+#endif
+#ifdef CALG_HASH_REPLACE_OWF
+  CIPHEROPTION(CALG_HASH_REPLACE_OWF);
+#endif
+#ifdef CALG_AES_128
+  CIPHEROPTION(CALG_AES_128);
+#endif
+#ifdef CALG_AES_192
+  CIPHEROPTION(CALG_AES_192);
+#endif
+#ifdef CALG_AES_256
+  CIPHEROPTION(CALG_AES_256);
+#endif
+#ifdef CALG_AES
+  CIPHEROPTION(CALG_AES);
+#endif
+#ifdef CALG_SHA_256
+  CIPHEROPTION(CALG_SHA_256);
+#endif
+#ifdef CALG_SHA_384
+  CIPHEROPTION(CALG_SHA_384);
+#endif
+#ifdef CALG_SHA_512
+  CIPHEROPTION(CALG_SHA_512);
+#endif
+#ifdef CALG_ECDH
+  CIPHEROPTION(CALG_ECDH);
+#endif
+#ifdef CALG_ECMQV
+  CIPHEROPTION(CALG_ECMQV);
+#endif
+#ifdef CALG_ECDSA
+  CIPHEROPTION(CALG_ECDSA);
+#endif
+  return 0;
+}
+
+static CURLcode
+set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers)
+{
+  char *startCur = ciphers;
+  int algCount = 0;
+  static ALG_ID algIds[45]; /*There are 45 listed in the MS headers*/
+  while(startCur && (0 != *startCur) && (algCount < 45)) {
+    long alg = strtol(startCur, 0, 0);
+    if(!alg)
+      alg = get_alg_id_by_name(startCur);
+    if(alg)
+      algIds[algCount++] = alg;
+    else
+      return CURLE_SSL_CIPHER;
+    startCur = strchr(startCur, ':');
+    if(startCur)
+      startCur++;
+  }
+    schannel_cred->palgSupportedAlgs = algIds;
+  schannel_cred->cSupportedAlgs = algCount;
+  return CURLE_OK;
+}
+
+#ifdef HAS_CLIENT_CERT_PATH
 static CURLcode
 get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path,
                   TCHAR **thumbprint)
@@ -248,6 +403,7 @@
 
   return CURLE_OK;
 }
+#endif
 
 static CURLcode
 schannel_connect_step1(struct connectdata *conn, int sockindex)
@@ -299,10 +455,15 @@
 #endif
 
 #ifdef _WIN32_WCE
+#ifdef HAS_MANUAL_VERIFY_API
   /* certificate validation on CE doesn't seem to work right; we'll
    * do it following a more manual process. */
   BACKEND->use_manual_cred_validation = true;
 #else
+#error "compiler too old to support requisite manual cert verify for Win CE"
+#endif
+#else
+#ifdef HAS_MANUAL_VERIFY_API
   if(SSL_CONN_CONFIG(CAfile)) {
     if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT,
                                    VERSION_GREATER_THAN_EQUAL)) {
@@ -316,6 +477,12 @@
   }
   else
     BACKEND->use_manual_cred_validation = false;
+#else
+  if(SSL_CONN_CONFIG(CAfile)) {
+    failf(data, "schannel: CA cert support not built in");
+    return CURLE_NOT_BUILT_IN;
+  }
+#endif
 #endif
 
   BACKEND->cred = NULL;
@@ -341,9 +508,11 @@
     schannel_cred.dwVersion = SCHANNEL_CRED_VERSION;
 
     if(conn->ssl_config.verifypeer) {
+#ifdef HAS_MANUAL_VERIFY_API
       if(BACKEND->use_manual_cred_validation)
         schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION;
       else
+#endif
         schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION;
 
       /* TODO s/data->set.ssl.no_revoke/SSL_SET_OPTION(no_revoke)/g */
@@ -401,6 +570,16 @@
       return CURLE_SSL_CONNECT_ERROR;
     }
 
+    if(SSL_CONN_CONFIG(cipher_list)) {
+      result = set_ssl_ciphers(&schannel_cred, SSL_CONN_CONFIG(cipher_list));
+      if(CURLE_OK != result) {
+        failf(data, "Unable to set ciphers to passed via SSL_CONN_CONFIG");
+        return result;
+      }
+    }
+
+
+#ifdef HAS_CLIENT_CERT_PATH
     /* client certificate */
     if(data->set.ssl.cert) {
       DWORD cert_store_name;
@@ -417,14 +596,21 @@
       result = get_cert_location(cert_path, &cert_store_name,
                                  &cert_store_path, &cert_thumbprint_str);
       if(result != CURLE_OK) {
+        failf(data, "schannel: Failed to get certificate location for %s",
+              cert_path);
         Curl_unicodefree(cert_path);
         return result;
       }
 
-      cert_store = CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0,
-                                 (HCRYPTPROV)NULL,
-                                 cert_store_name, cert_store_path);
+      cert_store =
+        CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0,
+                      (HCRYPTPROV)NULL,
+                      CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name,
+                      cert_store_path);
       if(!cert_store) {
+        failf(data, "schannel: Failed to open cert store %x %s, "
+              "last error is %x",
+              cert_store_name, cert_store_path, GetLastError());
         Curl_unicodefree(cert_path);
         return CURLE_SSL_CONNECT_ERROR;
       }
@@ -453,6 +639,12 @@
 
       CertCloseStore(cert_store, 0);
     }
+#else
+    if(data->set.ssl.cert) {
+      failf(data, "schannel: client cert support not built in");
+      return CURLE_NOT_BUILT_IN;
+    }
+#endif
 
     /* allocate memory for the re-usable credential handle */
     BACKEND->cred = (struct curl_schannel_cred *)
@@ -877,9 +1069,11 @@
     }
   }
 
+#ifdef HAS_MANUAL_VERIFY_API
   if(conn->ssl_config.verifypeer && BACKEND->use_manual_cred_validation) {
     return verify_certificate(conn, sockindex);
   }
+#endif
 
   return CURLE_OK;
 }
@@ -1819,7 +2013,7 @@
 
     x509_der = (const char *)pCertContextServer->pbCertEncoded;
     x509_der_len = pCertContextServer->cbCertEncoded;
-    memset(&x509_parsed, 0, sizeof x509_parsed);
+    memset(&x509_parsed, 0, sizeof(x509_parsed));
     if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))
       break;
 
@@ -1870,7 +2064,8 @@
     if(!CryptCreateHash(hProv, algId, 0, 0, &hHash))
       break; /* failed */
 
-    if(!CryptHashData(hHash, (const BYTE*)input, (DWORD)inputlen, 0))
+    /* workaround for original MinGW, should be (const BYTE*) */
+    if(!CryptHashData(hHash, (BYTE*)input, (DWORD)inputlen, 0))
       break; /* failed */
 
     /* get hash size */
diff --git a/Utilities/cmcurl/lib/vtls/schannel.h b/Utilities/cmcurl/lib/vtls/schannel.h
index 4476900..51417af 100644
--- a/Utilities/cmcurl/lib/vtls/schannel.h
+++ b/Utilities/cmcurl/lib/vtls/schannel.h
@@ -32,12 +32,44 @@
 
 #include "urldata.h"
 
+/* <wincrypt.h> has been included via the above <schnlsp.h>.
+ * Or in case of ldap.c, it was included via <winldap.h>.
+ * And since <wincrypt.h> has this:
+ *   #define X509_NAME  ((LPCSTR) 7)
+ *
+ * And in BoringSSL's <openssl/base.h> there is:
+ *  typedef struct X509_name_st X509_NAME;
+ *  etc.
+ *
+ * this wil cause all kinds of C-preprocessing paste errors in
+ * BoringSSL's <openssl/x509.h>: So just undefine those defines here
+ * (and only here).
+ */
+#if defined(HAVE_BORINGSSL) || defined(OPENSSL_IS_BORINGSSL)
+# undef X509_NAME
+# undef X509_CERT_PAIR
+# undef X509_EXTENSIONS
+#endif
+
 extern const struct Curl_ssl Curl_ssl_schannel;
 
 CURLcode verify_certificate(struct connectdata *conn, int sockindex);
 
 /* structs to expose only in schannel.c and schannel_verify.c */
 #ifdef EXPOSE_SCHANNEL_INTERNAL_STRUCTS
+
+#ifdef __MINGW32__
+#include <_mingw.h>
+#ifdef __MINGW64_VERSION_MAJOR
+#define HAS_MANUAL_VERIFY_API
+#endif
+#else
+#include <wincrypt.h>
+#ifdef CERT_CHAIN_REVOCATION_CHECK_CHAIN
+#define HAS_MANUAL_VERIFY_API
+#endif
+#endif
+
 struct curl_schannel_cred {
   CredHandle cred_handle;
   TimeStamp time_stamp;
@@ -66,7 +98,9 @@
   bool recv_sspi_close_notify; /* true if connection closed by close_notify */
   bool recv_connection_closed; /* true if connection closed, regardless how */
   bool use_alpn; /* true if ALPN is used for this connection */
+#ifdef HAS_MANUAL_VERIFY_API
   bool use_manual_cred_validation; /* true if manual cred validation is used */
+#endif
 };
 #endif /* EXPOSE_SCHANNEL_INTERNAL_STRUCTS */
 
diff --git a/Utilities/cmcurl/lib/vtls/schannel_verify.c b/Utilities/cmcurl/lib/vtls/schannel_verify.c
index db187dd..5a7092a 100644
--- a/Utilities/cmcurl/lib/vtls/schannel_verify.c
+++ b/Utilities/cmcurl/lib/vtls/schannel_verify.c
@@ -30,14 +30,15 @@
 #include "curl_setup.h"
 
 #ifdef USE_SCHANNEL
-
-#define EXPOSE_SCHANNEL_INTERNAL_STRUCTS
-
 #ifndef USE_WINDOWS_SSPI
 #  error "Can't compile SCHANNEL support without SSPI."
 #endif
 
+#define EXPOSE_SCHANNEL_INTERNAL_STRUCTS
 #include "schannel.h"
+
+#ifdef HAS_MANUAL_VERIFY_API
+
 #include "vtls.h"
 #include "sendf.h"
 #include "strerror.h"
@@ -53,7 +54,7 @@
 #define BACKEND connssl->backend
 
 #define MAX_CAFILE_SIZE 1048576 /* 1 MiB */
-#define BEGIN_CERT "-----BEGIN CERTIFICATE-----\n"
+#define BEGIN_CERT "-----BEGIN CERTIFICATE-----"
 #define END_CERT "\n-----END CERTIFICATE-----"
 
 typedef struct {
@@ -71,6 +72,10 @@
   HCERTSTORE hExclusiveTrustedPeople;
 } CERT_CHAIN_ENGINE_CONFIG_WIN7, *PCERT_CHAIN_ENGINE_CONFIG_WIN7;
 
+static int is_cr_or_lf(char c)
+{
+  return c == '\r' || c == '\n';
+}
 
 static CURLcode add_certs_to_store(HCERTSTORE trust_store,
                                    const char *ca_file,
@@ -177,7 +182,7 @@
   current_ca_file_ptr = ca_file_buffer;
   while(more_certs && *current_ca_file_ptr != '\0') {
     char *begin_cert_ptr = strstr(current_ca_file_ptr, BEGIN_CERT);
-    if(!begin_cert_ptr) {
+    if(!begin_cert_ptr || !is_cr_or_lf(begin_cert_ptr[strlen(BEGIN_CERT)])) {
       more_certs = 0;
     }
     else {
@@ -209,7 +214,7 @@
                              NULL,
                              NULL,
                              NULL,
-                             &cert_context)) {
+                             (const void **)&cert_context)) {
 
           failf(data,
                 "schannel: failed to extract certificate from CA file "
@@ -548,4 +553,5 @@
   return result;
 }
 
+#endif /* HAS_MANUAL_VERIFY_API */
 #endif /* USE_SCHANNEL */
diff --git a/Utilities/cmcurl/lib/vtls/vtls.c b/Utilities/cmcurl/lib/vtls/vtls.c
index ee5bc7a..b61c640 100644
--- a/Utilities/cmcurl/lib/vtls/vtls.c
+++ b/Utilities/cmcurl/lib/vtls/vtls.c
@@ -96,7 +96,8 @@
      Curl_safe_strcasecompare(data->clientcert, needle->clientcert) &&
      Curl_safe_strcasecompare(data->random_file, needle->random_file) &&
      Curl_safe_strcasecompare(data->egdsocket, needle->egdsocket) &&
-     Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list))
+     Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list) &&
+     Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13))
     return TRUE;
 
   return FALSE;
@@ -119,6 +120,7 @@
   CLONE_STRING(random_file);
   CLONE_STRING(egdsocket);
   CLONE_STRING(cipher_list);
+  CLONE_STRING(cipher_list13);
 
   return TRUE;
 }
@@ -131,6 +133,7 @@
   Curl_safefree(sslc->random_file);
   Curl_safefree(sslc->egdsocket);
   Curl_safefree(sslc->cipher_list);
+  Curl_safefree(sslc->cipher_list13);
 }
 
 #ifdef USE_SSL
@@ -980,6 +983,14 @@
 }
 
 /*
+ * Check whether the SSL backend supports setting TLS 1.3 cipher suites
+ */
+bool Curl_ssl_tls13_ciphersuites(void)
+{
+  return Curl_ssl->supports & SSLSUPP_TLS13_CIPHERSUITES;
+}
+
+/*
  * Default implementations for unsupported functions.
  */
 
diff --git a/Utilities/cmcurl/lib/vtls/vtls.h b/Utilities/cmcurl/lib/vtls/vtls.h
index e7b87c4..40f9d74 100644
--- a/Utilities/cmcurl/lib/vtls/vtls.h
+++ b/Utilities/cmcurl/lib/vtls/vtls.h
@@ -31,6 +31,7 @@
 #define SSLSUPP_PINNEDPUBKEY (1<<2) /* supports CURLOPT_PINNEDPUBLICKEY */
 #define SSLSUPP_SSL_CTX      (1<<3) /* supports CURLOPT_SSL_CTX */
 #define SSLSUPP_HTTPS_PROXY  (1<<4) /* supports access via HTTPS proxies */
+#define SSLSUPP_TLS13_CIPHERSUITES (1<<5) /* supports TLS 1.3 ciphersuites */
 
 struct Curl_ssl {
   /*
@@ -93,6 +94,7 @@
 CURLcode Curl_none_set_engine_default(struct Curl_easy *data);
 struct curl_slist *Curl_none_engines_list(struct Curl_easy *data);
 bool Curl_none_false_start(void);
+bool Curl_ssl_tls13_ciphersuites(void);
 CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
                           unsigned char *md5sum, size_t md5len);
 
@@ -246,7 +248,7 @@
 
 #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
 
-#else
+#else /* if not USE_SSL */
 
 /* When SSL support is not present, just define away these function calls */
 #define Curl_ssl_init() 1
@@ -270,6 +272,7 @@
 #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
 #define Curl_ssl_cert_status_request() FALSE
 #define Curl_ssl_false_start() FALSE
+#define Curl_ssl_tls13_ciphersuites() FALSE
 #endif
 
 #endif /* HEADER_CURL_VTLS_H */
diff --git a/Utilities/cmcurl/lib/warnless.h b/Utilities/cmcurl/lib/warnless.h
index f6a2d74..284ea1e 100644
--- a/Utilities/cmcurl/lib/warnless.h
+++ b/Utilities/cmcurl/lib/warnless.h
@@ -26,6 +26,9 @@
 #include <curl/curl.h> /* for curl_socket_t */
 #endif
 
+#define CURLX_FUNCTION_CAST(target_type, func) \
+  (target_type)(void (*) (void))(func)
+
 unsigned short curlx_ultous(unsigned long ulnum);
 
 unsigned char curlx_ultouc(unsigned long ulnum);
diff --git a/Utilities/cmcurl/lib/x509asn1.c b/Utilities/cmcurl/lib/x509asn1.c
index bba2023..72a0b4a 100644
--- a/Utilities/cmcurl/lib/x509asn1.c
+++ b/Utilities/cmcurl/lib/x509asn1.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -40,10 +40,6 @@
 #include "curl_memory.h"
 #include "memdebug.h"
 
-/* For overflow checks. */
-#define CURL_SIZE_T_MAX         ((size_t)-1)
-
-
 /* ASN.1 OIDs. */
 static const char       cnOID[] = "2.5.4.3";    /* Common name. */
 static const char       sanOID[] = "2.5.29.17"; /* Subject alternative name. */
@@ -108,8 +104,8 @@
  */
 
 
-const char *Curl_getASN1Element(curl_asn1Element *elem,
-                                const char *beg, const char *end)
+static const char *getASN1Element(curl_asn1Element *elem,
+                                  const char *beg, const char *end)
 {
   unsigned char b;
   unsigned long len;
@@ -146,7 +142,7 @@
       return (const char *) NULL;
     elem->beg = beg;
     while(beg < end && *beg) {
-      beg = Curl_getASN1Element(&lelem, beg, end);
+      beg = getASN1Element(&lelem, beg, end);
       if(!beg)
         return (const char *) NULL;
     }
@@ -206,7 +202,7 @@
   /* Convert an ASN.1 octet string to a printable string.
      Return the dynamically allocated string, or NULL if an error occurs. */
 
-  if(n <= (CURL_SIZE_T_MAX - 1) / 3) {
+  if(n <= (SIZE_T_MAX - 1) / 3) {
     buf = malloc(3 * n + 1);
     if(buf)
       for(n = 0; beg < end; n += 3)
@@ -287,7 +283,7 @@
 
   if(inlength % size)
     return -1;  /* Length inconsistent with character size. */
-  if(inlength / size > (CURL_SIZE_T_MAX - 1) / 4)
+  if(inlength / size > (SIZE_T_MAX - 1) / 4)
     return -1;  /* Too big. */
   buf = malloc(4 * (inlength / size) + 1);
   if(!buf)
@@ -306,10 +302,10 @@
       case 4:
         wc = (wc << 8) | *(const unsigned char *) from++;
         wc = (wc << 8) | *(const unsigned char *) from++;
-        /* fallthrough */
+        /* FALLTHROUGH */
       case 2:
         wc = (wc << 8) | *(const unsigned char *) from++;
-        /* fallthrough */
+        /* FALLTHROUGH */
       default: /* case 1: */
         wc = (wc << 8) | *(const unsigned char *) from++;
       }
@@ -546,7 +542,7 @@
                        tzl, tzp);
 }
 
-const char *Curl_ASN1tostr(curl_asn1Element *elem, int type)
+static const char *ASN1tostr(curl_asn1Element *elem, int type)
 {
   /* Convert an ASN.1 element to a printable string.
      Return the dynamically allocated string, or NULL if an error occurs. */
@@ -605,12 +601,12 @@
      Return the total string length, even if larger than `n'. */
 
   for(p1 = dn->beg; p1 < dn->end;) {
-    p1 = Curl_getASN1Element(&rdn, p1, dn->end);
+    p1 = getASN1Element(&rdn, p1, dn->end);
     for(p2 = rdn.beg; p2 < rdn.end;) {
-      p2 = Curl_getASN1Element(&atv, p2, rdn.end);
-      p3 = Curl_getASN1Element(&oid, atv.beg, atv.end);
-      Curl_getASN1Element(&value, p3, atv.end);
-      str = Curl_ASN1tostr(&oid, 0);
+      p2 = getASN1Element(&atv, p2, rdn.end);
+      p3 = getASN1Element(&oid, atv.beg, atv.end);
+      getASN1Element(&value, p3, atv.end);
+      str = ASN1tostr(&oid, 0);
       if(!str)
         return -1;
 
@@ -640,7 +636,7 @@
       l++;
 
       /* Generate value. */
-      str = Curl_ASN1tostr(&value, 0);
+      str = ASN1tostr(&value, 0);
       if(!str)
         return -1;
       for(p3 = str; *p3; p3++) {
@@ -655,7 +651,7 @@
   return l;
 }
 
-const char *Curl_DNtostr(curl_asn1Element *dn)
+static const char *DNtostr(curl_asn1Element *dn)
 {
   char *buf = (char *) NULL;
   ssize_t n = encodeDN(buf, 0, dn);
@@ -694,17 +690,17 @@
   cert->certificate.end = end;
 
   /* Get the sequence content. */
-  if(!Curl_getASN1Element(&elem, beg, end))
+  if(!getASN1Element(&elem, beg, end))
     return -1;  /* Invalid bounds/size. */
   beg = elem.beg;
   end = elem.end;
 
   /* Get tbsCertificate. */
-  beg = Curl_getASN1Element(&tbsCertificate, beg, end);
+  beg = getASN1Element(&tbsCertificate, beg, end);
   /* Skip the signatureAlgorithm. */
-  beg = Curl_getASN1Element(&cert->signatureAlgorithm, beg, end);
+  beg = getASN1Element(&cert->signatureAlgorithm, beg, end);
   /* Get the signatureValue. */
-  Curl_getASN1Element(&cert->signature, beg, end);
+  getASN1Element(&cert->signature, beg, end);
 
   /* Parse TBSCertificate. */
   beg = tbsCertificate.beg;
@@ -712,29 +708,29 @@
   /* Get optional version, get serialNumber. */
   cert->version.header = NULL;
   cert->version.beg = &defaultVersion;
-  cert->version.end = &defaultVersion + sizeof defaultVersion;;
-  beg = Curl_getASN1Element(&elem, beg, end);
+  cert->version.end = &defaultVersion + sizeof(defaultVersion);
+  beg = getASN1Element(&elem, beg, end);
   if(elem.tag == 0) {
-    Curl_getASN1Element(&cert->version, elem.beg, elem.end);
-    beg = Curl_getASN1Element(&elem, beg, end);
+    getASN1Element(&cert->version, elem.beg, elem.end);
+    beg = getASN1Element(&elem, beg, end);
   }
   cert->serialNumber = elem;
   /* Get signature algorithm. */
-  beg = Curl_getASN1Element(&cert->signatureAlgorithm, beg, end);
+  beg = getASN1Element(&cert->signatureAlgorithm, beg, end);
   /* Get issuer. */
-  beg = Curl_getASN1Element(&cert->issuer, beg, end);
+  beg = getASN1Element(&cert->issuer, beg, end);
   /* Get notBefore and notAfter. */
-  beg = Curl_getASN1Element(&elem, beg, end);
-  ccp = Curl_getASN1Element(&cert->notBefore, elem.beg, elem.end);
-  Curl_getASN1Element(&cert->notAfter, ccp, elem.end);
+  beg = getASN1Element(&elem, beg, end);
+  ccp = getASN1Element(&cert->notBefore, elem.beg, elem.end);
+  getASN1Element(&cert->notAfter, ccp, elem.end);
   /* Get subject. */
-  beg = Curl_getASN1Element(&cert->subject, beg, end);
+  beg = getASN1Element(&cert->subject, beg, end);
   /* Get subjectPublicKeyAlgorithm and subjectPublicKey. */
-  beg = Curl_getASN1Element(&cert->subjectPublicKeyInfo, beg, end);
-  ccp = Curl_getASN1Element(&cert->subjectPublicKeyAlgorithm,
+  beg = getASN1Element(&cert->subjectPublicKeyInfo, beg, end);
+  ccp = getASN1Element(&cert->subjectPublicKeyAlgorithm,
                             cert->subjectPublicKeyInfo.beg,
                             cert->subjectPublicKeyInfo.end);
-  Curl_getASN1Element(&cert->subjectPublicKey, ccp,
+  getASN1Element(&cert->subjectPublicKey, ccp,
                       cert->subjectPublicKeyInfo.end);
   /* Get optional issuerUiqueID, subjectUniqueID and extensions. */
   cert->issuerUniqueID.tag = cert->subjectUniqueID.tag = 0;
@@ -745,19 +741,19 @@
   cert->extensions.header = NULL;
   cert->extensions.beg = cert->extensions.end = "";
   if(beg < end)
-    beg = Curl_getASN1Element(&elem, beg, end);
+    beg = getASN1Element(&elem, beg, end);
   if(elem.tag == 1) {
     cert->issuerUniqueID = elem;
     if(beg < end)
-      beg = Curl_getASN1Element(&elem, beg, end);
+      beg = getASN1Element(&elem, beg, end);
   }
   if(elem.tag == 2) {
     cert->subjectUniqueID = elem;
     if(beg < end)
-      beg = Curl_getASN1Element(&elem, beg, end);
+      beg = getASN1Element(&elem, beg, end);
   }
   if(elem.tag == 3)
-    Curl_getASN1Element(&cert->extensions, elem.beg, elem.end);
+    getASN1Element(&cert->extensions, elem.beg, elem.end);
   return 0;
 }
 
@@ -785,12 +781,12 @@
 
   /* Get algorithm parameters and return algorithm name. */
 
-  beg = Curl_getASN1Element(&oid, beg, end);
+  beg = getASN1Element(&oid, beg, end);
   param->header = NULL;
   param->tag = 0;
   param->beg = param->end = end;
   if(beg < end)
-    Curl_getASN1Element(param, beg, end);
+    getASN1Element(param, beg, end);
   return OID2str(oid.beg, oid.end, TRUE);
 }
 
@@ -801,7 +797,7 @@
 
   /* Generate a certificate information record for the public key. */
 
-  output = Curl_ASN1tostr(elem, 0);
+  output = ASN1tostr(elem, 0);
   if(output) {
     if(data->set.ssl.certinfo)
       Curl_ssl_push_certinfo(data, certnum, label, output);
@@ -825,10 +821,10 @@
   /* Generate all information records for the public key. */
 
   /* Get the public key (single element). */
-  Curl_getASN1Element(&pk, pubkey->beg + 1, pubkey->end);
+  getASN1Element(&pk, pubkey->beg + 1, pubkey->end);
 
   if(strcasecompare(algo, "rsaEncryption")) {
-    p = Curl_getASN1Element(&elem, pk.beg, pk.end);
+    p = getASN1Element(&elem, pk.beg, pk.end);
     /* Compute key length. */
     for(q = elem.beg; !*q && q < elem.end; q++)
       ;
@@ -849,22 +845,22 @@
     }
     /* Generate coefficients. */
     do_pubkey_field(data, certnum, "rsa(n)", &elem);
-    Curl_getASN1Element(&elem, p, pk.end);
+    getASN1Element(&elem, p, pk.end);
     do_pubkey_field(data, certnum, "rsa(e)", &elem);
   }
   else if(strcasecompare(algo, "dsa")) {
-    p = Curl_getASN1Element(&elem, param->beg, param->end);
+    p = getASN1Element(&elem, param->beg, param->end);
     do_pubkey_field(data, certnum, "dsa(p)", &elem);
-    p = Curl_getASN1Element(&elem, p, param->end);
+    p = getASN1Element(&elem, p, param->end);
     do_pubkey_field(data, certnum, "dsa(q)", &elem);
-    Curl_getASN1Element(&elem, p, param->end);
+    getASN1Element(&elem, p, param->end);
     do_pubkey_field(data, certnum, "dsa(g)", &elem);
     do_pubkey_field(data, certnum, "dsa(pub_key)", &pk);
   }
   else if(strcasecompare(algo, "dhpublicnumber")) {
-    p = Curl_getASN1Element(&elem, param->beg, param->end);
+    p = getASN1Element(&elem, param->beg, param->end);
     do_pubkey_field(data, certnum, "dh(p)", &elem);
-    Curl_getASN1Element(&elem, param->beg, param->end);
+    getASN1Element(&elem, param->beg, param->end);
     do_pubkey_field(data, certnum, "dh(g)", &elem);
     do_pubkey_field(data, certnum, "dh(pub_key)", &pk);
   }
@@ -903,7 +899,7 @@
     return CURLE_OUT_OF_MEMORY;
 
   /* Subject. */
-  ccp = Curl_DNtostr(&cert.subject);
+  ccp = DNtostr(&cert.subject);
   if(!ccp)
     return CURLE_OUT_OF_MEMORY;
   if(data->set.ssl.certinfo)
@@ -913,7 +909,7 @@
   free((char *) ccp);
 
   /* Issuer. */
-  ccp = Curl_DNtostr(&cert.issuer);
+  ccp = DNtostr(&cert.issuer);
   if(!ccp)
     return CURLE_OUT_OF_MEMORY;
   if(data->set.ssl.certinfo)
@@ -937,7 +933,7 @@
     infof(data, "   Version: %lu (0x%lx)\n", version + 1, version);
 
   /* Serial number. */
-  ccp = Curl_ASN1tostr(&cert.serialNumber, 0);
+  ccp = ASN1tostr(&cert.serialNumber, 0);
   if(!ccp)
     return CURLE_OUT_OF_MEMORY;
   if(data->set.ssl.certinfo)
@@ -958,7 +954,7 @@
   free((char *) ccp);
 
   /* Start Date. */
-  ccp = Curl_ASN1tostr(&cert.notBefore, 0);
+  ccp = ASN1tostr(&cert.notBefore, 0);
   if(!ccp)
     return CURLE_OUT_OF_MEMORY;
   if(data->set.ssl.certinfo)
@@ -968,7 +964,7 @@
   free((char *) ccp);
 
   /* Expire Date. */
-  ccp = Curl_ASN1tostr(&cert.notAfter, 0);
+  ccp = ASN1tostr(&cert.notAfter, 0);
   if(!ccp)
     return CURLE_OUT_OF_MEMORY;
   if(data->set.ssl.certinfo)
@@ -992,7 +988,7 @@
 /* TODO: extensions. */
 
   /* Signature. */
-  ccp = Curl_ASN1tostr(&cert.signature, 0);
+  ccp = ASN1tostr(&cert.signature, 0);
   if(!ccp)
     return CURLE_OUT_OF_MEMORY;
   if(data->set.ssl.certinfo)
@@ -1051,7 +1047,7 @@
   /* Check if first ASN.1 element at `beg' is the given OID.
      Return a pointer in the source after the OID if found, else NULL. */
 
-  ccp = Curl_getASN1Element(&e, beg, end);
+  ccp = getASN1Element(&e, beg, end);
   if(!ccp || e.tag != CURL_ASN1_OBJECT_IDENTIFIER)
     return (const char *) NULL;
 
@@ -1110,19 +1106,19 @@
 
   /* Process extensions. */
   for(p = cert.extensions.beg; p < cert.extensions.end && matched != 1;) {
-    p = Curl_getASN1Element(&ext, p, cert.extensions.end);
+    p = getASN1Element(&ext, p, cert.extensions.end);
     /* Check if extension is a subjectAlternativeName. */
     ext.beg = checkOID(ext.beg, ext.end, sanOID);
     if(ext.beg) {
-      ext.beg = Curl_getASN1Element(&elem, ext.beg, ext.end);
+      ext.beg = getASN1Element(&elem, ext.beg, ext.end);
       /* Skip critical if present. */
       if(elem.tag == CURL_ASN1_BOOLEAN)
-        ext.beg = Curl_getASN1Element(&elem, ext.beg, ext.end);
+        ext.beg = getASN1Element(&elem, ext.beg, ext.end);
       /* Parse the octet string contents: is a single sequence. */
-      Curl_getASN1Element(&elem, elem.beg, elem.end);
+      getASN1Element(&elem, elem.beg, elem.end);
       /* Check all GeneralNames. */
       for(q = elem.beg; matched != 1 && q < elem.end;) {
-        q = Curl_getASN1Element(&name, q, elem.end);
+        q = getASN1Element(&name, q, elem.end);
         switch(name.tag) {
         case 2: /* DNS name. */
           len = utf8asn1str(&dnsname, CURL_ASN1_IA5_STRING,
@@ -1162,9 +1158,9 @@
   /* we have to look to the last occurrence of a commonName in the
      distinguished one to get the most significant one. */
   while(q < cert.subject.end) {
-    q = Curl_getASN1Element(&dn, q, cert.subject.end);
+    q = getASN1Element(&dn, q, cert.subject.end);
     for(p = dn.beg; p < dn.end;) {
-      p = Curl_getASN1Element(&elem, p, dn.end);
+      p = getASN1Element(&elem, p, dn.end);
       /* We have a DN's AttributeTypeAndValue: check it in case it's a CN. */
       elem.beg = checkOID(elem.beg, elem.end, cnOID);
       if(elem.beg)
@@ -1173,7 +1169,7 @@
   }
 
   /* Check the CN if found. */
-  if(!Curl_getASN1Element(&elem, name.beg, name.end))
+  if(!getASN1Element(&elem, name.beg, name.end))
     failf(data, "SSL: unable to obtain common name from peer certificate");
   else {
     len = utf8asn1str(&dnsname, elem.tag, elem.beg, elem.end);