[cmake-developers] Fix for FindPythonLibs with multiple configurations

Richard Christie r.christie at auckland.ac.nz
Wed Mar 30 19:43:24 EDT 2016


Dear CMake developers!

I have had to modify Module FindPythonLibs.cmake to correctly find the Python debug and release libraries on Windows (for Python 3.5).

A problem with the current version is that it always copies the current PYTHON_LIBRARY to PYTHON_LIBRARY_RELEASE:

set(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}")

this means when find_package(PythonLibs) is called multiple times when both release and debug python libraries are present, it nests the full multi-configuration library list within a new multi-configuration library list, so after getting the expected multi-configuration result:

optimized;RELEASE_LIBRARY;debug;DEBUG_LIBRARY

you get after a second call:

optimised;optimized;RELEASE_LIBRARY;debug;DEBUG_LIBRARY;debug;DEBUG_LIBRARY

and so on.

The attached patch fixes this nesting issue. It is slightly more symmetric in its treatment of DEBUG and RELEASE, however it relies on a RELEASE library variable existing from the last run to avoid copying a list into the PYTHON_RELEASE_LIBRARY variable, and allows only a single library to be pre-specified. These issues are somewhat unsatisfactory to me and there may be a better idiom for dealing with pre-specified multi-configuration libraries.

Regards,
Richard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160330/5e19e2f3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-FindPythonLibs-for-multiple-configurations.patch
Type: application/octet-stream
Size: 3463 bytes
Desc: 0001-Fix-FindPythonLibs-for-multiple-configurations.patch
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160330/5e19e2f3/attachment-0001.obj>


More information about the cmake-developers mailing list