diff options
author | sanine <sanine.not@pm.me> | 2023-03-11 15:58:20 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-03-11 15:58:20 -0600 |
commit | ebc50b387ab209c9f9a0d92e340ac293d5697274 (patch) | |
tree | ea8c8b3677a18c994d2b9d33dbef3461dcf18113 /libs/luajit-cmake/host | |
parent | c2329b4c8258baa9429c77566c9def97d00e96d7 (diff) |
build & link with luajit instead of lua5.1
Diffstat (limited to 'libs/luajit-cmake/host')
-rwxr-xr-x | libs/luajit-cmake/host/buildvm/CMakeLists.txt | 69 | ||||
-rwxr-xr-x | libs/luajit-cmake/host/minilua/CMakeLists.txt | 15 |
2 files changed, 84 insertions, 0 deletions
diff --git a/libs/luajit-cmake/host/buildvm/CMakeLists.txt b/libs/luajit-cmake/host/buildvm/CMakeLists.txt new file mode 100755 index 0000000..59340f8 --- /dev/null +++ b/libs/luajit-cmake/host/buildvm/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.4) + +project(buildvm C) + +set(EXTRA_COMPILER_FLAGS_FILE "" + CACHE PATH "Location of a file to specify extra compiler flags.") +set(EXTRA_COMPILER_FLAGS "") +if(EXISTS ${EXTRA_COMPILER_FLAGS_FILE}) + file(READ ${EXTRA_COMPILER_FLAGS_FILE} EXTRA_COMPILER_FLAGS) +else() + set(EXTRA_COMPILER_FLAGS ${BUILDVM_COMPILER_FLAGS}) +endif() + +include(CheckTypeSize) +if("${EXTRA_COMPILER_FLAGS}" MATCHES "LUAJIT_ARCH_.*64") + set(TARGET_SIZE_OF_P 8) +else() + set(TARGET_SIZE_OF_P 4) +endif() + +set(CXX_ARCH_FLAGS "") +if(NOT (CMAKE_SIZEOF_VOID_P EQUAL ${TARGET_SIZE_OF_P})) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CXX_ARCH_FLAGS "-m32") + else() + set(CXX_ARCH_FLAGS "-m64") + endif() +endif() + +find_library(LIBM_LIBRARIES NAMES m) + +add_executable(buildvm + ${LUAJIT_DIR}/src/host/buildvm.c + ${LUAJIT_DIR}/src/host/buildvm_asm.c + ${LUAJIT_DIR}/src/host/buildvm_fold.c + ${LUAJIT_DIR}/src/host/buildvm_lib.c + ${LUAJIT_DIR}/src/host/buildvm_peobj.c) + +target_compile_options(buildvm PRIVATE + ${EXTRA_COMPILER_FLAGS} ${CXX_ARCH_FLAGS}) +target_link_libraries(buildvm PRIVATE ${CXX_ARCH_FLAGS}) +if(LIBM) + target_link_libraries(buildvm PRIVATE ${LIBM_LIBRARIES}) +endif() + + +set(BIN ${CMAKE_CURRENT_BINARY_DIR}) +get_filename_component(BIN_UP ${BIN}/.. ABSOLUTE) +get_filename_component(BIN_UP_UP_UP ${BIN}/../../.. ABSOLUTE) +target_include_directories(buildvm PRIVATE + ${LUAJIT_DIR}/src + ${LUAJIT_DIR}/src/host + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR}/../.. + ${CMAKE_CURRENT_BINARY_DIR}/../../.. + ${CMAKE_CURRENT_BINARY_DIR} + # ${BIN_UP} + # ${BIN_UP_UP_UP} + # ${BIN} +) + + +message(${CMAKE_CURRENT_BINARY_DIR}) +get_target_property(inc_dirs buildvm INCLUDE_DIRECTORIES) +message("!!!!!!!!!!!!!!!!!!!!!!!!") +foreach(dir ${inc_dirs}) + message(${dir}) +endforeach() diff --git a/libs/luajit-cmake/host/minilua/CMakeLists.txt b/libs/luajit-cmake/host/minilua/CMakeLists.txt new file mode 100755 index 0000000..065031f --- /dev/null +++ b/libs/luajit-cmake/host/minilua/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.0) + +project(minilua C) + +find_library(LIBM_LIBRARIES NAMES m) + +add_executable(minilua ${LUAJIT_DIR}/src/host/minilua.c) +if(LIBM_LIBRARIES) + target_link_libraries(minilua ${LIBM_LIBRARIES}) +endif() +if(TARGET_ARCH) + string (REPLACE ";" " " STARGET_ARCH "${TARGET_ARCH}") + set_target_properties(minilua PROPERTIES + COMPILE_FLAGS "${STARGET_ARCH}") +endif() |