Skip to content
Snippets Groups Projects
Commit 52f2779a authored by Deepak Rangarajan's avatar Deepak Rangarajan
Browse files

add git hash as a property

parent 423c8d16
Branches main
No related tags found
1 merge request!125add git hash as a property
Pipeline #35197 passed
......@@ -60,3 +60,24 @@ install(EXPORT CsgEbConfig
if (CSG_CGAL_ENABLED)
target_compile_definitions(csg-eb PUBLIC USE_CGAL)
endif()
set(CSGEB_GIT_HASH "")
execute_process(
COMMAND git describe --abbrev=12 --dirty --always --tags
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE CSGEB_GIT_HASH
ERROR_VARIABLE _tmperr
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(_tmperr)
message(WARNING "Failing to retrieve Git commit from repo: ${PROJECT_SOURCE_DIR}")
endif()
set_target_properties(csg-eb PROPERTIES CSGEB_GIT_HASH ${CSGEB_GIT_HASH}
EXPORT_PROPERTIES CSGEB_GIT_HASH)
# to be used by gnumake
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CsgEbConfig.mk
"CSGEB_GIT_HASH := ${CSGEB_GIT_HASH}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CsgEbConfig.mk
DESTINATION "${CMAKE_INSTALL_PREFIX}"
)
......@@ -8,6 +8,7 @@
TARGET ?= libcsg-eb.a
BUILD_DIR ?= ./build
CONFIG_FILE ?= CsgEbConfig.mk
SRCFILENAMES := csg.cpp \
levelset_2d.cpp \
......@@ -46,11 +47,15 @@ $(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -std=c++17 -c $< -o $@
$(CONFIG_FILE): $(TARGET)
@echo "CSGEB_GIT_HASH := $(shell git describe --abbrev=12 --dirty --always --tags)" > $@
.PHONY: install
install: $(TARGET)
install: $(TARGET) $(CONFIG_FILE)
@$(MKDIR_P) $(DESTDIR)/lib $(DESTDIR)/include
install -m 0755 $< $(DESTDIR)/lib
install -m 0755 include/*.hpp $(DESTDIR)/include
install -m 0755 $(CONFIG_FILE) $(DESTDIR)
.PHONY: clean
clean:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment