Skip to content
Snippets Groups Projects
Commit f5a1b197 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Revert "Fix luajit build issues on OSX + refactoring"

This reverts commit 615f0985.
parent 0a747304
No related branches found
No related tags found
No related merge requests found
......@@ -129,50 +129,27 @@ message (STATUS "Use LuaJIT includes: ${LUAJIT_INCLUDE}")
message (STATUS "Use LuaJIT library: ${LUAJIT_LIB}")
macro(luajit_build)
# 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.
# Use separate_arguments() to turn a string into a list (splits at ws).
# It appears that variable expansion rules are context-dependent.
# With the current arrangement add_custom_command()
# does the right thing. We can even handle pathnames with
# spaces though a path with an embeded semicolon or a quotation mark
# will most certainly wreak havok.
#
# This stuff is extremely fragile, proceed with caution.
set (luajit_cflags ${CMAKE_C_FLAGS})
separate_arguments(luajit_cflags)
set (luajut_ldflags ${CMAKE_STATIC_LINKER_FLAGS})
separate_arguments(luajit_ldflags)
# Use external unwind on all platforms.
set (luajit_xcflags "-DLUAJIT_UNWIND_EXTERNAL=1")
# We are consciously ommiting debug info in RelWithDebugInfo mode
set (luajit_buildoptions BUILDMODE=static)
set (luajit_copt "")
set (luajit_xcflags "")
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set (luajit_ccopt -O0)
if (CC_HAS_GGDB)
set (luajit_ccdebug -g -ggdb)
else ()
set (luajit_ccdebug -g)
endif ()
set (luajit_buildoptions ${luajit_buildoptions} CCDEBUG=${CC_DEBUG_OPT})
set (luajit_copt ${luajit_copt} -O1)
set (luajit_xcflags ${luajit_xcflags}
-DLUA_USE_APICHECK -DLUA_USE_ASSERT)
else ()
set (luajit_cсopt -O2)
set (luajit_ccdbebug "")
endif()
# Pass sysroot settings on OSX
if (NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "")
set (luajit_cflags ${luajit_cflags} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT})
set (luajit_ldflags ${luajit_ldlags} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT})
set (luajit_copt ${luajit_copt} -O2)
endif()
if (ENABLE_VALGRIND)
set (luajit_xcflags ${luajit_xcflags}
-DLUAJIT_USE_VALGRIND -DLUAJIT_USE_SYSMALLOC)
endif()
set (luajit_target_cc ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
set (luajit_target_cc "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} ${CMAKE_C_FLAGS}")
# Use external unwind on all platforms.
set (luajit_target_cc "${luajit_target_cc} -DLUAJIT_UNWIND_EXTERNAL=1")
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})
set (luajit_host_cc ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} ${CMAKE_C_FLAGS})
else()
# Crosscompile mode - use a host CC compiler for building host utils.
# Since CMake does not support cross compilation properly
......@@ -184,16 +161,20 @@ macro(luajit_build)
# 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_host_cc}"
CFLAGS="${luajit_cflags}"
LDFLAGS="${luajit_ldflags}"
CCOPT="${luajit_ccopt}"
CCDEBUG="${luajit_ccdebug}"
set(luajit_ldflags "${CMAKE_SHARED_LINKER_FLAGS}")
separate_arguments(luajit_copt)
separate_arguments(luajit_ldflags)
separate_arguments(luajit_host_cc)
separate_arguments(luajit_target_cc)
set (luajit_buildoptions ${luajit_buildoptions}
CFLAGS=""
CXXFLAGS=""
XCFLAGS="${luajit_xcflags}"
CC="${luajit_host_cc}"
HOST_CC="${luajit_host_cc}"
TARGET_CC="${luajit_target_cc}"
Q='')
CCOPT="${luajit_copt}")
set (luajit_buildoptions ${luajit_buildoptions} Q='' LDFLAGS="${luajit_ldflags}")
if (${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/luajit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment