mac 15 m4 chip + glfw + openGL build error

I tried using glfw as my window and then employed it`

vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow =
      vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
  renderWindow->InitializeFromCurrentContext();

Synchronize the context of the window, but it always throws an error on this function. I tested it on the Windows platform using mingw and it ran normally, but it got an error on my mac,What caused this and how can I solve it。

This is my complete test code:

main.cpp

#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <cstdlib>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkSmartPointer.h>

int main()
{
  if (!glfwInit())
  {
    std::cout << "Fialed to initialize GLFW" << std::endl;
    exit(EXIT_FAILURE);
  }

  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

#ifdef __APPLE__
  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif

  GLFWwindow *window = glfwCreateWindow(800, 600, "glfw-vtk", NULL, NULL);
  if (window == NULL)
  {
    std::cout << "Fail to create GLFW Window" << std::endl;
    glfwTerminate();
    exit(EXIT_FAILURE);
  }

  glfwMakeContextCurrent(window);

  if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
  {
    std::cout << "Failed to initalize GLAD" << std::endl;
    exit(EXIT_FAILURE);
  }
  
 
  vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow =
      vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();

   // ERROR
  renderWindow->InitializeFromCurrentContext();

  while (!glfwWindowShouldClose(window))
  {

    glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    glfwSwapBuffers(window);
    glfwPollEvents();
  }

  return 0;
}

CMakeList.txt

cmake_minimum_required(VERSION 3.12)
project(MyProject VERSION 1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Debug)

find_package(glfw3 REQUIRED)
add_subdirectory(glad)

find_package(
  VTK REQUIRED
  CommonColor
  CommonCore
  FiltersSources
  InteractionStyle
  RenderingContextOpenGL2
  RenderingCore
  RenderingFreeType
  RenderingOpenGL2
  RenderingGL2PSOpenGL2 
)

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE ${VTK_LIBRARIES} glfw glad)

vtk_module_autoinit(
  TARGETS ${PROJECT_NAME}
  MODULES ${VTK_LIBRARIES}
)

error: