Merge pull request '80 setup LuaJIT build environment' (#94) from feature/80-lua into main
Reviewed-on: #94
This commit is contained in:
commit
e52df1e3eb
@ -8,6 +8,10 @@ option(SANITIZER "ADDRESS or THREAD" "THREAD")
|
||||
|
||||
# all targets should link to this to use common compile options
|
||||
add_library(nf7_config INTERFACE EXCLUDE_FROM_ALL)
|
||||
target_include_directories(nf7_config
|
||||
INTERFACE
|
||||
${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
target_compile_options(nf7_config INTERFACE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4
|
||||
|
@ -3,10 +3,15 @@ FROM debian:unstable-slim
|
||||
RUN apt update && apt install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
gcc-13 \
|
||||
gdb \
|
||||
git \
|
||||
g++-13 \
|
||||
make \
|
||||
&& apt -y clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN \
|
||||
ln -s /usr/bin/gcc-13 /usr/bin/gcc && \
|
||||
ln -s /usr/bin/g++-13 /usr/bin/g++
|
||||
|
||||
WORKDIR /repo
|
||||
|
@ -1,7 +1,6 @@
|
||||
add_library(nf7_iface)
|
||||
target_include_directories(nf7_iface PUBLIC ${PROJECT_SOURCE_DIR})
|
||||
target_link_libraries(nf7_iface
|
||||
PRIVATE
|
||||
PUBLIC
|
||||
git_hash
|
||||
nf7_config
|
||||
)
|
||||
|
@ -164,7 +164,7 @@ TEST(Future, ThenWhenError) {
|
||||
nf7::Future<int32_t> sut {std::make_exception_ptr(nf7::Exception {"hello"})};
|
||||
|
||||
auto called = int32_t {0};
|
||||
sut.Then([&](auto& x) { ++called; });
|
||||
sut.Then([&](auto&) { ++called; });
|
||||
|
||||
EXPECT_EQ(called, 0);
|
||||
}
|
||||
@ -181,7 +181,7 @@ TEST(Future, CatchWhenError) {
|
||||
nf7::Future<int32_t> sut {std::make_exception_ptr(nf7::Exception {"hello"})};
|
||||
|
||||
auto called = int32_t {0};
|
||||
sut.Catch([&](auto& e) { ++called; });
|
||||
sut.Catch([&](auto&) { ++called; });
|
||||
|
||||
EXPECT_EQ(called, 1);
|
||||
}
|
||||
|
@ -7,5 +7,6 @@
|
||||
namespace nf7 {
|
||||
|
||||
using Env = Container<subsys::Interface>;
|
||||
using SimpleEnv = SimpleContainer<subsys::Interface>;
|
||||
|
||||
} // namespace nf7
|
||||
|
9
thirdparty/CMakeLists.txt
vendored
9
thirdparty/CMakeLists.txt
vendored
@ -1,5 +1,14 @@
|
||||
include(FetchContent)
|
||||
|
||||
# ---- luajit (MIT)
|
||||
FetchContent_Declare(
|
||||
luajit
|
||||
GIT_REPOSITORY https://github.com/LuaJIT/LuaJIT.git
|
||||
GIT_TAG 8635cbabf3094c4d8bd00578c7d812bea87bb2d3
|
||||
)
|
||||
FetchContent_Populate(luajit)
|
||||
include(luajit.cmake)
|
||||
|
||||
# ---- gtest (BSD-3-Clause)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
|
56
thirdparty/luajit.cmake
vendored
Normal file
56
thirdparty/luajit.cmake
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
set(src "${luajit_SOURCE_DIR}/src")
|
||||
if (UNIX)
|
||||
find_program(MAKE make REQUIRED)
|
||||
|
||||
set(lib "${src}/libluajit.a")
|
||||
add_custom_target(luajit-build
|
||||
COMMAND
|
||||
${MAKE} -j BUILDMODE=static CFLAGS=-fPIC
|
||||
|
||||
WORKING_DIRECTORY "${luajit_SOURCE_DIR}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# To enable assertions, add the following options:
|
||||
# XCFLAGS="-DLUA_USE_APICHECK -DLUA_USE_ASSERT -Og -g"
|
||||
|
||||
elseif (MINGW)
|
||||
find_program(MAKE mingw32-make REQUIRED)
|
||||
|
||||
set(lib "${src}/libluajit.a")
|
||||
add_custom_target(luajit-build
|
||||
COMMAND ${MAKE} -j BUILDMODE=static CFLAGS=-fPIC
|
||||
|
||||
WORKING_DIRECTORY "${luajit_SOURCE_DIR}/src"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
elseif (MSVC)
|
||||
set(lib "${src}/lua51.lib")
|
||||
add_custom_command(
|
||||
OUTPUT "${lib}"
|
||||
COMMAND msvcbuild.bat static
|
||||
DEPENDS "${luajit_BINARY_DIR}/skip_build"
|
||||
|
||||
WORKING_DIRECTORY "${src}"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(luajit-build SOURCES "${lib}")
|
||||
|
||||
else()
|
||||
message(ERROR "unknown environment")
|
||||
endif()
|
||||
|
||||
add_library(luajit-imported STATIC IMPORTED)
|
||||
set_target_properties(luajit-imported PROPERTIES
|
||||
IMPORTED_LOCATION "${lib}"
|
||||
)
|
||||
add_dependencies(luajit-imported luajit-build)
|
||||
|
||||
add_library(luajit INTERFACE)
|
||||
target_link_libraries(luajit
|
||||
INTERFACE luajit-imported $<$<PLATFORM_ID:Linux>:m>
|
||||
)
|
||||
target_include_directories(luajit SYSTEM BEFORE
|
||||
INTERFACE "${src}"
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user