Cmake FetchContent fails when git is configured with ssh

I setup my github account on my computer to use github’s ssh configuration for cloning. I can git clone any URL, but for some reason Cmake can’t use git. I’m on Ubuntu 22.04, cmake version 3.22.1, and git version 2.34.1.

For example, when I try to configure this file with cmake

cmake_minimum_required(VERSION 3.22)
project(TestSFML)

include(FetchContent)

FetchContent_Declare(SFML
    GIT_REPOSITORY https://github.com/SFML/SFML.git
    GIT_TAG        2.6.1
    FIND_PACKAGE_ARGS COMPONENTS system window graphics network audio 
)

FetchContent_MakeAvailable(SFML)

I get this output.

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
[ 11%] Creating directories for 'sfml-populate'
[ 22%] Performing download step (git clone) for 'sfml-populate'
-- Had to git clone more than once:
          3 times.
CMake Error at sfml-subbuild/sfml-populate-prefix/tmp/sfml-populate-gitclone.cmake:31 (message):
  Failed to clone repository: 'https://github.com/SFML/SFML.git'


gmake[2]: *** [CMakeFiles/sfml-populate.dir/build.make:102: sfml-populate-prefix/src/sfml-populate-stamp/sfml-populate-download] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/sfml-populate.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

CMake Error at /usr/share/cmake-3.22/Modules/FetchContent.cmake:1087 (message):
  Build step for sfml failed: 2
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FetchContent.cmake:1216:EVAL:2 (__FetchContent_directPopulate)
  /usr/share/cmake-3.22/Modules/FetchContent.cmake:1216 (cmake_language)
  /usr/share/cmake-3.22/Modules/FetchContent.cmake:1259 (FetchContent_Populate)
  CMakeLists.txt:12 (FetchContent_MakeAvailable)


-- Configuring incomplete, errors occurred!
See also "/home/kyle/Downloads/build/CMakeFiles/CMakeOutput.log".

I assume I have issues because I’ve configured git to use ssh keys with github. That is configured correctly:

(base) kyle@Strawberry:~$ ssh -T git@github.com
Hi K20shores! You've successfully authenticated, but GitHub does not provide shell access.

And, yes, I can clone SFML by hand.

(base) kyle@Strawberry:~/Downloads$ git clone https://github.com/SFML/SFML.git
Cloning into 'SFML'...
remote: Enumerating objects: 47512, done.
remote: Counting objects: 100% (2204/2204), done.
remote: Compressing objects: 100% (933/933), done.
remote: Total 47512 (delta 1450), reused 1602 (delta 1114), pack-reused 45308
Receiving objects: 100% (47512/47512), 102.46 MiB | 19.21 MiB/s, done.
Resolving deltas: 100% (34399/34399), done.

Also, changing the url in cmake to git://github.com/SFML/SFML.git results in a failure as well:

(base) kyle@Strawberry:~/Downloads/build$ cmake ..
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
[ 11%] Creating directories for 'sfml-populate'
[ 22%] Performing download step (git clone) for 'sfml-populate'
-- Had to git clone more than once:
          3 times.
CMake Error at sfml-subbuild/sfml-populate-prefix/tmp/sfml-populate-gitclone.cmake:31 (message):
  Failed to clone repository: 'git://github.com/SFML/SFML.git'


gmake[2]: *** [CMakeFiles/sfml-populate.dir/build.make:102: sfml-populate-prefix/src/sfml-populate-stamp/sfml-populate-download] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/sfml-populate.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

CMake Error at /usr/share/cmake-3.22/Modules/FetchContent.cmake:1087 (message):
  Build step for sfml failed: 2
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FetchContent.cmake:1216:EVAL:2 (__FetchContent_directPopulate)
  /usr/share/cmake-3.22/Modules/FetchContent.cmake:1216 (cmake_language)
  /usr/share/cmake-3.22/Modules/FetchContent.cmake:1259 (FetchContent_Populate)
  CMakeLists.txt:12 (FetchContent_MakeAvailable)


-- Configuring incomplete, errors occurred!
See also "/home/kyle/Downloads/build/CMakeFiles/CMakeOutput.log".

What should I do?

Ah, I have a too old version of cmake (3.22) need 3.24 for FIND_PACKAGE_ARGS.