Using python 3.7, win10, and vs2019.
My CMakeLists.txt has
find_package(Python COMPONENTS Development REQUIRED)
message(STATUS "Python:")
message(STATUS " Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}")
message(STATUS " Python_LIBRARIES: ${Python_LIBRARIES}")
message(STATUS " Python_LIBRARY_DIRS: ${Python_LIBRARY_DIRS}")
I run cmake with:
-DPython_LIBRARY="c:/python37/libs/python37.lib" ^
-DPython_INCLUDE_DIR="c:/python37/include/" ^
If python37_d.lib is there, then it would grab it too (I'm using vcpkg if it matters). I need to remove the file for it to ignore it.
pyconfig.h auto-links with the library, and it needs a hack like:
#if defined(DEBUG_PYTHON_WITH_RELEASE)
#undef _DEBUG
#define NDEBUG
#include <Python.h>
#define _DEBUG
#undef NDEBUG
#else
#include <Python.h>
#endif
or if using SWIG
#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
Why avoid linking with the debug lib? It requires running with python_d.exe, else it crashes, loading the wrong dll or something. If I run it with python_d, then it seems that there are changes to the environment (can't find files, need different settings, or something--I didn't bother to get into it).
I'm looking for an easy, clean solution.