mirror of https://github.com/dnomd343/klotski.git
Dnomd343
7 months ago
10 changed files with 83 additions and 22 deletions
@ -1,8 +1,17 @@ |
|||||
cmake_minimum_required(VERSION 3.12) |
cmake_minimum_required(VERSION 3.12) |
||||
project(core_ffi LANGUAGES CXX) |
project(core_ffi) |
||||
|
|
||||
set(CMAKE_CXX_STANDARD 23) |
set(CMAKE_CXX_STANDARD 23) |
||||
|
|
||||
add_library(klotski all_cases.cc) |
if (KLSK_C_FFI) |
||||
target_include_directories(klotski PUBLIC include) |
add_library(klotski_c c_ffi/all_cases.cc) |
||||
target_link_libraries(klotski PRIVATE klotski_core) |
target_include_directories(klotski_c PUBLIC c_ffi/include) |
||||
|
target_link_libraries(klotski_c PRIVATE klotski::core) |
||||
|
set_target_properties(klotski_c PROPERTIES OUTPUT_NAME klotski) |
||||
|
endif() |
||||
|
|
||||
|
if (KLSK_PYTHON_FFI) |
||||
|
pybind11_add_module(klotski_py py_ffi/demo.cc) |
||||
|
target_link_libraries(klotski_py PRIVATE klotski::core) |
||||
|
set_target_properties(klotski_py PROPERTIES OUTPUT_NAME klotski) |
||||
|
endif() |
||||
|
@ -0,0 +1,39 @@ |
|||||
|
#include <pybind11/pybind11.h> |
||||
|
#include <pybind11/stl.h> |
||||
|
|
||||
|
#include <common_code/common_code.h> |
||||
|
|
||||
|
namespace py = pybind11; |
||||
|
|
||||
|
// class CommonCode {
|
||||
|
// public:
|
||||
|
// explicit CommonCode(uint64_t val) : value_(val) {}
|
||||
|
//
|
||||
|
// uint64_t Value() const {
|
||||
|
// return value_;
|
||||
|
// }
|
||||
|
//
|
||||
|
// static std::optional<CommonCode> Create(uint64_t val) {
|
||||
|
// if (val == 343) {
|
||||
|
// return CommonCode {val};
|
||||
|
// }
|
||||
|
// return std::nullopt;
|
||||
|
// }
|
||||
|
//
|
||||
|
// private:
|
||||
|
// uint64_t value_ {343};
|
||||
|
// };
|
||||
|
|
||||
|
using klotski::codec::CommonCode; |
||||
|
|
||||
|
PYBIND11_MODULE(klotski, m) { |
||||
|
|
||||
|
py::class_<CommonCode>(m, "CommonCode") |
||||
|
// .def(py::init<uint64_t>())
|
||||
|
.def("to_string", &CommonCode::to_string, py::arg("shorten") = false) |
||||
|
.def_property_readonly("value", &CommonCode::unwrap) |
||||
|
// .def_static("from_val", &CommonCode::Create);
|
||||
|
.def_static("create", &CommonCode::create); |
||||
|
|
||||
|
m.attr("__version__") = "version field"; |
||||
|
} |
@ -1,32 +1,37 @@ |
|||||
set(KLOTSKI_THIRD_PARTY ${KLOTSKI_ROOT_DIR}/third_party) |
set(KLSK_THIRD_PARTY ${KLSK_ROOT_DIR}/third_party) |
||||
|
|
||||
# abseil library |
# abseil library |
||||
set(ABSL_PROPAGATE_CXX_STD ON) |
set(ABSL_PROPAGATE_CXX_STD ON) |
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/abseil-cpp EXCLUDE_FROM_ALL) |
add_subdirectory(${KLSK_THIRD_PARTY}/abseil-cpp EXCLUDE_FROM_ALL) |
||||
|
|
||||
if (KLOTSKI_ENABLE_BENCHMARK) |
if (KLSK_ENABLE_BENCHMARK) |
||||
# google benchmark framework |
# google benchmark framework |
||||
set(BENCHMARK_ENABLE_TESTING OFF) |
set(BENCHMARK_ENABLE_TESTING OFF) |
||||
set(BENCHMARK_ENABLE_EXCEPTIONS OFF) |
set(BENCHMARK_ENABLE_EXCEPTIONS OFF) |
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/benchmark EXCLUDE_FROM_ALL) |
add_subdirectory(${KLSK_THIRD_PARTY}/benchmark EXCLUDE_FROM_ALL) |
||||
endif() |
endif() |
||||
|
|
||||
if (KLOTSKI_ENABLE_TESTING) |
if (KLSK_ENABLE_TESTING) |
||||
# BS thread pool |
# BS thread pool |
||||
add_library(thread_pool INTERFACE) |
add_library(thread_pool INTERFACE) |
||||
target_include_directories(thread_pool INTERFACE |
target_include_directories(thread_pool INTERFACE |
||||
${KLOTSKI_THIRD_PARTY}/thread-pool/include) |
${KLSK_THIRD_PARTY}/thread-pool/include) |
||||
add_library(bs::thread_pool ALIAS thread_pool) |
add_library(bs::thread_pool ALIAS thread_pool) |
||||
|
|
||||
# md5sum implementation |
# md5sum implementation |
||||
set(MD5_ENABLE_LTO OFF) |
set(MD5_ENABLE_LTO OFF) |
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/md5sum EXCLUDE_FROM_ALL) |
add_subdirectory(${KLSK_THIRD_PARTY}/md5sum EXCLUDE_FROM_ALL) |
||||
|
|
||||
# google test framework |
# google test framework |
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/googletest EXCLUDE_FROM_ALL) |
add_subdirectory(${KLSK_THIRD_PARTY}/googletest EXCLUDE_FROM_ALL) |
||||
|
|
||||
# xxHash implementation |
# xxHash implementation |
||||
add_library(xxhash INTERFACE) |
add_library(xxhash INTERFACE) |
||||
target_include_directories(xxhash INTERFACE ${KLOTSKI_THIRD_PARTY}/xxHash) |
target_include_directories(xxhash INTERFACE ${KLSK_THIRD_PARTY}/xxHash) |
||||
add_library(xxHash::xxh3 ALIAS xxhash) |
add_library(xxHash::xxh3 ALIAS xxhash) |
||||
endif() |
endif() |
||||
|
|
||||
|
if (KLSK_PYTHON_FFI) |
||||
|
# python ffi exposure |
||||
|
add_subdirectory(${KLSK_THIRD_PARTY}/pybind11 EXCLUDE_FROM_ALL) |
||||
|
endif() |
||||
|
Loading…
Reference in new issue