Re: [CMake] compiling for both python2 and python3

2018-06-22 Thread Juan E. Sanchez
I use the same source files to compile by setting 
TARGET_INCLUDE_DIRECTORIES for two similar targets.  The included 
Python.h provides the PY_MAJOR_VERSION macro to know if you are 
compiling for python 2 or 3.


https://github.com/devsim/devsim/blob/master/src/pythonapi/CMakeLists.txt

https://github.com/devsim/devsim/blob/master/src/pythonapi/PythonCommands.cc

I avoid using FIND_PACKAGE, and code my own PYTHON or PYTHON3 variables, 
like:

PYTHON_INCLUDE
PYTHON3_INCLUDE

in a specific cmake file for my configuration:

https://github.com/devsim/devsim/blob/master/cmake/centos_6.cmake

Regards,

Juan Sanchez

On 6/22/18 2:15 PM, Isaiah Norton wrote:



On Fri, Jun 22, 2018 at 4:36 AM Alexander Bürger > 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


The headers CMake needs to find are different depending on the selected 
version, because the CPython API changed between 2 and 3. The ABI is 
also not guaranteed to be stable within 3.x minor versions unless you 
set Py_LIMITED_API (see e.g. 
https://stackoverflow.com/questions/28830653/build-boost-with-multiple-python-versions).



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





--

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


Re: [CMake] compiling for both python2 and python3

2018-06-22 Thread Isaiah Norton
On Fri, Jun 22, 2018 at 4:36 AM Alexander Bürger  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
>

The headers CMake needs to find are different depending on the selected
version, because the CPython API changed between 2 and 3. The ABI is also
not guaranteed to be stable within 3.x minor versions unless you set
Py_LIMITED_API (see e.g.
https://stackoverflow.com/questions/28830653/build-boost-with-multiple-python-versions
).



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

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


Re: [CMake] Green Hills MULTI generator development

2018-06-22 Thread Robert Maynard
An easy way to track the activity and authors is to look at the
history on the generator.
 ( 
https://gitlab.kitware.com/cmake/cmake/commits/master/Source/cmGlobalGhsMultiGenerator.cxx
)
On Thu, Jun 21, 2018 at 9:06 AM Erich Schroeter
 wrote:
>
> Is anyone actively developing the Green Hills MULTI generator support? If so, 
> who can I contact to get involved?
> --
>
> 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
-- 

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


Re: [CMake] compiling for both python2 and python3

2018-06-22 Thread Alexander Bürger
Hi,

thanks, Petr, for the hint. I was not aware of the possibility to specify a
binary directory, and I will investigate how that works.

Cheers,

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


Re: [CMake] FindPythonLibs on macOS

2018-06-22 Thread Jonas Devlieghere
Hi Marc,

> On Jun 22, 2018, at 10:32 AM, Marc CHEVRIER  wrote:
> 
> There is no specific reason.
> But, starting with CMake 3.12, a new approach to manage python is available 
> (modules FindPython2, FindPython3 and FindPython) which take care of 
> consistency between interpreter and libraries and rely, when possible, on 
> python-config tool.

Great, that sounds very much like the thing I'm looking for. Thanks!

> 
> Le ven. 22 juin 2018 à 11:04, Jonas Devlieghere  > a écrit :
> Hi everyone,
> 
> I'm having trouble with FindPythonLibs on macOS when having a version of 
> Python installed from either via python.org  or Homebrew 
> (in addition to the system one). 
> 
> The issue is that I end up with an inconsistency between the library and the 
> interpreter, which causes issues at runtime. 
> 
> -- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.10") 
> <- System Python
> -- Found PythonInterp: /usr/local/bin/python2.7 (found version "2.7.15")  
>   <- Homebrew Python 
> 
> I was wondering if there's a particular reason that FindPythonLibs doesn't 
> use the python-config binary to find both the python libraries and 
> interpreter. 
> 
> Cheers,
> Jonas
> -- 
> 
> 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 
> 

Jonas-- 

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


Re: [CMake] FindPythonLibs on macOS

2018-06-22 Thread Marc CHEVRIER
There is no specific reason.
But, starting with CMake 3.12, a new approach to manage python is available
(modules FindPython2, FindPython3 and FindPython) which take care of
consistency between interpreter and libraries and rely, when possible, on
python-config tool.



Le ven. 22 juin 2018 à 11:04, Jonas Devlieghere  a
écrit :

> Hi everyone,
>
> I'm having trouble with FindPythonLibs on macOS when having a version of
> Python installed from either via python.org or Homebrew (in addition to
> the system one).
>
> The issue is that I end up with an inconsistency between the library and
> the interpreter, which causes issues at runtime.
>
> -- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.10") <-
> System Python
> -- Found PythonInterp: /usr/local/bin/python2.7 (found version "2.7.15")
>  <- Homebrew Python
>
> I was wondering if there's a particular reason that FindPythonLibs doesn't
> use the python-config binary to find both the python libraries and
> interpreter.
>
> Cheers,
> Jonas
> --
>
> 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
>
-- 

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


Re: [CMake] compiling for both python2 and python3

2018-06-22 Thread Petr Kmoch
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  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
>
>
-- 

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


[CMake] FindPythonLibs on macOS

2018-06-22 Thread Jonas Devlieghere
Hi everyone,

I'm having trouble with FindPythonLibs on macOS when having a version of Python 
installed from either via python.org  or Homebrew (in 
addition to the system one). 

The issue is that I end up with an inconsistency between the library and the 
interpreter, which causes issues at runtime. 

-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.10")   
<- System Python
-- Found PythonInterp: /usr/local/bin/python2.7 (found version "2.7.15")
<- Homebrew Python 

I was wondering if there's a particular reason that FindPythonLibs doesn't use 
the python-config binary to find both the python libraries and interpreter. 

Cheers,
Jonas-- 

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


[CMake] compiling for both python2 and python3

2018-06-22 Thread Alexander Bürger
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