Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid to use external git command and include_directory property if possible #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.5)

option(LUA_DIR "Path of Lua 5.4 source dir" OFF)
option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" OFF)
option(LUAJIT_SETUP_INCLUDE_DIR "Setup include dir if parent is present" ON)

if(CMAKE_COMPILER_IS_GNUCC)
set(LUA_TARGET_SHARED ON)
@@ -17,17 +18,21 @@ if(LUAJIT_DIR)
if (hasParent)
set(LUA_TARGET $<TARGET_FILE:luajit> PARENT_SCOPE)
set(LUA_LIBRARIES luajit::lib PARENT_SCOPE)
get_target_property(LUA_INCLUDE_DIR luajit::header INCLUDE_DIRECTORIES)
set(LUA_INCLUDE_DIR ${LUA_INCLUDE_DIR} PARENT_SCOPE)
if (LUAJIT_SETUP_INCLUDE_DIR)
get_target_property(LUA_INCLUDE_DIR luajit::header INCLUDE_DIRECTORIES)
set(LUA_INCLUDE_DIR ${LUA_INCLUDE_DIR} PARENT_SCOPE)
endif()
endif()
elseif(LUA_DIR)
project(lua)
include(lua.cmake)
if (hasParent)
set(LUA_TARGET $<TARGET_FILE:lua> PARENT_SCOPE)
set(LUA_LIBRARIES lua::lib PARENT_SCOPE)
get_target_property(LUA_INCLUDE_DIR lua::header INCLUDE_DIRECTORIES)
set(LUA_INCLUDE_DIR ${LUA_INCLUDE_DIR} PARENT_SCOPE)
if (LUAJIT_SETUP_INCLUDE_DIR)
get_target_property(LUA_INCLUDE_DIR lua::header INCLUDE_DIRECTORIES)
set(LUA_INCLUDE_DIR ${LUA_INCLUDE_DIR} PARENT_SCOPE)
endif()
endif()
if (WITH_LIBFFI)
include(ffi.cmake)
30 changes: 27 additions & 3 deletions LuaJIT.cmake
Original file line number Diff line number Diff line change
@@ -408,11 +408,35 @@ if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(GIT_FORMAT %%ct)
endif()

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/luajit_relver.txt
COMMAND git show -s --format=${GIT_FORMAT} > ${CMAKE_CURRENT_BINARY_DIR}/luajit_relver.txt
WORKING_DIRECTORY ${LUAJIT_DIR}
execute_process(
COMMAND git --version
RESULT_VARIABLE GIT_EXISTENCE
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(
COMMAND git rev-parse --is-inside-work-tree
RESULT_VARIABLE GIT_IN_REPOSITORY
OUTPUT_VARIABLE GIT_IS_IN_REPOSITORY
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if ((GIT_EXISTENCE EQUAL 0) AND (GIT_IN_REPOSITORY EQUAL 0))
message(STATUS "Using Git: ${GIT_VERSION}")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/luajit_relver.txt
COMMAND git -c log.showSignature=false show -s --format=${GIT_FORMAT} > ${CMAKE_CURRENT_BINARY_DIR}/luajit_relver.txt
WORKING_DIRECTORY ${LUAJIT_DIR}
)
else()
string(TIMESTAMP current_epoch "%s")
message(STATUS "Using current epoch: ${current_epoch}")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/luajit_relver.txt
COMMAND echo "${current_epoch}" > ${CMAKE_CURRENT_BINARY_DIR}/luajit_relver.txt
WORKING_DIRECTORY ${LUAJIT_DIR}
)
endif()

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/luajit.h
COMMAND ${HOST_WINE} ${MINILUA_PATH} ${LUAJIT_DIR}/src/host/genversion.lua
ARGS ${LUAJIT_DIR}/src/luajit_rolling.h