Skip to content

Commit 336723f

Browse files
committed
Add spdlog dependency and update CMake configuration for JS bindings
1 parent 4225699 commit 336723f

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.20)
22
cmake_policy(SET CMP0091 NEW)
33
project(libnest2d)
44
find_package(standardprojectsettings REQUIRED)
5+
find_package(spdlog REQUIRED)
56

67
option(BUILD_SHARED_LIBS "Build shared libs instead of static (applies for dependencies as well)" OFF)
78
option(HEADER_ONLY "If enabled static library will not be built." ON)
@@ -55,7 +56,7 @@ target_compile_definitions(project_options INTERFACE LIBNEST2D_GEOMETRIES_${GEOM
5556

5657
if("${OPTIMIZER}" STREQUAL "nlopt")
5758
find_package(NLopt REQUIRED)
58-
target_link_libraries(project_options INTERFACE NLopt::nlopt)
59+
target_link_libraries(project_options INTERFACE NLopt::nlopt spdlog::spdlog)
5960
list(APPEND nest2d_HDRS
6061
include/libnest2d/optimizers/nlopt/simplex.hpp
6162
include/libnest2d/optimizers/nlopt/subplex.hpp

conanfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def layout(self):
8989
self.cpp.package.includedirs = ["include"]
9090

9191
def requirements(self):
92+
self.requires("spdlog/[>=1.14.1]", transitive_headers=True)
9293
if self.options.geometries == "clipper":
9394
self.requires("clipper/6.4.2@ultimaker/stable", transitive_headers=True)
9495
if self.options.geometries == "boost" or self.options.geometries == "clipper":

libnest2d_js/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ target_link_libraries(libnest2d_js PRIVATE Boost::headers)
3434
target_link_libraries(libnest2d_js PRIVATE clipper::clipper)
3535

3636
target_link_libraries(libnest2d_js PRIVATE NLopt::nlopt)
37+
38+
target_link_libraries(libnest2d_js PUBLIC spdlog::spdlog)
3739
# Define backend macro for Emscripten
3840
target_compile_definitions(libnest2d_js PRIVATE LIBNEST2D_GEOMETRIES_clipper)
3941
target_compile_definitions(libnest2d_js PRIVATE LIBNEST2D_OPTIMIZER_nlopt)
@@ -51,7 +53,7 @@ target_link_options(libnest2d_js
5153
"SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=0"
5254
"SHELL:--bind"
5355
"SHELL:-l embind"
54-
"SHELL: --embind-emit-tsd libnest2d_js.d.ts"
56+
"SHELL: --emit-tsd libnest2d_js.d.ts"
5557
"SHELL:-sWASM_BIGINT=1"
5658
)
5759

libnest2d_js/libnest2d_js.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ EMSCRIPTEN_BINDINGS(libnest2d_js) {
161161
// Item class
162162
class_<Item>("Item")
163163
.constructor<const PolygonImpl&>()
164-
.class_function("createFromVertices", optional_override([](const emscripten::val& jsVertices) -> Item* {
164+
.class_function("createFromVertices", optional_override([](const emscripten::val& jsVertices) -> Item {
165165
std::vector<Point> vertices = jsArrayToPointVector(jsVertices);
166166
PolygonImpl polygon;
167167
polygon.Contour = vertices;
168-
return new Item(polygon);
169-
}), allow_raw_pointers())
168+
return Item(polygon);
169+
}))
170170
.function("binId", select_overload<int() const>(&Item::binId))
171171
.function("setBinId", select_overload<void(int)>(&Item::binId))
172172
.function("area", &Item::area)
@@ -187,6 +187,7 @@ EMSCRIPTEN_BINDINGS(libnest2d_js) {
187187
return pointVectorToJSArray(poly.Contour);
188188
}));
189189

190+
190191
// Polygon class for internal type compatibility
191192
class_<Polygon>("Polygon");
192193

0 commit comments

Comments
 (0)