diff --git a/.gitignore b/.gitignore index c795b054e5ade51b7031abab1581a5b7e2d2f5ba..ce8c7f333ab473981aed53e81137279d14c42ce3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -build \ No newline at end of file +__pycache__ +build diff --git a/.spack/repo/packages/csg-eb/package.py b/.spack/repo/packages/csg-eb/package.py new file mode 100644 index 0000000000000000000000000000000000000000..56674970281f2b107b1be5295ad4be02887cb47c --- /dev/null +++ b/.spack/repo/packages/csg-eb/package.py @@ -0,0 +1,37 @@ +# 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 diff --git a/.spack/repo/repo.yaml b/.spack/repo/repo.yaml new file mode 100644 index 0000000000000000000000000000000000000000..007d87a1fe80363cca280f228dc97688cb258598 --- /dev/null +++ b/.spack/repo/repo.yaml @@ -0,0 +1,2 @@ +repo: + namespace: 'csg-eb-ns' diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f8f7ea5d23abcf957f4a9db5a94141185f10d61..e845572831fa6957bf8c2dab6d7a9c51a9c41448 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,12 +28,35 @@ endif() add_subdirectory(src/csg) target_include_directories(csg-eb - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PUBLIC $ + $ 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() diff --git a/README.md b/README.md index c42764c1764f15b1521a21c9ae752315129676ae..3edf3e2ad8eee54bc41993f2a241087c4c352337 100644 --- a/README.md +++ b/README.md @@ -89,3 +89,17 @@ add_subdirectory(/path/to/repo/csg-eb) ```cmake target_link_libraries( PRIVATE csg) ``` + +## Install with Spack + +Another way to install csg-eb is with Spack. See the [Spack documentation](https://spack.readthedocs.io) for instructions on how to install Spack. + + +Then define a recipe for csg-eb: +``` 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 directory with libcsg-eb.a to LD_LIBRARY_PATH +```