Build static library during Makefile build.
Makes it easier to use SPIRV-Cross as an API. Add some subsection in README about this.
This commit is contained in:
parent
a1fd2403e9
commit
1230dd9fe2
24
Makefile
24
Makefile
@ -1,27 +1,37 @@
|
||||
TARGET := spirv-cross
|
||||
SOURCES := $(wildcard *.cpp)
|
||||
|
||||
SOURCES := $(wildcard spirv_*.cpp)
|
||||
CLI_SOURCES := main.cpp
|
||||
|
||||
OBJECTS := $(SOURCES:.cpp=.o)
|
||||
DEPS := $(OBJECTS:.o=.d)
|
||||
CLI_OBJECTS := $(CLI_SOURCES:.cpp=.o)
|
||||
|
||||
STATIC_LIB := lib$(TARGET).a
|
||||
|
||||
DEPS := $(OBJECTS:.o=.d) $(CLI_OBJECTS:.o=.d)
|
||||
|
||||
CXXFLAGS += -std=c++11 -Wall -Wextra
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CXXFLAGS += -O0 -gdwarf-2
|
||||
CXXFLAGS += -O0
|
||||
else
|
||||
CXXFLAGS += -O2 -gdwarf-2
|
||||
CXXFLAGS += -O2
|
||||
endif
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||
$(TARGET): $(CLI_OBJECTS) $(STATIC_LIB)
|
||||
$(CXX) -o $@ $(CLI_OBJECTS) $(STATIC_LIB) $(LDFLAGS)
|
||||
|
||||
$(STATIC_LIB): $(OBJECTS)
|
||||
$(AR) rcs $@ $(OBJECTS)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $< $(CXXFLAGS) -MMD
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS) $(DEPS)
|
||||
rm -f $(TARGET) $(OBJECTS) $(CLI_OBJECTS) $(STATIC_LIB) $(DEPS)
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -79,6 +79,12 @@ int main()
|
||||
}
|
||||
```
|
||||
|
||||
#### Integrating SPIRV-Cross in a custom build system
|
||||
|
||||
To add SPIRV-Cross to your own codebase, just copy the source and header files from root directory
|
||||
and build the relevant .cpp files you need. Make sure to build with C++11 support, e.g. `-std=c++11` in GCC and Clang.
|
||||
Alternatively, the Makefile generates a libspirv-cross.a static library during build that can be linked in.
|
||||
|
||||
### Creating a SPIR-V file from GLSL with glslang
|
||||
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user