diff --git a/.cmake.metadata b/.cmake.metadata
index cb944b2..2d0abdd 100644
--- a/.cmake.metadata
+++ b/.cmake.metadata
@@ -1 +1 @@
-667675c77842f092f2b9571c409ba8bfbea9e817 SOURCES/cmake-3.18.2.tar.gz
+0c0c76bd90092bbc36288ffd25d8e7f7ebc3c2e5 SOURCES/cmake-3.20.2.tar.gz
diff --git a/.gitignore b/.gitignore
index 5d71b39..75cd037 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/cmake-3.18.2.tar.gz
+SOURCES/cmake-3.20.2.tar.gz
diff --git a/SOURCES/0001-Remove-pax-zstd-test.patch b/SOURCES/0001-Remove-pax-zstd-test.patch
deleted file mode 100644
index a524c20..0000000
--- a/SOURCES/0001-Remove-pax-zstd-test.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From e1287c801aca417b740bc3a9f62df93a4c2c797e Mon Sep 17 00:00:00 2001
-From: Tom Stellard <tstellar@redhat.com>
-Date: Tue, 26 May 2020 11:56:44 -0700
-Subject: [PATCH] Remove pax-zstd test
-
----
- Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake |  1 -
- Tests/RunCMake/CommandLineTar/pax-zstd.cmake     | 10 ----------
- 2 files changed, 11 deletions(-)
- delete mode 100644 Tests/RunCMake/CommandLineTar/pax-zstd.cmake
-
-diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
-index a64af95..4d1b396 100644
---- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
-+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
-@@ -27,7 +27,6 @@ run_cmake(gnutar)
- run_cmake(gnutar-gz)
- run_cmake(pax)
- run_cmake(pax-xz)
--run_cmake(pax-zstd)
- run_cmake(paxr)
- run_cmake(paxr-bz2)
- run_cmake(zip)
-diff --git a/Tests/RunCMake/CommandLineTar/pax-zstd.cmake b/Tests/RunCMake/CommandLineTar/pax-zstd.cmake
-deleted file mode 100644
-index c2a304d..0000000
---- a/Tests/RunCMake/CommandLineTar/pax-zstd.cmake
-+++ /dev/null
-@@ -1,10 +0,0 @@
--set(OUTPUT_NAME "test.tar.zstd")
--
--set(COMPRESSION_FLAGS cvf)
--set(COMPRESSION_OPTIONS --format=pax --zstd)
--
--set(DECOMPRESSION_FLAGS xvf)
--
--include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
--
--check_magic("28b52ffd0058" LIMIT 6 HEX)
--- 
-1.8.3.1
-
diff --git a/SOURCES/cmake-3.20-CPACK_THREADS.patch b/SOURCES/cmake-3.20-CPACK_THREADS.patch
new file mode 100644
index 0000000..354f585
--- /dev/null
+++ b/SOURCES/cmake-3.20-CPACK_THREADS.patch
@@ -0,0 +1,11 @@
+diff -up cmake-3.20.0/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake.CPACK_THREADS cmake-3.20.0/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake
+--- cmake-3.20.0/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake.CPACK_THREADS	2021-03-23 10:43:17.000000000 -0500
++++ cmake-3.20.0/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake	2021-03-23 13:29:14.539434722 -0500
+@@ -1,6 +1,6 @@
+ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
+ 
+-set(CPACK_THREADS 0)
++set(CPACK_THREADS 4)
+ 
+ if(PACKAGING_TYPE STREQUAL "COMPONENT")
+   set(CPACK_COMPONENTS_ALL test)
diff --git a/SOURCES/cmake-fedora-flag_release.patch b/SOURCES/cmake-fedora-flag_release.patch
deleted file mode 100644
index 1e49dee..0000000
--- a/SOURCES/cmake-fedora-flag_release.patch
+++ /dev/null
@@ -1,118 +0,0 @@
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/Absoft-Fortran.cmake cmake-3.18.2/Modules/Compiler/Absoft-Fortran.cmake
---- cmake-3.18.2.orig/Modules/Compiler/Absoft-Fortran.cmake	2020-09-08 13:30:51.134086928 +0000
-+++ cmake-3.18.2/Modules/Compiler/Absoft-Fortran.cmake	2020-09-10 08:44:13.788373968 +0000
-@@ -1,7 +1,7 @@
- string(APPEND CMAKE_Fortran_FLAGS_INIT " ")
- string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -g")
- string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " ")
--string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3")
-+string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O2")
- string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
- set(CMAKE_Fortran_MODDIR_FLAG "-YMOD_OUT_DIR=")
- set(CMAKE_Fortran_MODPATH_FLAG "-p")
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/G95-Fortran.cmake cmake-3.18.2/Modules/Compiler/G95-Fortran.cmake
---- cmake-3.18.2.orig/Modules/Compiler/G95-Fortran.cmake	2020-09-08 13:30:51.136086957 +0000
-+++ cmake-3.18.2/Modules/Compiler/G95-Fortran.cmake	2020-09-10 08:44:22.991490916 +0000
-@@ -1,7 +1,7 @@
- string(APPEND CMAKE_Fortran_FLAGS_INIT " ")
- string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -g")
- string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -Os")
--string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3")
-+string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O2")
- string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
- set(CMAKE_Fortran_MODDIR_FLAG "-fmod=")
- set(CMAKE_Fortran_VERBOSE_FLAG "-v")
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/GNU-Fortran.cmake cmake-3.18.2/Modules/Compiler/GNU-Fortran.cmake
---- cmake-3.18.2.orig/Modules/Compiler/GNU-Fortran.cmake	2020-09-08 13:30:51.137086972 +0000
-+++ cmake-3.18.2/Modules/Compiler/GNU-Fortran.cmake	2020-09-10 08:44:10.635333901 +0000
-@@ -19,7 +19,7 @@
- 
- # No -DNDEBUG for Fortran.
- string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -Os")
--string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3")
-+string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O2")
- 
- # No -isystem for Fortran because it will not find .mod files.
- unset(CMAKE_INCLUDE_SYSTEM_FLAG_Fortran)
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/GNU.cmake cmake-3.18.2/Modules/Compiler/GNU.cmake
---- cmake-3.18.2.orig/Modules/Compiler/GNU.cmake	2020-09-08 13:30:51.137086972 +0000
-+++ cmake-3.18.2/Modules/Compiler/GNU.cmake	2020-09-10 08:44:38.939693578 +0000
-@@ -56,7 +56,7 @@
-   string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
-   string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")
-   string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG")
--  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
-+  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -DNDEBUG")
-   string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
-   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
-   set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/Intel.cmake cmake-3.18.2/Modules/Compiler/Intel.cmake
---- cmake-3.18.2.orig/Modules/Compiler/Intel.cmake	2020-09-08 13:30:51.138086986 +0000
-+++ cmake-3.18.2/Modules/Compiler/Intel.cmake	2020-09-10 08:44:25.749525964 +0000
-@@ -22,7 +22,7 @@
-     string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
-     string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")
-     string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
--    string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
-+    string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2")
-     string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
- 
-     set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}")
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/NVIDIA-CUDA.cmake cmake-3.18.2/Modules/Compiler/NVIDIA-CUDA.cmake
---- cmake-3.18.2.orig/Modules/Compiler/NVIDIA-CUDA.cmake	2020-09-08 13:30:51.138086986 +0000
-+++ cmake-3.18.2/Modules/Compiler/NVIDIA-CUDA.cmake	2020-09-10 08:44:19.672448740 +0000
-@@ -39,7 +39,7 @@
-   set(CMAKE_SHARED_LIBRARY_CUDA_FLAGS -fPIC)
-   string(APPEND CMAKE_CUDA_FLAGS_INIT " ")
-   string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -g")
--  string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
-+  string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -O2 -DNDEBUG")
-   string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG")
-   string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
- endif()
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/PGI.cmake cmake-3.18.2/Modules/Compiler/PGI.cmake
---- cmake-3.18.2.orig/Modules/Compiler/PGI.cmake	2020-09-08 13:30:51.138086986 +0000
-+++ cmake-3.18.2/Modules/Compiler/PGI.cmake	2020-09-10 08:44:32.995618043 +0000
-@@ -18,7 +18,7 @@
-   string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
-   string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0")
-   string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O2 -s")
--  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -fast -O3")
-+  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -fast -O2")
-   string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -gopt")
- 
-   if(CMAKE_HOST_WIN32)
-diff -Naur cmake-3.18.2.orig/Modules/Compiler/PathScale.cmake cmake-3.18.2/Modules/Compiler/PathScale.cmake
---- cmake-3.18.2.orig/Modules/Compiler/PathScale.cmake	2020-09-08 13:30:51.138086986 +0000
-+++ cmake-3.18.2/Modules/Compiler/PathScale.cmake	2020-09-10 08:44:16.715411163 +0000
-@@ -16,6 +16,6 @@
-   string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
-   string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0")
-   string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
--  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
-+  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2")
-   string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g -O2")
- endmacro()
-diff -Naur cmake-3.18.2.orig/Modules/Platform/HP-UX-HP-CXX.cmake cmake-3.18.2/Modules/Platform/HP-UX-HP-CXX.cmake
---- cmake-3.18.2.orig/Modules/Platform/HP-UX-HP-CXX.cmake	2020-09-08 13:30:51.182087632 +0000
-+++ cmake-3.18.2/Modules/Platform/HP-UX-HP-CXX.cmake	2020-09-10 08:44:00.226201627 +0000
-@@ -9,6 +9,6 @@
-   )
- 
- string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -g")
--string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " +O3 -DNDEBUG")
-+string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " +O2 -DNDEBUG")
- string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " +O2 -DNDEBUG")
- string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -g")
-diff -Naur cmake-3.18.2.orig/Modules/Platform/Windows-Clang.cmake cmake-3.18.2/Modules/Platform/Windows-Clang.cmake
---- cmake-3.18.2.orig/Modules/Platform/Windows-Clang.cmake	2020-09-08 13:30:51.185087676 +0000
-+++ cmake-3.18.2/Modules/Platform/Windows-Clang.cmake	2020-09-10 08:44:07.269291127 +0000
-@@ -79,7 +79,7 @@
- 
-     string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}")
-     string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}")
--    string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}")
-+    string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -DNDEBUG ${__ADDED_FLAGS}")
-     string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}")
-   endif()
-   set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
diff --git a/SOURCES/cmake-findruby.patch b/SOURCES/cmake-findruby.patch
new file mode 100644
index 0000000..97ac43a
--- /dev/null
+++ b/SOURCES/cmake-findruby.patch
@@ -0,0 +1,20 @@
+diff -Naur cmake-3.18.2.orig/Modules/FindRuby.cmake cmake-3.18.2/Modules/FindRuby.cmake
+--- cmake-3.18.2.orig/Modules/FindRuby.cmake	2020-09-08 13:30:51.129086854 +0000
++++ cmake-3.18.2/Modules/FindRuby.cmake	2020-09-10 07:10:56.679302608 +0000
+@@ -300,14 +300,8 @@
+   _RUBY_CONFIG_VAR("sitearchdir" Ruby_SITEARCH_DIR)
+   _RUBY_CONFIG_VAR("sitelibdir" Ruby_SITELIB_DIR)
+ 
+-  # vendor_ruby available ?
+-  execute_process(COMMAND ${Ruby_EXECUTABLE} -r vendor-specific -e "print 'true'"
+-    OUTPUT_VARIABLE Ruby_HAS_VENDOR_RUBY  ERROR_QUIET)
+-
+-  if(Ruby_HAS_VENDOR_RUBY)
+-    _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR)
+-    _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR)
+-  endif()
++  _RUBY_CONFIG_VAR("vendorlibdir" RUBY_VENDORLIB_DIR)
++  _RUBY_CONFIG_VAR("vendorarchdir" RUBY_VENDORARCH_DIR)
+ 
+   # save the results in the cache so we don't have to run ruby the next time again
+   set(Ruby_VERSION_MAJOR    ${Ruby_VERSION_MAJOR}    CACHE PATH "The Ruby major version" FORCE)
diff --git a/SOURCES/cmake-gui.appdata.xml b/SOURCES/cmake-gui.appdata.xml
deleted file mode 100644
index b0ffd48..0000000
--- a/SOURCES/cmake-gui.appdata.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright 2014 Ryan Lerch <rlerch@redhat.com> -->
-<!--
-EmailAddress: kitware@kitware.com
-SentUpstream: 2014-09-17
--->
-<application>
-  <id type="desktop">cmake-gui.desktop</id>
-  <metadata_license>CC0-1.0</metadata_license>
-  <name>CMake GUI</name>
-  <summary>Create new CMake projects</summary>
-  <description>
-    <p>
-      CMake is an open source, cross platform build system that can build, test,
-      and package software. CMake GUI is a graphical user interface that can
-      create and edit CMake projects.
-    </p>
-  </description>
-  <url type="homepage">http://www.cmake.org</url>
-  <screenshots>
-    <screenshot type="default">https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/CMake/a.png</screenshot>
-  </screenshots>
-  <!-- FIXME: change this to an upstream email address for spec updates
-  <updatecontact>someone_who_cares@upstream_project.org</updatecontact>
-   -->
-</application>
diff --git a/SPECS/cmake.spec b/SPECS/cmake.spec
index bb0653c..fd3d4c8 100644
--- a/SPECS/cmake.spec
+++ b/SPECS/cmake.spec
@@ -32,15 +32,15 @@
 # Enable RPM dependency generators for cmake files written in Python
 %bcond_without rpm
 
-# Sphinx-build cannot import CMakeLexer on EPEL <= 6
-%if 0%{?rhel} && 0%{?rhel} <= 6
-%bcond_with sphinx
-%else
 %bcond_without sphinx
-%endif
 
-%bcond_with bundled_libarchive
+%if !0%{?rhel}
+%bcond_with bundled_jsoncpp
+%bcond_with bundled_rhash
+%else
 %bcond_without bundled_jsoncpp
+%bcond_without bundled_rhash
+%endif
 
 # Run tests
 %bcond_without test
@@ -58,22 +58,21 @@
 %{!?_vpath_builddir:%global _vpath_builddir %{_target_platform}}
 
 %global major_version 3
-%global minor_version 18
-%global patch_version 2
-
-%global baserelease 9
-
+%global minor_version 20
 # Set to RC version if building RC, else %%{nil}
-#global rcsuf rc3
+#global rcsuf rc1
 %{?rcsuf:%global relsuf .%{rcsuf}}
 %{?rcsuf:%global versuf -%{rcsuf}}
 
+# For handling bump release by rpmdev-bumpspec and mass rebuild
+%global baserelease 1
+
 # Uncomment if building for EPEL
 #global name_suffix %%{major_version}
 %global orig_name cmake
 
 Name:           %{orig_name}%{?name_suffix}
-Version:        %{major_version}.%{minor_version}.%{patch_version}
+Version:        %{major_version}.%{minor_version}.2
 Release:        %{baserelease}%{?relsuf}%{?dist}
 Summary:        Cross-platform make system
 
@@ -84,28 +83,37 @@ Summary:        Cross-platform make system
 # exception granting redistribution under terms of your choice
 License:        BSD and MIT and zlib
 URL:            http://www.cmake.org
-Source0:        https://github.com/Kitware/CMake/archive/v%{version}/cmake-%{version}%{?rcver:%rcver}.tar.gz
+Source0:        http://www.cmake.org/files/v%{major_version}.%{minor_version}/%{orig_name}-%{version}%{?versuf}.tar.gz
 Source1:        %{name}-init.el
 Source2:        macros.%{name}
 # See https://bugzilla.redhat.com/show_bug.cgi?id=1202899
 Source3:        %{name}.attr
 Source4:        %{name}.prov
 Source5:        %{name}.req
-Source6:        cmake%{?name_suffix}-gui.appdata.xml
 
 # Always start regular patches with numbers >= 100.
 # We need lower numbers for patches in compat package.
 # And this enables us to use %%autosetup
-
+#
+# Patch to fix RindRuby vendor settings
+# http://public.kitware.com/Bug/view.php?id=12965
+# https://bugzilla.redhat.com/show_bug.cgi?id=822796
+Patch100:       %{name}-findruby.patch
 # replace release flag -O3 with -O2 for fedora
+%if 0%{?fedora} && 0%{?fedora} < 34
 Patch101:       %{name}-fedora-flag_release.patch
+%endif
 # Add dl to CMAKE_DL_LIBS on MINGW
 # https://gitlab.kitware.com/cmake/cmake/issues/17600
 Patch102:       %{name}-mingw-dl.patch
+# memory-hungry tests when building on koji builders with *lots* of cores
+# so limit it to some reasonable number (4)
+Patch103:       cmake-3.20-CPACK_THREADS.patch
 
-# --zstd option requires tar >= 1.31
-Patch103:       0001-Remove-pax-zstd-test.patch
-
+# Patch for renaming on EPEL
+%if 0%{?name_suffix:1}
+Patch1:      %{name}-rename.patch
+%endif
 
 BuildRequires:  coreutils
 BuildRequires:  findutils
@@ -131,18 +139,25 @@ BuildRequires:  %{_bindir}/sphinx-build
 BuildRequires:  bzip2-devel
 BuildRequires:  curl-devel
 BuildRequires:  expat-devel
-# Needed jsoncpp >= 1.4.1
-%if %{without bundled_jsoncpp}
+%if %{with bundled_jsoncpp}
+Provides: bundled(jsoncpp)
+%else
 BuildRequires:  jsoncpp-devel
 %endif
-# Needed libarchive >= 3.3.3
-%if %{without bundled_libarchive}
+%if 0%{?fedora} || 0%{?rhel} >= 7
 BuildRequires:  libarchive-devel
+%else
+BuildRequires:  libarchive3-devel
 %endif
 BuildRequires:  libuv-devel
+%if %{with bundled_rhash}
+Provides:  bundled(rhash)
+%else
+BuildRequires:  rhash-devel
+%endif
 BuildRequires:  xz-devel
 BuildRequires:  zlib-devel
-BuildRequires:  libzstd-devel
+BuildRequires:  vim-filesystem
 %endif
 %if %{with emacs}
 BuildRequires:  emacs
@@ -156,26 +171,34 @@ BuildRequires:  python%{python3_pkgversion}-devel
 BuildRequires:  python2-devel
 %endif
 %endif
-#BuildRequires: xmlrpc-c-devel
 %if %{with gui}
 %if 0%{?fedora} || 0%{?rhel} > 7
 BuildRequires: pkgconfig(Qt5Widgets)
-BuildRequires: libappstream-glib
 %else
 BuildRequires: pkgconfig(QtGui)
 %endif
 BuildRequires: desktop-file-utils
 %endif
 
+BuildRequires: pkgconfig(bash-completion)
+%global bash_completionsdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null || echo '%{_datadir}/bash-completion/completions')
+
 %if %{without bootstrap}
 # Ensure we have our own rpm-macros in place during build.
 BuildRequires:  %{name}-rpm-macros
 %endif
+BuildRequires: make
 
 Requires:       %{name}-data = %{version}-%{release}
 Requires:       %{name}-rpm-macros = %{version}-%{release}
 Requires:       %{name}-filesystem%{?_isa} = %{version}-%{release}
 
+# Explicitly require make.  (rhbz#1862014)
+Requires:       make
+
+# Provide the major version name
+Provides: %{orig_name}%{major_version} = %{version}-%{release}
+
 # Source/kwsys/MD5.c
 # see https://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries
 Provides: bundled(md5-deutsch)
@@ -183,15 +206,6 @@ Provides: bundled(md5-deutsch)
 # https://fedorahosted.org/fpc/ticket/555
 Provides: bundled(kwsys)
 
-%if %{with bundled_libarchive}
-Provides: bundled(libarchive) = 0:3.3.3
-%endif
-%if %{with bundled_jsoncpp}
-Provides: bundled(json-cpp) = 0:1.8.2
-%endif
-
-Conflicts: %{name}-doc < %{version}
-
 %description
 CMake is used to control the software compilation process using simple
 platform and compiler independent configuration files. CMake generates
@@ -222,7 +236,6 @@ This package contains common data-files for %{name}.
 %package        doc
 Summary:        Documentation for %{name}
 BuildArch:      noarch
-Conflicts: 	%{name} < %{version}
 
 %description    doc
 This package contains documentation for %{name}.
@@ -261,8 +274,7 @@ This package contains common RPM macros for %{name}.
 
 
 %prep
-%autosetup -n CMake-%{version}%{?versuf} -p1
-
+%autosetup -n %{orig_name}-%{version}%{?versuf} -p 1
 
 %if %{with rpm}
 %if %{with python3}
@@ -293,14 +305,13 @@ pushd %{_vpath_builddir}
 $SRCDIR/bootstrap --prefix=%{_prefix} --datadir=/share/%{name} \
                   --docdir=/share/doc/%{name} --mandir=/share/man \
                   --%{?with_bootstrap:no-}system-libs \
+                  --parallel="$(echo %{?_smp_mflags} | sed -e 's|-j||g')" \
+%if %{with bundled_rhash}
                   --no-system-librhash \
+%endif
 %if %{with bundled_jsoncpp}
                   --no-system-jsoncpp \
 %endif
-%if %{with bundled_libarchive}
-                  --no-system-libarchive \
-%endif
-                  --parallel=`/usr/bin/getconf _NPROCESSORS_ONLN` \
 %if %{with sphinx}
                   --sphinx-man --sphinx-html \
 %else
@@ -319,14 +330,17 @@ find %{buildroot}%{_datadir}/%{name}/Modules -type f | xargs chmod -x
 [ -n "$(find %{buildroot}%{_datadir}/%{name}/Modules -name \*.orig)" ] &&
   echo "Found .orig files in %{_datadir}/%{name}/Modules, rebase patches" &&
   exit 1
+# Install major_version name links
+%{!?name_suffix:for f in ccmake cmake cpack ctest; do ln -s $f %{buildroot}%{_bindir}/${f}%{major_version}; done}
 
 %if %{with emacs}
 # Install emacs cmake mode
-mkdir -p %{buildroot}%{_emacs_sitelispdir}/%{name}
-install -p -m 0644 Auxiliary/cmake-mode.el %{buildroot}%{_emacs_sitelispdir}/%{name}/%{name}-mode.el
+mkdir -p %{buildroot}%{_emacs_sitelispdir}/%{name} %{buildroot}%{_emacs_sitestartdir}
+mv %{buildroot}%{_emacs_sitelispdir}/%{name}-mode.el %{buildroot}%{_emacs_sitelispdir}/%{name}
 %{_emacs_bytecompile} %{buildroot}%{_emacs_sitelispdir}/%{name}/%{name}-mode.el
-mkdir -p %{buildroot}%{_emacs_sitestartdir}
 install -p -m 0644 %{SOURCE1} %{buildroot}%{_emacs_sitestartdir}
+%else
+rm -f %{buildroot}%{_emacs_sitelispdir}
 %endif
 # RPM macros
 install -p -m0644 -D %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.%{name}
@@ -375,8 +389,34 @@ desktop-file-install --delete-original \
 # See http://www.freedesktop.org/software/appstream/docs/ for more details.
 #
 mkdir -p %{buildroot}%{_metainfodir}
-install -pm 644 %{SOURCE6} %{buildroot}%{_metainfodir}/
-appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.appdata.xml
+cat > %{buildroot}%{_metainfodir}/cmake-gui.appdata.xml <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2014 Ryan Lerch <rlerch@redhat.com> -->
+<!--
+EmailAddress: kitware@kitware.com
+SentUpstream: 2014-09-17
+-->
+<application>
+  <id type="desktop">cmake-gui.desktop</id>
+  <metadata_license>CC0-1.0</metadata_license>
+  <name>CMake GUI</name>
+  <summary>Create new CMake projects</summary>
+  <description>
+    <p>
+      CMake is an open source, cross platform build system that can build, test,
+      and package software. CMake GUI is a graphical user interface that can
+      create and edit CMake projects.
+    </p>
+  </description>
+  <url type="homepage">http://www.cmake.org</url>
+  <screenshots>
+    <screenshot type="default">https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/CMake/a.png</screenshot>
+  </screenshots>
+  <!-- FIXME: change this to an upstream email address for spec updates
+  <updatecontact>someone_who_cares@upstream_project.org</updatecontact>
+   -->
+</application>
+EOF
 %endif
 %endif
 
@@ -395,51 +435,25 @@ find %{buildroot}%{_bindir} -type f -or -type l -or -xtype l | \
 
 %if %{with test}
 %check
-%if 0%{?rhel} && 0%{?rhel} <= 6
-mv -f Modules/FindLibArchive.cmake Modules/FindLibArchive.disabled
-%endif
 pushd %{_vpath_builddir}
 # CTestTestUpload require internet access
 # CPackComponentsForAll-RPM-IgnoreGroup failing wih rpm 4.15 - https://gitlab.kitware.com/cmake/cmake/issues/19983
-NO_TEST="CTestTestUpload|CPackComponentsForAll-RPM-IgnoreGroup"
+NO_TEST="CTestTestUpload|CPackComponentsForAll-RPM-IgnoreGroup|CPack_RPM.DEBUGINFO"
 # kwsys.testProcess-{4,5} are flaky on s390x.
 %ifarch s390x
 NO_TEST="$NO_TEST|kwsys.testProcess-4|kwsys.testProcess-5"
 %endif
-# RunCMake.PrecompileHeaders test uses precompiled file presumably compiled with different compiler
-# that one of RHEL8 (GCC-8.3.1). See https://bugzilla.redhat.com/show_bug.cgi?id=1721553#c4
-%if 0%{?rhel} && 0%{?rhel} > 7
-NO_TEST="$NO_TEST|RunCMake.PrecompileHeaders"
+# curl test may fail during bootstrap
+%if %{with bootstrap}
+NO_TEST="$NO_TEST|curl"
 %endif
-
 bin/ctest%{?name_suffix} %{?_smp_mflags} -V -E "$NO_TEST" --output-on-failure
+## do this only periodically, not for every build -- rdieter 20210429
 # Keep an eye on failing tests
-bin/ctest%{?name_suffix} %{?_smp_mflags} -V -R "$NO_TEST" --output-on-failure || :
+#bin/ctest%{?name_suffix} %{?_smp_mflags} -V -R "$NO_TEST" --output-on-failure || :
 popd
-%if 0%{?rhel} && 0%{?rhel} <= 6
-mv -f Modules/FindLibArchive.disabled Modules/FindLibArchive.cmake
-%endif
 %endif
 
-%if %{with gui}
-%post gui
-update-desktop-database &> /dev/null || :
-/bin/touch --no-create %{_datadir}/mime || :
-/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
-
-%postun gui
-update-desktop-database &> /dev/null || :
-if [ $1 -eq 0 ] ; then
-    /bin/touch --no-create %{_datadir}/mime || :
-    update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
-    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
-    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-fi
-
-%posttrans gui
-update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
-/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-%endif
 
 %files -f lib_files.mf
 %doc %dir %{_pkgdocdir}
@@ -456,23 +470,24 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
 
 %files data -f data_files.mf
 %{_datadir}/aclocal/%{name}.m4
-%{_datadir}/bash-completion
+%{bash_completionsdir}/c*
 %if %{with emacs}
 %if 0%{?fedora} || 0%{?rhel} >= 7
 %{_emacs_sitelispdir}/%{name}
-%{_emacs_sitelispdir}/%{name}-mode.el
 %{_emacs_sitestartdir}/%{name}-init.el
 %else
 %{_emacs_sitelispdir}
 %{_emacs_sitestartdir}
 %endif
 %endif
-%{_datadir}/vim/vimfiles/indent/cmake.vim
-%{_datadir}/vim/vimfiles/syntax/cmake.vim
+%{vimfiles_root}/indent/%{name}.vim
+%{vimfiles_root}/syntax/%{name}.vim
 
 
 %files doc
-%license %{_datadir}/licenses/%{name}*
+# Pickup license-files from main-pkg's license-dir
+# If there's no license-dir they are picked up by %%doc previously
+%{?_licensedir:%license %{_datadir}/licenses/%{name}*}
 %doc %{_pkgdocdir}
 
 
@@ -504,6 +519,9 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
 
 
 %changelog
+* Thu May 20 2021 sguelton@redhat.com - 3.20.2-1
+- Sync with Fedora rawhide. (#1957947)
+
 * Mon Jan 25 2021 Tom Stellard <tstellar@redhat.com> - 3.18.2-9
 - Sync macros from Fedora