Unable to run SFML project with CMake on arm64

  apple-m1, c++, cmake, sfml

I am using MacBook with M1 and I try to create a project with SFML.
I downloaded a snapshot of SFML with files built for arm64

I verified it using file command
libsfml-graphics.dylib: Mach-O 64-bit dynamically linked shared library arm64

I placed these files in ~/Library/Frameworks along with extlibs directory content.

I set a CMake flag: -DCMAKE_OSX_ARCHITECTURES=arm64

But I still am unable to run this project.

[ 50%] Linking CXX executable myProject
Undefined symbols for architecture arm64:
  "__ZN2sf6StringC1EPKcRKSt6locale", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make[3]: *** [myProject] Error 1
make[2]: *** [CMakeFiles/myProject.dir/all] Error 2
make[1]: *** [CMakeFiles/myProject.dir/rule] Error 2
make: *** [myProject] Error 2

This is my whole CMakeLists.txt file:

cmake_minimum_required(VERSION 3.19)

add_executable(myProject main.cpp)

set(CMAKE_CXX_COMPILER "/opt/homebrew/bin/g++-11" CACHE STRING "C++ compiler" FORCE)


find_package(SFML 2.5 COMPONENTS system window graphics network audio REQUIRED)
target_link_libraries(myProject sfml-system sfml-window sfml-graphics sfml-audio sfml-network)

I also tried to use dylib instead of framework, but it was unsuccessful also. I’d be grateful for any help, I can’t figure out what I did wrong.

Source: Windows Questions C++