Commit d5e4a974 authored by Mark Meredith's avatar Mark Meredith
Browse files

Reorganize CMake

parent 48625d30
Loading
Loading
Loading
Loading
Loading
+14 −19
Original line number Diff line number Diff line
@@ -4,6 +4,11 @@ stages:
  - build-img
  - test

variables:
  CONAN_LOGIN_USERNAME: ci_user
  CONAN_PASSWORD: ${CI_JOB_TOKEN}
  REPO: gitlab

build-img:
  stage: build-img
  image:
@@ -17,31 +22,21 @@ build-img:
    - docker


###### Test jobs #####

.test:cmake: &cmake_def
.package: &package_template
  stage: test
  image: $CI_REGISTRY_IMAGE:latest
  needs: ['build-img']
  script:
    - cmake -S. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE
    - cmake --build build --target unit_tests_csg
    - cd build
    - ctest
    - conan create . exa/stable -s compiler=${COMPILER} -s compiler.version=${CVERSION} -s compiler.libcxx=${LIBCXX}
    - conan remote add ${REPO} ${CI_API_V4_URL}/projects/$CI_PROJECT_ID/packages/conan
    - conan upload csg-eb/0.1@exa/stable --all --remote=${REPO}
  tags:
    - docker

test:cmake:debug:
  variables:
    BUILD_TYPE: "Debug"
    CC: "gcc"
    CXX: "g++"
  <<: *cmake_def

test:cmake:release:
package:gcc:
  variables:
    BUILD_TYPE: "Release"
    CC: "gcc"
    CXX: "g++"
  allow_failure: true
  <<: *cmake_def
    COMPILER: gcc
    CVERSION: 9
    LIBCXX: libstdc++
  <<: *package_template
+46 −33
Original line number Diff line number Diff line
@@ -10,16 +10,15 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
  set( CMAKE_CXX_COMPILER_LAUNCHER ccache )
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
   message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
   file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"
      "${CMAKE_BINARY_DIR}/conan.cmake"
      EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484
      TLS_VERIFY ON)
endif()

include(conan.cmake)
conan_cmake_configure(REQUIRES catch2/2.13.7
                               cgal/5.2.1
                               taocpp-pegtl/3.2.1
                      GENERATORS cmake_find_package)
include(${CMAKE_BINARY_DIR}/conan.cmake)

if(CONAN_SETTINGS)
   set(settings ${CONAN_SETTINGS})
@@ -27,29 +26,43 @@ else()
   conan_cmake_autodetect(settings)
endif()

conan_cmake_install(PATH_OR_REFERENCE .
                    REMOTE conancenter
                    SETTINGS ${settings})

include(CTest)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR})
find_package(CGAL REQUIRED)
find_package(Catch2 REQUIRED)
find_package(pegtl REQUIRED)
find_program(CONAN_FOUND conan)
if(NOT CONAN_FOUND)
   message(WARNING "
   Did not find conan in PATH. Recommend installing with 'pip install conan'.
   Will try downloading Conan with PMM <https://github.com/vector-of-bool/pmm>")
   include(pmm.cmake)
   pmm(CONAN)
endif()

include(Catch)
conan_cmake_configure(REQUIRES
   catch2/2.13.7
   GENERATORS cmake_find_package)

if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
  set(MFIXPARSER_CATCH2_DIR ${CONAN_BUILD_DIRS_CATCH2} PARENT_SCOPE)
  set(MFIXPARSER_CATCH2_INC ${CONAN_INCLUDE_DIRS_CATCH2} PARENT_SCOPE)
endif()
conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt
   BUILD missing
   SETTINGS ${settings})

add_subdirectory(src/csg)
conan_cmake_configure(REQUIRES
   csg-eb/0.1@exa/stable
   GENERATORS cmake_find_package)

target_include_directories(csg
  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
conan_add_remote(
   NAME mfix-gitlab
   INDEX 1
   URL https://mfix.netl.doe.gov/gitlab/api/v4/projects/292/packages/conan
   VERIFY_SSL True
)

target_compile_features(csg PRIVATE cxx_std_17)
conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt
   BUILD missing
   SETTINGS ${settings})

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})

find_package(Catch2 REQUIRED)
find_package(csg-eb REQUIRED)

conan.cmake

deleted100644 → 0
+0 −904

File deleted.

Preview size limit exceeded, changes collapsed.

conanfile.py

0 → 100644
+37 −0
Original line number Diff line number Diff line
import shutil
import sys

from conans import ConanFile, Meson


class CsgEbConan(ConanFile):
    name = "csg-eb"
    version = "0.1"
    license = "<Put the package license here>"
    author = "Deepak Rangarajan <Deepak.Rangarajan@netl.doe.gov>"
    url = "https://mfix.netl.doe.gov/gitlab/exa/csg-eb"
    description = "Library for reading CSG geometry files"
    topics = ("<Put some tag here>", "<here>", "<and here>")
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False]}
    default_options = {"shared": False}
    generators = "pkg_config"
    requires = ("catch2/2.13.7", "cgal/5.2.1", "taocpp-pegtl/3.2.0")
    build_requires = ("meson/0.59.2", "pkgconf/1.7.4", "ninja/1.10.2")
    exports_sources = "meson.build", "include/*", "src/*"

    def build(self):
        meson = Meson(self)
        args = ["-Dcpp_std=vc++latest"] if sys.platform in ("win32", "cygwin") else []
        meson.configure(build_folder="build", args=args)
        meson.build()
        meson.meson_test(args=["--verbose", "--print-errorlog"])

    def package(self):
        self.copy("*.hpp", dst="include", src="include", keep_path=False)
        self.copy("*.a", dst="lib", keep_path=False)

    def package_info(self):
        self.cpp_info.includedirs = ["include"]
        self.cpp_info.libs = ["csg-eb"]
        self.cpp_info.defines = ["CSG_EB=1"]

pmm.cmake

0 → 100644
+84 −0
Original line number Diff line number Diff line
## MIT License
##
## Copyright (c) 2019 vector-of-bool
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in all
## copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.

# Bump this version to change what PMM version is downloaded
set(PMM_VERSION_INIT 1.5.1)

# Helpful macro to set a variable if it isn't already set
macro(_pmm_set_if_undef varname)
    if(NOT DEFINED "${varname}")
        set("${varname}" "${ARGN}")
    endif()
endmacro()

## Variables used by this script
# The version:
_pmm_set_if_undef(PMM_VERSION ${PMM_VERSION_INIT})
# The base URL we download PMM from:
_pmm_set_if_undef(PMM_URL_BASE "https://vector-of-bool.github.io/pmm")
# The real URL we download from (Based on the version)
_pmm_set_if_undef(PMM_URL "${PMM_URL_BASE}/${PMM_VERSION}")
# The directory where we store our downloaded files
_pmm_set_if_undef(PMM_DIR_BASE "${CMAKE_BINARY_DIR}/_pmm")
_pmm_set_if_undef(PMM_DIR "${PMM_DIR_BASE}/${PMM_VERSION}")
# The location of the current file
_pmm_set_if_undef(PMM_MODULE "${CMAKE_CURRENT_LIST_FILE}")

# The file that we first download
set(_PMM_ENTRY_FILE "${PMM_DIR}/entry.cmake")

# Guard against multiple processes trying to use the PMM dir simultaneously
file(LOCK "${PMM_DIR}/_init-pmm"
    GUARD PROCESS
    TIMEOUT 10
    RESULT_VARIABLE _lock_res
    )
if(NOT _lock_res STREQUAL "0")
    message(WARNING "PMM entry didn't lock the directory ${PMM_DIR} successfully (${_lock_res}). We'll continue as best we can.")
    set(_pmm_init_did_lock FALSE)
else()
    set(_pmm_init_did_lock TRUE)
endif()

if(NOT EXISTS "${_PMM_ENTRY_FILE}" OR PMM_ALWAYS_DOWNLOAD)
    file(
        DOWNLOAD "${PMM_URL}/entry.cmake"
        "${_PMM_ENTRY_FILE}.tmp"
        STATUS pair
        )
    list(GET pair 0 rc)
    list(GET pair 1 msg)
    if (rc)
        message(FATAL_ERROR "Failed to download PMM entry file: ${msg}")
    endif ()
    file(RENAME "${_PMM_ENTRY_FILE}.tmp" "${_PMM_ENTRY_FILE}")
endif()

# ^^^ DO NOT CHANGE THIS LINE vvv
set(_PMM_BOOTSTRAP_VERSION 3)
# ^^^ DO NOT CHANGE THIS LINE ^^^

include("${_PMM_ENTRY_FILE}")

if(_pmm_init_did_lock)
    file(LOCK "${PMM_DIR}/_init-pmm" RELEASE)
endif()