How to install Python package with CMake?

Install a CMake macro script from within a python package install script (using setup.py)

  • So I have a Python package – it’s all https://pypi.python.org/pypi/iod-symbolizer, and https://github.com/fish2000/iod-symbolizer, no problem. This is something I’m relatively familiar with. What is unknown to me is: the notion of installing a CMake script as part of the python package install process. The python package in question is a development tool – you use it to preprocess some of your C/C++/Obj-C/Obj-C++ source files and generate some predefined macros in a header – and it works well when it’s wrapped in a CMake macro (https://github.com/fish2000/iod-symbolizer/blob/master/IodSymbolize.cmake) and executed as part of a proper chain of dependencies. For one, I am not sure how to approach this, as there seem to be significant differences between http://stackoverflow.com/a/13476594/298171 and https://wiki.debian.org/Python/Packaging – and then even if I did know how to go about setting things up correctly in setup.py, I can’t find a good precedent on where a CMake script pertaining to a Python package might live. All thoughts and insights on the matter are welcome.

  • Answer:

    It took me a while to understand your question. If I understand correctly, what you are trying to do is provide the IodSymbolize.cmake in the standard installation location of cmake so that other users/projects who rely on your software(symbolizer) can use it in their build process. I think you are thinking in a good direction, trying to provide services for end users of your package. Good question! Here is my understanding of how things work in the cmake world. Say I am an end user who wants to use "symbolizer" executable. What I would do is find_package(symbolizer). This would try to figure out the location of the executable and it would set certain variables which can be used in the build process. You need to provide Findsymbolizer.cmake file. Please take a look at : http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries Also look at the Find*.cmake files provided in /usr//share/cmake/Modules directory if you are Unix/Linux platform. Once the Findsymbolizer.cmake file is working properly, send it to the cmake mailing list for review. Once accepted it can be packaged in the next release of cmake. Then your module is usable with cmake. Hope I answered your question. Please update if you need more info.

fish2000 at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.