Search code examples
pythoncmakesetuptoolsdistutilssetup.py

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


So I have a Python package – it’s all set up on PyPI, and on GitHub, 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 (for example like so) 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 the setuptools sandbox stance and distutils’ willing systems-level installer integration – 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.


Solution

  • 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.