Visual Studio 2022 compile

I am trying to compile mylittlengsolve on Windows 10 and Visual Studio 2022.

I am using the following command to

SET pybind11_DIR=C:\Program Files\Python310\Lib\site-packages\pybind11\share\cmake\pybind11
SET CMAKE_PREFIX_PATH=C:/Program Files/Python310/Lib/site-packages/ngsolve/cmake;C:/Program Files/Python310/Lib/site-packages/netgen/cmake;
SET NGSOLVE_DIR=C:\Program Files\Python310\Scripts
rem SET NETGEN_DIR=C:\Program Files\Python310\Scripts
SET PYTHONPATH="C:\Program Files\Python310\"
SET PYTHONLIBS="C:\Program Files\Python310\libs"
rd /s /q build
md build
cd build 
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config release

Althoug visual studio generates myngspy.pyd, it fails saying

import myngspy
ImportError: DLL load failed while importing myngspy: 

It seems that it is not the DLL.

CmakeLists.txt is as follows.

project(mylittlengsolve)

cmake_minimum_required(VERSION 3.1)

#find_package(Netgen REQUIRED C:/Program Files/Python310/Lib/site-packages/netgen/cmake)
find_package(NGSolve REQUIRED C:/Program Files/Python310/Lib/site-packages/ngsolve/cmake)


add_ngsolve_python_module(myngspy myngspy.cpp
  1_myFEM/myElement.cpp 1_myFEM/myFESpace.cpp
  1_myFEM/myPreconditioner.cpp 1_myFEM/myCoefficient.cpp
  1_myFEM/myIntegrator.cpp
  2_myHOFEM/myHOFESpace.cpp 2_myHOFEM/myHOElement.cpp
  4_utility_functions/demo_coupling.cpp 4_utility_functions/myAssembling.cpp
  )

For anyone running into this in the future, it seems to be that on windows you need to import ngsolve in python before importing myngspy.

Visal studio cmake info
cmake --help-policy CMP0148

CMP0148

… versionadded:: 3.27

The FindPythonInterp and FindPythonLibs modules are removed.

These modules have been deprecated since CMake 3.12.
CMake 3.27 and above prefer to not provide the modules.
This policy provides compatibility for projects that have not been
ported away from them.

Projects using the FindPythonInterp and/or FindPythonLibs
modules should be updated to use one of their replacements:

  • FindPython3
  • FindPython2
  • FindPython

The OLD behavior of this policy is for find_package(PythonInterp)
and find_package(PythonLibs) to load the deprecated modules. The NEW
behavior is for uses of the modules to fail as if they do not exist.

This policy was introduced in CMake version 3.27. CMake version
3.27.2-msvc1 warns when the policy is not set and uses OLD behavior.
Use the cmake_policy() command to set it to OLD or NEW
explicitly.

… note::
The OLD behavior of a policy is
deprecated by definition
and may be removed in a future version of CMake.