title: ImportError: Library not loaded python macos: Monterey
body: <p>I have written a python binding for the c++ library using pybind11, and the library is installed, and the .so file is generated. But when I'm using the library in my python implementation, I get the below error. After updating to macOS Monterey, I cannot use ${PYTHON_LIBRARY_DIR} as LIBRARY DESTINATION in the install command. So I used the absolute path. Any help would be appreciated to resolve this issue.</p>
  <pre><code>ImportError: dlopen(/Users/username/projectFolder/libname_python.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/liblibname.dylib
    Referenced from: /Users/username/projectFolder/libname_python.cpython-39-darwin.so
    Reason: tried: '/usr/lib/liblibname.dylib' (no such file)
  </code></pre>
  <p>My CmakeList.txt for python binding is,</p>
  <pre><code>cmake_minimum_required(VERSION 3.2)
  
  set(CMAKE_CXX_STANDARD 17)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
  set(CMAKE_CXX_EXTENSIONS OFF)
  
  if(NOT CMAKE_BUILD_TYPE)
      set(CMAKE_BUILD_TYPE Release)
  endif()
  
  set(CMAKE_CXX_FLAGS &quot;-O3&quot;)
  set(CMAKE_CXX_FLAGS_RELEASE &quot;-O3&quot;)
  Set(MY_COMMON_LIBRARIES fw)
  
  project(libname)
  
  
  include_directories(&quot;${CMAKE_SOURCE_DIR}/../src&quot;)
  include_directories(&quot;${CMAKE_SOURCE_DIR}/python&quot;)
  
  find_package(pybind11 REQUIRED)
  
  pybind11_add_module(fw_python
          ${CMAKE_SOURCE_DIR}/../src/programs/*.cpp
          ${CMAKE_SOURCE_DIR}/../src/programs/*.h
          ${PYTHON_FILES}
          )
  
  find_library (
          LIBNAME_LIB
          NAMES libname liblibname # what to look for
          HINTS &quot;/Users/user/projectfolder&quot; # where to look
          NO_DEFAULT_PATH # do not search system default paths
  )
  
  target_link_libraries(libname_python PUBLIC ${FW_LIB})
  
  install(TARGETS libname_python
          COMPONENT python
          LIBRARY DESTINATION &quot;/Users/user/projectfolder/&quot;
          )
  </code></pre>
  <p>My python file</p>
  <pre><code>import libname
  
  libname.functionName()
  </code></pre>
  <p>My project folder hierarchy is</p>
  <pre><code>-projectfolder
      -python
         -CmakeList.txt
   liblibname.dylib
   libname-python.cpython-39-darwin.so
   test.py 
  </code></pre>