From 0a747304075029b33f67fc7475091cb1aa8f3709 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Sat, 5 Sep 2015 23:56:58 +0300 Subject: [PATCH] Revert "Remove support for crosscompilation in luajit.cmake" This reverts commit 3010b98b59fca1fd2a7b41bf11e2cb787ad36ac5. --- cmake/luajit.cmake | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake index ff971986e0..7f64541f5f 100644 --- a/cmake/luajit.cmake +++ b/cmake/luajit.cmake @@ -129,7 +129,6 @@ message (STATUS "Use LuaJIT includes: ${LUAJIT_INCLUDE}") message (STATUS "Use LuaJIT library: ${LUAJIT_LIB}") macro(luajit_build) - set (luajit_cc ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}) # Cmake rules concerning strings and lists of strings are weird. # set (foo "1 2 3") defines a string, while # set (foo 1 2 3) defines a list. @@ -170,14 +169,30 @@ macro(luajit_build) set (luajit_xcflags ${luajit_xcflags} -DLUAJIT_USE_VALGRIND -DLUAJIT_USE_SYSMALLOC) endif() + set (luajit_target_cc ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}) + if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR}) + # Regular mode - use CMake compiler for building host utils. + set (luajit_host_cc ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}) + else() + # Crosscompile mode - use a host CC compiler for building host utils. + # Since CMake does not support cross compilation properly + # we have to use system CC here. + set (luajit_host_cc "cc") + endif() + if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64" AND + ${CMAKE_SIZEOF_VOID_P} EQUAL 4) + # The host compiler must have same pointer size as the target compiler. + set (luajit_host_cc "${luajit_host_cc} -m32") + endif() set (luajit_buildoptions BUILDMODE=static - CC="${luajit_cc}" + CC="${luajit_host_cc}" CFLAGS="${luajit_cflags}" LDFLAGS="${luajit_ldflags}" CCOPT="${luajit_ccopt}" CCDEBUG="${luajit_ccdebug}" XCFLAGS="${luajit_xcflags}" + TARGET_CC="${luajit_target_cc}" Q='') if (${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a -- GitLab