diff --git a/CMakeLists.txt b/CMakeLists.txt index 26a0e65..339de8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 $<$: /W4 diff --git a/Dockerfile b/Dockerfile index a87aa95..ca1eedc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/iface/CMakeLists.txt b/iface/CMakeLists.txt index 980a3d7..93794b3 100644 --- a/iface/CMakeLists.txt +++ b/iface/CMakeLists.txt @@ -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 ) diff --git a/iface/common/future_test.cc b/iface/common/future_test.cc index 44bafc3..e4f4f6c 100644 --- a/iface/common/future_test.cc +++ b/iface/common/future_test.cc @@ -164,7 +164,7 @@ TEST(Future, ThenWhenError) { nf7::Future 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 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); } diff --git a/iface/env.hh b/iface/env.hh index b01a7a7..489e726 100644 --- a/iface/env.hh +++ b/iface/env.hh @@ -7,5 +7,6 @@ namespace nf7 { using Env = Container; +using SimpleEnv = SimpleContainer; } // namespace nf7 diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 043729b..8317664 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -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 diff --git a/thirdparty/luajit.cmake b/thirdparty/luajit.cmake new file mode 100644 index 0000000..61d81a6 --- /dev/null +++ b/thirdparty/luajit.cmake @@ -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 $<$:m> +) +target_include_directories(luajit SYSTEM BEFORE + INTERFACE "${src}" +)