From fa540a3af8a5ad3d201223aa0baf26819437e108 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 29 Aug 2019 10:36:12 -0500 Subject: Add 32-bit cross-compile toolchain --- MANIFEST | 1 + config/toolchain/build32.cmake | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 config/toolchain/build32.cmake diff --git a/MANIFEST b/MANIFEST index 1232411..622c339 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3263,6 +3263,7 @@ ./java/lib/ext/slf4j-simple-1.7.25.jar # CMake-specific Files +./config/toolchain/build32.cmake ./config/toolchain/crayle.cmake ./config/toolchain/GCC.cmake ./config/toolchain/intel.cmake diff --git a/config/toolchain/build32.cmake b/config/toolchain/build32.cmake new file mode 100644 index 0000000..99b3013 --- /dev/null +++ b/config/toolchain/build32.cmake @@ -0,0 +1,37 @@ +if (WIN32) + set (CMAKE_SYSTEM_NAME Windows) + set (CMAKE_GENERATOR_PLATFORM "x86") +else () + set (CMAKE_SYSTEM_NAME Linux) + + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -msse2" CACHE STRING "c++ flags") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -msse2" CACHE STRING "c flags") + + set (LIB32 /usr/lib) # Fedora + + if (EXISTS /usr/lib32) + set (LIB32 /usr/lib32) # Arch, Solus + endif () + + set (CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE) + set (CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE) + + # this is probably unlikely to be needed, but just in case + set (CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE) + set (CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE) + set (CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE) + + # on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have + # to include the regular system .pc files as well (at the end), because some + # are not always present in the 32 bit directory + if (EXISTS ${LIB32}/pkgconfig) + set (ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig) + endif () +# where is the target environment + set (CMAKE_FIND_ROOT_PATH ${LIB32}) +# search for programs in the build host directories + set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories + set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif () \ No newline at end of file -- cgit v0.12