I'm testing my cmake python-extension setup utility and encountered an odd behavior that I cannot seem to resolve on my own.
In essence, my CMakeLists.txt
boils down to 2 lines:
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
...
Python3_add_library (${TARGET} SHARED ${SRCS})
When I try to build in Debug mode, MSVC 2019 spew a linker error:
LINK : fatal error LNK1104: cannot open file 'python37_d.lib'
I'm using conda, and I'm aware that I don't have the debug library on my PC. So, I started digging around to see if I could circumvent that: mainly just to link to the release lib, python37.lib
...
With the help of this stackoverflow post, I printed all the target properties and found the relevant entry:
mymath LINK_LIBRARIES = Python3::Python
which indicate the use of the IMPORTED target FindPython3
configures. So, I printed its properties as well and found:
Python3::Python IMPORTED_IMPLIB = C:/Users/tikum/miniconda3/libs/python37.lib
Being puzzled, I looked in the corresponding .vcxproj in the build directory and found
<ImportLibrary>
C:/Users/tikum/Documents/Python/python-cmaketools-cpython-example/build/src/cpython_example/mymath/Debug/mymath.lib
</ImportLibrary>
So, I completely and utterly failed to find any trace of linking to python37_d.lib
... Could someone enlighten me on what's going on here?
P.S., the example C code I'm trying to compile is a line-by-line copy of a sample by Martino Pilia that I found online.