cmake 3.12 - python libs / 32 / 64 bits

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

cmake 3.12 - python libs / 32 / 64 bits

Stéphane Ancelot
Hi,

My system is 64 bits but I can cross compile python c modules for 32 bits .

Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.


here is what I tried :

cmake_minimum_required(VERSION 3.10)
project(py_autom)


set(CMAKE_SYSTEM_PROCESSOR "i686")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)

include_directories(python2.6)
find_package(Python2 COMPONENTS Development)



message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")

Regards

Steph
--

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
Reply | Threaded
Open this post in threaded view
|

Re: cmake 3.12 - python libs / 32 / 64 bits

Marc CHEVRIER
The way you proceed is wrong.
The system configuration is determined during the 'project' function call. Setting information after this call is useless. So, in your example, on a 64bit system, the compilation configuration will be 64bit (variable CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This property is taken in consideration only on 32bit systems.

Moreover, I am not sure that modifying variable 'CMAKE_SYSTEM_PROCESSOR' is a valid action.

To configure a 32bit compilation environment, two possibilities:
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
 

Le mer. 14 nov. 2018 à 14:06, Stéphane Ancelot <[hidden email]> a écrit :
Hi,

My system is 64 bits but I can cross compile python c modules for 32 bits .

Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.


here is what I tried :

cmake_minimum_required(VERSION 3.10)
project(py_autom)


set(CMAKE_SYSTEM_PROCESSOR "i686")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)

include_directories(python2.6)
find_package(Python2 COMPONENTS Development)



message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")

Regards

Steph
--

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
Reply | Threaded
Open this post in threaded view
|

Re: cmake 3.12 - python libs / 32 / 64 bits

Stéphane Ancelot
I agree. That was a debug snippet...but is wrong ... I setted up again the toolchain, but does not help.

 So, I know where are include_dirs and libs  for 32 bits cross compiling, I have to hardcode it like this ?

 add_library(python SHARED IMPORTED)
 set_target_properties( python PROPERTIES IMPORTED_LOCATION /usr/lib32/libpython2.6.so )
 target_include_directories(python SYSTEM ...


Le 14/11/2018 à 17:53, Marc CHEVRIER a écrit :
The way you proceed is wrong.
The system configuration is determined during the 'project' function call. Setting information after this call is useless. So, in your example, on a 64bit system, the compilation configuration will be 64bit (variable CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This property is taken in consideration only on 32bit systems.

Moreover, I am not sure that modifying variable 'CMAKE_SYSTEM_PROCESSOR' is a valid action.

To configure a 32bit compilation environment, two possibilities:
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
 

Le mer. 14 nov. 2018 à 14:06, Stéphane Ancelot <[hidden email]> a écrit :
Hi,

My system is 64 bits but I can cross compile python c modules for 32 bits .

Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.


here is what I tried :

cmake_minimum_required(VERSION 3.10)
project(py_autom)


set(CMAKE_SYSTEM_PROCESSOR "i686")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)

include_directories(python2.6)
find_package(Python2 COMPONENTS Development)



message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")

Regards

Steph
--

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
Reply | Threaded
Open this post in threaded view
|

Re: cmake 3.12 - python libs / 32 / 64 bits

Eric Noulard


Le jeu. 15 nov. 2018 à 09:47, Stéphane Ancelot <[hidden email]> a écrit :
I agree. That was a debug snippet...but is wrong ... I setted up again the toolchain, but does not help.

If you are using a proper toolchain for 32bit compilation.
It looks like a bug in the find_package for Python in the cross-compiling case.
Do you have a stripped down example which exhibit the issue?
Which version of CMake are you using?
  
 So, I know where are include_dirs and libs  for 32 bits cross compiling, I have to hardcode it like this ?

 add_library(python SHARED IMPORTED)
 set_target_properties( python PROPERTIES IMPORTED_LOCATION /usr/lib32/libpython2.6.so )
 target_include_directories(python SYSTEM ...

I think you can do that but it replaces the use of find_package(Python2 COMPONENTS Development) 
may be fixing this would be a better long-term solution ?

 


Le 14/11/2018 à 17:53, Marc CHEVRIER a écrit :
The way you proceed is wrong.
The system configuration is determined during the 'project' function call. Setting information after this call is useless. So, in your example, on a 64bit system, the compilation configuration will be 64bit (variable CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This property is taken in consideration only on 32bit systems.

Moreover, I am not sure that modifying variable 'CMAKE_SYSTEM_PROCESSOR' is a valid action.

To configure a 32bit compilation environment, two possibilities:
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
 

Le mer. 14 nov. 2018 à 14:06, Stéphane Ancelot <[hidden email]> a écrit :
Hi,

My system is 64 bits but I can cross compile python c modules for 32 bits .

Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.


here is what I tried :

cmake_minimum_required(VERSION 3.10)
project(py_autom)


set(CMAKE_SYSTEM_PROCESSOR "i686")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)

include_directories(python2.6)
find_package(Python2 COMPONENTS Development)



message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")

Regards

Steph
--

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


--
Eric

--

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
Reply | Threaded
Open this post in threaded view
|

Re: cmake 3.12 - python libs / 32 / 64 bits

Marc CHEVRIER
FYI, I just deliver a MR (https://gitlab.kitware.com/cmake/cmake/merge_requests/2624) which fix the problem of the selection of the library with the wrong architecture.


Le jeu. 15 nov. 2018 à 10:00, Eric Noulard <[hidden email]> a écrit :
Le jeu. 15 nov. 2018 à 09:47, Stéphane Ancelot <[hidden email]> a écrit :
I agree. That was a debug snippet...but is wrong ... I setted up again the toolchain, but does not help.

If you are using a proper toolchain for 32bit compilation.
It looks like a bug in the find_package for Python in the cross-compiling case.
Do you have a stripped down example which exhibit the issue?
Which version of CMake are you using?
  
 So, I know where are include_dirs and libs  for 32 bits cross compiling, I have to hardcode it like this ?

 add_library(python SHARED IMPORTED)
 set_target_properties( python PROPERTIES IMPORTED_LOCATION /usr/lib32/libpython2.6.so )
 target_include_directories(python SYSTEM ...

I think you can do that but it replaces the use of find_package(Python2 COMPONENTS Development) 
may be fixing this would be a better long-term solution ?

 


Le 14/11/2018 à 17:53, Marc CHEVRIER a écrit :
The way you proceed is wrong.
The system configuration is determined during the 'project' function call. Setting information after this call is useless. So, in your example, on a 64bit system, the compilation configuration will be 64bit (variable CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This property is taken in consideration only on 32bit systems.

Moreover, I am not sure that modifying variable 'CMAKE_SYSTEM_PROCESSOR' is a valid action.

To configure a 32bit compilation environment, two possibilities:
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
 

Le mer. 14 nov. 2018 à 14:06, Stéphane Ancelot <[hidden email]> a écrit :
Hi,

My system is 64 bits but I can cross compile python c modules for 32 bits .

Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.


here is what I tried :

cmake_minimum_required(VERSION 3.10)
project(py_autom)


set(CMAKE_SYSTEM_PROCESSOR "i686")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)

include_directories(python2.6)
find_package(Python2 COMPONENTS Development)



message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")

Regards

Steph
--

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


--
Eric

--

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