From e0498196e35bd91c7e10e163a0970966944824e8 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Fri, 29 Dec 2023 00:37:16 -0500 Subject: [PATCH] split --- .github/workflows/ci_cmake.yml | 47 ++++++------------------ CMakeLists.txt | 1 + cmake/modules/autocmake_safeguards.cmake | 27 ++++++++++++++ 3 files changed, 40 insertions(+), 35 deletions(-) create mode 100644 cmake/modules/autocmake_safeguards.cmake diff --git a/.github/workflows/ci_cmake.yml b/.github/workflows/ci_cmake.yml index c36fcf66c..3edba671b 100644 --- a/.github/workflows/ci_cmake.yml +++ b/.github/workflows/ci_cmake.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: build_type : [ Release, Debug ] - os : [ macos-latest, ubuntu-20.04] + os : [ macos-latest, ubuntu-20.04 ] include: - os: ubuntu-20.04 cxx: g++-10 @@ -52,7 +52,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - # fetch-depth: 0 gets git history to compute version + # fetch-depth: 0 for git history to compute version - id: skip_check name: Check if can skip @@ -84,35 +84,6 @@ jobs: echo "FC=/usr/bin/gfortran-10" >> $GITHUB_ENV echo "EIGEN3_INCLUDE_DIR=/usr/include/eigen3" >> $GITHUB_ENV - - name: Install Windows prerequisites, part 1, Create Conda Environment - if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'windows-latest' }} - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: "" - auto-activate-base: true - show-channel-urls: true - miniforge-variant: Mambaforge - use-mamba: true - channels: conda-forge - add-pip-as-python-dependency: true - - # Note: `shell: bash -l {0}` makes Miniconda created above for Windows available to - # subsequent steps. see https://github.com/conda-incubator/setup-miniconda#usage-examples - - - name: Install Windows prerequisites, part 2, Environment Information - if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'windows-latest' }} - shell: bash -l {0} - run: | - mamba info - mamba install ninja cmake=3.21 python mpir boost eigen ccache -c conda-forge --yes - mamba list - - - name: Prepare compiler environment for Windows - if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'windows-latest' }} - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: x64 - - name: Prepare ccache timestamp if: ${{ steps.skip_check.outputs.should_skip != 'true' }} id: ccache_cache_timestamp @@ -130,15 +101,21 @@ jobs: restore-keys: | ${{ matrix.config.name }}-ccache- - - name: Generate Libint library + - name: Generate Libint generator if: ${{ steps.skip_check.outputs.should_skip != 'true' }} # Use a bash shell so we can use the same syntax for environment variable # access regardless of the host operating system - shell: bash -l {0} + shell: bash working-directory: ${{github.workspace}}/build/compiler run: | - ls ${{github.workspace}} git describe --tags cmake -S ../.. -B build $BUILD_CONFIG --log-level=DEBUG - cmake --build build --target check-libint2compiler libint-library-generate + cmake --build build --target check-libint2compiler + + - name: Generate Libint library + if: ${{ steps.skip_check.outputs.should_skip != 'true' }} + shell: bash + working-directory: ${{github.workspace}}/build/compiler + run: | + cmake --build build --target libint-library-generate diff --git a/CMakeLists.txt b/CMakeLists.txt index 14e75690d..0813855f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,6 +271,7 @@ message(STATUS "Showing option BUILD_TESTING: ${BUILD_TESTING}") # <<< Path >>> ######################## Process & Validate Options ########################### +include(autocmake_safeguards) include(CheckFunctionExists) include(CheckIncludeFileCXX) include(FeatureSummary) diff --git a/cmake/modules/autocmake_safeguards.cmake b/cmake/modules/autocmake_safeguards.cmake new file mode 100644 index 000000000..cf7d56757 --- /dev/null +++ b/cmake/modules/autocmake_safeguards.cmake @@ -0,0 +1,27 @@ +# Downloaded from +# https://github.com/coderefinery/autocmake/blob/master/modules/safeguards.cmake +# * changed text of in-source message + +#.rst: +# +# Provides safeguards against in-source builds and bad build types. +# +# Variables used:: +# +# PROJECT_SOURCE_DIR +# PROJECT_BINARY_DIR +# CMAKE_BUILD_TYPE + +if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) + message(FATAL_ERROR "In-source builds not allowed. Please run CMake from top directory and specify a build directory (e.g., cmake -S. -Bbuild).") +endif() + +string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower) +string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper) + +if(NOT cmake_build_type_tolower STREQUAL "debug" AND + NOT cmake_build_type_tolower STREQUAL "release" AND + NOT cmake_build_type_tolower STREQUAL "minsizerel" AND + NOT cmake_build_type_tolower STREQUAL "relwithdebinfo") + message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, MinSizeRel, RelWithDebInfo (case-insensitive).") +endif()