[CMake] Various problems deploying a python module

Michael Hertling mhertling at online.de
Mon Jun 21 01:01:36 EDT 2010


On 06/19/2010 12:31 PM, Janosch Peters wrote:
> On 2010-06-18 08:29:25 +0200, Michael Hertling said:
> 
>> On 06/17/2010 04:23 PM, Janosch Peters wrote:
>>> I have two python frameworks on my mac: Python2.5 which comes with OS
>>> X, and python2.6 from macports. If I just use
>>> FIND_PACKAGE(PythonInterp) and FIND_PACKAGE(PythonLibs) I end up
>>> getting the python2.6 interpreter from macports but the python2.5 libs
>>> from OS X.
>>
>> Have you already tried variables like CMAKE_PREFIX_PATH et al. to
>> direct the find functions to your preferred python installation?
> 
> I tried CMAKE_PREFIX_PATH and also CMAKE_FRAMEWORK_PATH but the 
> behaviour did not change. So I digged a bit into the modules code and 
> found out that the default macports framework prefix is already 
> recognized when looking for frameworks. However, as you can see in the 
> snippet below (it's from FindPythonLib), cmake just adds -framework 
> Python which apperantly defaults to the apple provided frameworks. It 
> seems to me that you cannot change that behaviour in any way, but by 
> changing the FindPythonLibs code. Correct me if Im wrong.

Currently, I've no access to a Mac OS X system, so I myself can't test,
but IMO, you're right: Even if PYTHON_LIBRARY and PYTHON_INCLUDE_DIR
are detected as desired FindPythonLibs.cmake sets PYTHON_LIBRARY to
"-framework Python" if PYTHON_INCLUDE_DIR indicates a framework -
regardless of which. BTW, does PYTHON_INCLUDE_DIR get the right
directory?

> BTW, the macro CMAKE_FIND_FRAMEWORKS doesent care about 
> CMAKE_FRAMEWORK_PATH at all. I would consider that a bug.

Here, I'd also expect the CMAKE_FRAMEWORK_PATH et al. to be recognized,
perhaps along with ARGN for additional explicit framework locations; a
bug report / feature request?

> I think the way to go would be to change CMAKE_FIND_FRAMEWORKS to make 
> it recognise CMAKE_FRAMEWORK_PATH and use the first framework found in 
> it to pass it to the "-frameworks" option and if none is found, just 
> default to the apple system framework.

Alternatively, you could use a modified FindPythonLibs.cmake, i.e.
without the snippet from your latest post concerning frameworks, as a
local CMake module in your project in junction with CMAKE_MODULE_PATH,
or you could resort to FIND_{LIBRARY,PATH}() directly and let CMake
figure out the correct options for linking and including.

> For the time being, I think I have to stick to my (very ugly) solution.

...or wait a little as the questionable snippet has gone: 8d87d12 ;)

Regards,

Michael


More information about the CMake mailing list