Hi Brad,

Thanks for the quick and helpful response!

I've had a quick education on CMake variable scoping, and now realise that the 
cached PYTHON_LIBRARY variable, which contains either the user-specified 
library or the found release library, becomes eclipsed by a local 
PYTHON_LIBRARY variable, set in SELECT_LIBRARY_CONFIGURATIONS() when 
FindPythonLibs is run, and in multi-configuration builds the variable becomes a 
list containing:
"optimized;PYTHON_LIBRARY_RELEASE;debug;PYTHON_LIBRARY_DEBUG". This would not 
be a problem except that FindPythonLibs assigns it to PYTHON_LIBRARY_RELEASE, 
which then feeds into the new PYTHON_LIBRARY list.

So I've attached an improved fix, which is much simpler: it determines whether 
PYTHON_LIBRARY is a list and extracts the optimized library out of it. It would 
be nice if it were more elegant or a standard function were available to do 
this as needed elsewhere.

The obvious question is whether our re-running of find_package(PythonLibs) is 
bad practice... It comes about because one CMakeLists does a first check on 
whether python is available, then another builds SWIG interfaces using it. OTOH 
the way the PYTHON_LIBRARY variable is manipulated is quite unexpected, however 
I imagine there are a lot of behaviours in these scripts which you're stuck 
with for legacy reasons...

Regards,
Richard


-----Original Message-----
From: Brad King [mailto:brad.k...@kitware.com] 
Sent: Friday, 1 April 2016 2:38 a.m.
To: Richard Christie
Cc: cmake-developers@cmake.org
Subject: Re: [cmake-developers] Fix for FindPythonLibs with multiple 
configurations

Hi Richard,

> The attached patch fixes this nesting issue.

Thanks for working on this.  Please look at revising this to avoid exposing the 
_ANYCONFIG variable.  Use a "_Python_..." internal variable that is unset, or 
find another way to do it without the variable, such as 
`(PYTHON_RELEASE_LIBRARY OR PYTHON_DEBUG_LIBRARY)`.

> idiom for dealing with pre-specified multi-configuration libraries

I don't think our find modules ever consider the possibility of pre-specified 
multi-config libraries.  Each cache entry is meant to hold a single 
find_library result and the module puts them together.  The leaking across 
multiple calls was not intentional.
Therefore this is not a concern for me.

Thanks,
-Brad

Attachment: 0001-Fix-re-running-FindPythonLibs-for-multi-config.patch
Description: 0001-Fix-re-running-FindPythonLibs-for-multi-config.patch

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to