Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • exa/csg-eb
  • rangarad/csg-eb
  • jmusser/csg-eb
3 results
Show changes
Commits on Source (4)
build
\ No newline at end of file
__pycache__
build
......@@ -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,10 +44,60 @@ 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
stage: test
image: $CI_REGISTRY_IMAGE:latest
needs: ['build-img']
when: manual
script:
- /usr/local/spack/bin/spack repo add .spack/repo
- /usr/local/spack/bin/spack install csg-eb ${NO_CSG}
tags:
- docker
spack:cgal:
variables:
NO_CSG: ""
<<: *spack_def
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
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
CSG_REPO = "https://mfix.netl.doe.gov/gitlab/exa/csg-eb.git"
CSG_BRANCH = "main"
class CsgEb(CMakePackage):
"""Define Embedded Boundaries (for AMReX) using CSG"""
homepage = "https://mfix.netl.doe.gov/gitlab/exa/csg-eb"
version("main", git=CSG_REPO, branch=CSG_BRANCH)
variant("cgal", default=True, description="Build with CGAL Support")
depends_on("pegtl")
depends_on("catch2")
depends_on("cgal", when="+cgal")
def cmake_args(self):
return [
"-DCSG_CGAL_ENABLED={}".format("True" if "+cgal" in self.spec else "False")
]
def setup_run_environment(self, env):
env.prepend_path("CPATH", self.prefix.include)
@property
def headers(self):
headers = find_all_headers(self.prefix.include)
headers.directories = [self.prefix.include]
return headers
repo:
namespace: 'csg-eb-ns'
......@@ -28,12 +28,35 @@ endif()
add_subdirectory(src/csg)
target_include_directories(csg-eb
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_compile_features(csg-eb PRIVATE cxx_std_17)
file(GLOB headers "include/*.hpp")
install(FILES ${headers}
DESTINATION include
)
install(TARGETS csg-eb
EXPORT CsgEbConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
export(TARGETS csg-eb
NAMESPACE CsgEb::
FILE "${CMAKE_CURRENT_BINARY_DIR}/CsgEbConfig.cmake"
)
install(EXPORT CsgEbConfig
DESTINATION "${CMAKE_INSTALL_PREFIX}"
NAMESPACE CsgEb::
)
if (CSG_CGAL_ENABLED)
target_compile_definitions(csg-eb PUBLIC USE_CGAL)
endif()
......@@ -19,6 +19,10 @@ RUN apt-get -qq update \
&& pip3 install --no-cache-dir \
cmake==3.* \
conan==1.* \
ninja==1.*
ninja==1.* \
&& git clone -c feature.manyFiles=true https://github.com/spack/spack.git /usr/local/spack \
&& PATH=/usr/local/spack/bin:$PATH
CMD [ "/bin/bash" ]
###
### 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
# CSG-EB
# Table of Contents
1. [Dependencies](#dependencies)
2. [Build](#build)
3. [Install with CMake](#install-with-cmake)
4. [Install with Spack](#install-with-spack)
5. [Using CSG-EB in your project](#using-csg-eb-in-your-project)
This library is for parsing [Constructive Solid Geometry
(CSG)](https://github.com/openscad/openscad/wiki/CSG-File-Format) for use in
......@@ -11,33 +16,56 @@ equivalent in the kinds of geometries that can be expressed, but with fewer
primitives (OpenSCAD can export `.scad` files to `.csg`). SCAD code is easier to
read and write by humans; CSG files are easier to parse and process by software.
Dependencies:
- [PEGTL](https://github.com/taocpp/PEGTL) for parsing
- [Catch2](https://github.com/catchorg/Catch2) for testing framework
- [CGAL](https://www.cgal.org) for geometry computation
## Dependencies
If installing with [Spack](#spack), dependencies will be installed automatically.
Install the following dependencies before building `csg-eb`
## How to Build
- C++17 compiler (GCC >=7.x, Clang >=5.x)
- [CMake](https://cmake.org) >=3.14
- [PEGTL](https://github.com/taocpp/PEGTL) for parsing
- [Catch2](https://github.com/catchorg/Catch2) for testing framework
- [CGAL](https://www.cgal.org) for geometry computation
### Build dependencies
- C++17 compiler (GCC >=7.x, Clang >=5.x)
- CMake >=3.14
## Build
```shell
> cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
> cmake --build build
```
#### Run tests
### Run tests
```shell
> cd build
> ctest
```
## Install with CMake
To install `csg-eb` to a location `$CSGEB_HOME`:
``` shell
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$CSGEB_HOME
cmake --build build --target install
```
## Install with Spack
Another way to install csg-eb is with [Spack ](https://spack.readthedocs.io).
To install with spack:
``` shell
spack repo add .spack/repo # add repo with csg-eb recipe
spack spec csg-eb # preview install
spack install csg-eb # install csg-eb (with CGAL support)
spack install csg-eb ~cgal # install csg-eb (without CGAL support)
spack load csg-eb # Adds libcsg-eb.a to LD_LIBRARY_PATH and csg.hpp to CPATH
```
## Using CSG-EB in your project
......
......@@ -29,4 +29,6 @@ if (CSG_CGAL_ENABLED)
target_link_libraries(csg-eb PRIVATE CGAL::CGAL)
endif()
add_subdirectory(tests)
if (BUILD_TESTING)
add_subdirectory(tests)
endif()