[CMake] cmake 3.12 - python libs / 32 / 64 bits

Stéphane Ancelot sancelot at numalliance.com
Thu Nov 15 03:47:11 EST 2018


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 ...
> * using a toolchain file: see 
> https://cmake.org/cmake/help/v3.13/manual/cmake-toolchains.7.html
>
>
> Le mer. 14 nov. 2018 à 14:06, Stéphane Ancelot 
> <sancelot at numalliance.com <mailto:sancelot at numalliance.com>> 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 <http://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/20181115/f5df1d4e/attachment.html>


More information about the CMake mailing list