[CMake] compiling for both python2 and python3

Petr Kmoch petr.kmoch at gmail.com
Fri Jun 22 05:04:20 EDT 2018


Hi Alexander.

No time for a full answer now, but a hint: it's possible to
add_subdirectory() the same CMakeLists.txt multiple times, if you use a
different binary dir each time. You can set some variables in the parent
CMakeList and use them in the child one to generate slightly different
projects from the same source.

Petr

On 22 June 2018 at 10:33, Alexander Bürger <alexanderb at met.no> wrote:

> Hi,
>
> I am trying to find a good way to compile a python module for a c++
> library using boost-python for both python2 and python3 in the same
> compilation. So far, The only solution I found for using
>
> FIND_PACKAGE(PythonInterp REQUIRED)
> FIND_PACKAGE(PythonLibs REQUIRED)
> FIND_PACKAGE(Boost REQUIRED COMPONENTS python # or python3)
>
> with different python versions is to use one CMakeLists.txt per python
> version, each in a subdirectory, and with almost equal contents. I would
> appreciate suggestions for a better approach, with less duplication.
>
> Best regards,
>
> Alexander Bürger
> MET Norway
>
>
> --
>
> 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:
> https://cmake.org/mailman/listinfo/cmake
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180622/391b8a40/attachment.html>


More information about the CMake mailing list