From b7563a5ae0833b414e03b817bd9d832091fad132 Mon Sep 17 00:00:00 2001 From: Mark Meredith <mark.meredith@netl.doe.gov> Date: Mon, 17 Jan 2022 19:13:05 +0000 Subject: [PATCH] Build with GNU Makefile --- .gitlab-ci.yml | 40 ++++++++++++++++++++++++++++---- GNUmakefile | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 GNUmakefile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0b4c5d..3b9e2c2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,10 @@ build-img: needs: ['build-img'] script: - conan install -if build -g cmake_find_package catch2/2.13.7@ - - if [ "$ENABLE_CSG" == "ON" ]; then conan install -if build -g cmake_find_package cgal/5.2.1@; fi + - | + if [ "$ENABLE_CGAL" == "ON" ]; then + conan install -if build -g cmake_find_package cgal/5.2.1@ + fi - conan install -if build -g cmake_find_package taocpp-pegtl/3.2.1@ - cmake -S. @@ -32,7 +35,7 @@ build-img: -GNinja -DCMAKE_MODULE_PATH=$PWD/build -DCMAKE_BUILD_TYPE=Debug - -DCSG_CGAL_ENABLED=${ENABLE_CSG} + -DCSG_CGAL_ENABLED=${ENABLE_CGAL} - cmake --build build --target unit_tests_csg - cd build - ctest @@ -41,12 +44,12 @@ build-img: test:cgal: variables: - ENABLE_CSG: "ON" + ENABLE_CGAL: "ON" <<: *cmake_def test:no_cgal: variables: - ENABLE_CSG: "OFF" + ENABLE_CGAL: "OFF" <<: *cmake_def .test:spack: &spack_def @@ -69,3 +72,32 @@ spack:no_cgal: variables: NO_CSG: "~cgal" <<: *spack_def + +.test:gnumake: &gnumake_def + stage: test + variables: + BUILD: ${CI_PROJECT_DIR}/build + BOOST_HOME: ${BUILD}/boost + CATCH2_HOME: ${BUILD}/catch2 + CGAL_HOME: ${BUILD}/cgal + PEGTL_HOME: ${BUILD}/taocpp-pegtl + image: $CI_REGISTRY_IMAGE:latest + needs: ['build-img'] + script: + - conan install -if build -g deploy catch2/2.13.7@ + - | + if [ "$ENABLE_CGAL" == "ON" ]; then + conan install -if build -g deploy cgal/5.2.1@ + fi + - conan install -if build -g deploy taocpp-pegtl/3.2.1@ + - make install DESTDIR=the_destination + tags: + - docker + +gnumake:cgal: + variables: + ENABLE_CGAL: "ON" + <<: *gnumake_def + +gnumake:no_cgal: + <<: *gnumake_def diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..6e409f0 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,62 @@ +### +### Makefile for building libcsgeb.a with GNU Make. +### Only works with GCC compiler +### Expects to find paths for dependencies defined in: BOOST_HOME, CATCH2_HOME, CGAL_HOME, PEGTL_HOME +### + + + +TARGET ?= libcsgeb.a +BUILD_DIR ?= ./build + +SRCFILENAMES := csg.cpp \ + levelset_2d.cpp \ + levelset_3d.cpp \ + matrix_functions.cpp \ + parser.cpp \ + exception.cpp \ + $(if $(ENABLE_CGAL),cgal_helper_polygon.cpp,) \ + $(if $(ENABLE_CGAL),cgal_helper_polyhedron.cpp,) + +SRCS := $(SRCFILENAMES:%=./src/csg/%) +OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) +DEPS := $(OBJS:.o=.d) + +INC_DIRS := src include +INC_DIRS += $(BOOST_HOME)/include +INC_DIRS += $(CATCH2_HOME)/include +INC_DIRS += $(CGAL_HOME)/include +INC_DIRS += $(PEGTL_HOME)/include + +INC_FLAGS := $(addprefix -I,$(INC_DIRS)) + +CPPFLAGS ?= $(INC_FLAGS) -MMD -MP + +ifdef $(ENABLE_CGAL) + CPPFLAGS += -DUSE_CGAL +endif + +$(TARGET): $(OBJS) + @ar rcs $(TARGET) $(OBJS) + +$(BUILD_DIR)/$(TARGET): $(OBJS) + $(CXX) $(OBJS) -o $@ $(LDFLAGS) + +$(BUILD_DIR)/%.cpp.o: %.cpp + $(MKDIR_P) $(dir $@) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -std=c++17 -c $< -o $@ + +.PHONY: install +install: $(TARGET) + @$(MKDIR_P) $(DESTDIR)/lib $(DESTDIR)/include + install -m 0755 $< $(DESTDIR)/lib + install -m 0755 include/*.hpp $(DESTDIR)/include + +.PHONY: clean +clean: + $(RM) -r $(BUILD_DIR) + + +-include $(DEPS) + +MKDIR_P ?= mkdir -p -- GitLab