Skip to content

Commit

Permalink
Clean up parsing library integration
Browse files Browse the repository at this point in the history
- Move meshloader.cpp to gltf/parselib.cpp to make it easier to
  customize the build for gltfpack
- Remove cgltf from tools/meshloader (now tools/objloader) to make
  non-gltfpack builds a little faster
- Fix vcachetuner Makefile build setup
  • Loading branch information
zeux committed Oct 7, 2023
1 parent c4e0e1b commit 19b9a26
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set(GLTF_SOURCES
gltf/mesh.cpp
gltf/node.cpp
gltf/parseobj.cpp
gltf/parselib.cpp
gltf/parsegltf.cpp
gltf/stream.cpp
gltf/write.cpp
Expand Down Expand Up @@ -94,12 +95,12 @@ endif()
set(TARGETS meshoptimizer)

if(MESHOPT_BUILD_DEMO)
add_executable(demo demo/main.cpp demo/tests.cpp tools/meshloader.cpp)
add_executable(demo demo/main.cpp demo/tests.cpp tools/objloader.cpp)
target_link_libraries(demo meshoptimizer)
endif()

if(MESHOPT_BUILD_GLTFPACK)
add_executable(gltfpack ${GLTF_SOURCES} tools/meshloader.cpp)
add_executable(gltfpack ${GLTF_SOURCES})
set_target_properties(gltfpack PROPERTIES CXX_STANDARD 11)
target_link_libraries(gltfpack meshoptimizer)
list(APPEND TARGETS gltfpack)
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ BUILD=build/$(config)
LIBRARY_SOURCES=$(wildcard src/*.cpp)
LIBRARY_OBJECTS=$(LIBRARY_SOURCES:%=$(BUILD)/%.o)

DEMO_SOURCES=$(wildcard demo/*.c demo/*.cpp) tools/meshloader.cpp
DEMO_SOURCES=$(wildcard demo/*.c demo/*.cpp) tools/objloader.cpp
DEMO_OBJECTS=$(DEMO_SOURCES:%=$(BUILD)/%.o)

GLTFPACK_SOURCES=$(wildcard gltf/*.cpp) tools/meshloader.cpp
GLTFPACK_SOURCES=$(wildcard gltf/*.cpp)
GLTFPACK_OBJECTS=$(GLTFPACK_SOURCES:%=$(BUILD)/%.o)

OBJECTS=$(LIBRARY_OBJECTS) $(DEMO_OBJECTS) $(GLTFPACK_OBJECTS)
Expand Down Expand Up @@ -110,7 +110,7 @@ $(BUILD)/gltfpack: $(GLTFPACK_OBJECTS) $(LIBRARY)

gltfpack.wasm: gltf/library.wasm

gltf/library.wasm: ${LIBRARY_SOURCES} ${GLTFPACK_SOURCES} tools/meshloader.cpp
gltf/library.wasm: ${LIBRARY_SOURCES} ${GLTFPACK_SOURCES}
$(WASMCC) $^ -o $@ -Os -DNDEBUG --target=wasm32-wasi --sysroot=$(WASIROOT) -nostartfiles -Wl,--no-entry -Wl,--export=pack -Wl,--export=malloc -Wl,--export=free -Wl,--export=__wasm_call_ctors -Wl,-s -Wl,--allow-undefined-file=gltf/wasistubs.txt

build/decoder_base.wasm: $(WASM_DECODER_SOURCES)
Expand Down Expand Up @@ -152,7 +152,7 @@ js/%.module.js: js/%.js
$(DEMO): $(DEMO_OBJECTS) $(LIBRARY)
$(CXX) $^ $(LDFLAGS) -o $@

vcachetuner: tools/vcachetuner.cpp $(BUILD)/tools/meshloader.cpp.o $(BUILD)/demo/miniz.cpp.o $(LIBRARY)
vcachetuner: tools/vcachetuner.cpp tools/objloader.cpp $(LIBRARY)
$(CXX) $^ -fopenmp $(CXXFLAGS) -std=c++11 $(LDFLAGS) -o $@

codecbench: tools/codecbench.cpp $(LIBRARY)
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions tools/objloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif

#define FAST_OBJ_IMPLEMENTATION
#include "../extern/fast_obj.h"

0 comments on commit 19b9a26

Please sign in to comment.