Skip to content

Commit 57fa38f

Browse files
committed
add build_libint
take 2 try 3 try 4 try 5 try 6 try 7 libint_maybe_unused build src split
1 parent ae9f528 commit 57fa38f

File tree

13 files changed

+446
-6
lines changed

13 files changed

+446
-6
lines changed

.github/workflows/ci_cmake.yml

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: BuildCM
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
build_repo:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
build_type : [ Release, Debug ]
15+
os : [ macos-latest, ubuntu-20.04 ]
16+
include:
17+
- os: ubuntu-20.04
18+
cxx: g++-10
19+
cc: gcc-10
20+
- os: macos-latest
21+
cxx: clang++
22+
cc: clang
23+
24+
name: "Repo • ${{ matrix.os }}: ${{ matrix.cxx }} ${{ matrix.build_type }}"
25+
runs-on: ${{ matrix.os }}
26+
env:
27+
CC: ${{ matrix.cc }}
28+
CXX : ${{ matrix.cxx }}
29+
CCACHE_DIR : ${{github.workspace}}/build/.ccache
30+
CCACHE_COMPRESS : true
31+
CCACHE_COMPRESSLEVEL : 6
32+
BUILD_CONFIG : >
33+
-G Ninja
34+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
35+
-DBUILD_SHARED_LIBS=OFF
36+
-DMPIEXEC_PREFLAGS='--bind-to;none;--allow-run-as-root'
37+
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/library
38+
-DWITH_MAX_AM=2;2
39+
-DWITH_ERI_MAX_AM=2;2
40+
-DWITH_ERI3_MAX_AM=3;2
41+
-DENABLE_ERI=1
42+
-DENABLE_ERI3=1
43+
-DENABLE_ONEBODY=1
44+
-DDISABLE_ONEBODY_PROPERTY_DERIVS=ON
45+
-DMULTIPOLE_MAX_ORDER=2
46+
-DLIBINT2_ENABLE_PYTHON=ON
47+
48+
outputs:
49+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
# fetch-depth: 0 for git history to compute version
56+
57+
- id: skip_check
58+
name: Check if can skip
59+
uses: fkirc/skip-duplicate-actions@v5
60+
with:
61+
cancel_others: 'true'
62+
63+
- name: Create Build Environment
64+
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
65+
# Some projects don't allow in-source building, so create a separate build directory
66+
# We'll use this as our working directory for all subsequent commands
67+
run: |
68+
cmake -E make_directory ${{github.workspace}}/build/compiler
69+
cmake -E make_directory ${{github.workspace}}/build/library
70+
cmake -E make_directory ${{github.workspace}}/build/library_test
71+
72+
- name: Install prerequisite MacOS packages
73+
if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'macos-latest' }}
74+
run: |
75+
brew install ninja gcc@10 boost eigen ccache [email protected] numpy scipy
76+
echo "FC=/usr/local/bin/gfortran-10" >> $GITHUB_ENV
77+
echo "EIGEN3_INCLUDE_DIR=/usr/local/include/eigen3" >> $GITHUB_ENV
78+
79+
- name: Install prerequisite Ubuntu packages
80+
if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'ubuntu-20.04' }}
81+
run: |
82+
sudo apt-get update
83+
sudo apt-get install ninja-build g++-10 gfortran-10 liblapack-dev libboost-dev libeigen3-dev ccache python3-numpy python3-scipy
84+
echo "FC=/usr/bin/gfortran-10" >> $GITHUB_ENV
85+
echo "EIGEN3_INCLUDE_DIR=/usr/include/eigen3" >> $GITHUB_ENV
86+
87+
- name: Prepare ccache timestamp
88+
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
89+
id: ccache_cache_timestamp
90+
shell: cmake -P {0}
91+
run: |
92+
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
93+
message("\"timestamp=${current_date}\" >> $GITHUB_OUTPUT")
94+
95+
- name: Setup ccache cache files
96+
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
97+
uses: actions/cache@v3
98+
with:
99+
path: ${{github.workspace}}/build/.ccache
100+
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
101+
restore-keys: |
102+
${{ matrix.config.name }}-ccache-
103+
104+
- name: Generate Libint generator
105+
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
106+
# Use a bash shell so we can use the same syntax for environment variable
107+
# access regardless of the host operating system
108+
shell: bash
109+
working-directory: ${{github.workspace}}/build/compiler
110+
run: |
111+
git describe --tags
112+
cmake -S ../.. -B build $BUILD_CONFIG --log-level=DEBUG
113+
cmake --build build --target check-libint2compiler
114+
115+
- name: Generate Libint library
116+
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
117+
shell: bash
118+
working-directory: ${{github.workspace}}/build/compiler
119+
run: |
120+
cmake --build build --target libint-library-generate
121+

.github/workflows/cmake.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- master
7-
pull_request:
7+
#pull_request:
88

99
jobs:
1010
build_repo:

CMakeLists.txt

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
44
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
55
cmake_policy(SET CMP0135 NEW)
66
endif()
7+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0")
8+
# needed by DynamicVersion
9+
cmake_policy(SET CMP0140 NEW)
10+
endif()
711

812
############################# Version and Metadata #############################
913

@@ -103,9 +107,6 @@ option_with_default(LIBINT2_ENABLE_PYTHON
103107
option_with_default(LIBINT2_PREFIX_PYTHON_INSTALL
104108
"For LIBINT2_ENABLE_PYTHON=ON, whether to install the Python module in the Linux manner to CMAKE_INSTALL_PREFIX or to not install it. See target libint2-python-wheel for alternate installation in the Python manner to Python_EXECUTABLE's site-packages." OFF)
105109

106-
option_with_print(LIBINT2_ENABLE_MPFR
107-
"Use GNU MPFR library for high-precision testing (EXPERTS ONLY). Consumed at library build-time." OFF)
108-
## next one defined by `include(CTest)`
109110

110111
# <<< Which Integrals Classes, Which Derivative Levels >>>
111112

@@ -262,10 +263,15 @@ option_with_print(LIBINT_FLOP_COUNT
262263
"Support (approximate) FLOP counting by the library. (Generated code will require C++11!)" OFF)
263264
option_with_print(LIBINT_PROFILE
264265
"Turn on profiling instrumentation of the library. (Generated code will require C++11!)" OFF)
266+
option_with_print(LIBINT2_ENABLE_MPFR
267+
"Use GNU MPFR library for high-precision testing (EXPERTS ONLY). Consumed at library build-time." OFF)
268+
# next one defined by `include(CTest)`
269+
message(STATUS "Showing option BUILD_TESTING: ${BUILD_TESTING}")
265270

266-
271+
# <<< Path >>>
267272

268273
######################## Process & Validate Options ###########################
274+
include(autocmake_safeguards)
269275
include(CheckFunctionExists)
270276
include(CheckIncludeFileCXX)
271277
include(FeatureSummary)

INSTALL.md

+23
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ The Libint build is structured into three parts:
5858
- (7) optional Python build alongside library or afterwards. optional testing requires library install
5959

6060

61+
Command-line synopsis. See [table](#Build-Targets) for `--target` choices (steps refer to numbered bullets above) and [section](#Configuring-Libint) for `-D options` choices.
62+
63+
```bash
64+
>>> git clone https://github.com/evaleev/libint.git && cd libint
65+
>>> ls
66+
cmake/ COPYING src/ tests/ ...
67+
>>> cmake -S. -Bbuild -GNinja -DCMAKE_INSTALL_PREFIX=/path/to/future/install-libint -D options ...
68+
...
69+
-- Generating done
70+
-- Build files have been written to: /current/dir/build
71+
>>> cmake --build build --target install
72+
```
73+
74+
### Build Targets
75+
76+
| `--target ...` | incl. | steps | ( | see | above | ) | | (TARBALL) `--target ...` [^25] |
77+
| -------------- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ------------------------------ |
78+
| `build_libint` | 1 | - | - | - | - | - | - | n/a |
79+
| `check-libint2compiler` | 1 | 2 | - | - | - | - | - | n/a |
80+
81+
[^25]: (TARBALL) targets can include steps 4 onwards; the starting tarball itself is the product of step 3.
82+
83+
6184
-----------------------------------------------------------------------------
6285

6386
# Prerequisites
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2020 Eduard F Valeyev
2+
# Distributed under the OSI-approved BSD 3-Clause License.
3+
# See https://opensource.org/licenses/BSD-3-Clause for details.
4+
5+
# copy of https://github.com/BTAS/BTAS/blob/master/cmake/modules/AddCustomTargetSubproject.cmake
6+
#
7+
# add_custom_target_subproject(proj X ...) defines custom target X-proj and
8+
# - if target X already exists, makes it depend on X-proj
9+
# - else creates target X depending on X-proj
10+
#
11+
# use case: if custom target names (e.g. "check", "doc", etc.) clash
12+
# with other project's target when used as a subproject
13+
#
14+
# example: add_custom_target_subproject(myproject check USES_TERMINAL COMMAND ${CMAKE_CTEST_COMMAND} -V)
15+
#
16+
17+
macro(add_custom_target_subproject _subproj _name)
18+
19+
set(extra_args "${ARGN}")
20+
add_custom_target(${_name}-${_subproj} ${extra_args})
21+
22+
# does the newly-created target get compiled by default?
23+
list(FIND extra_args "ALL" extra_args_has_all)
24+
if (NOT (extra_args_has_all EQUAL -1))
25+
set (target_built_by_default ON)
26+
endif()
27+
28+
if (TARGET ${_name})
29+
# is existing target ${_name} also compiled by default?
30+
# warn if not, but this project's target is since that
31+
# may indicate inconsistent creation of generic targets
32+
get_target_property(supertarget_not_built_by_default ${_name} EXCLUDE_FROM_ALL)
33+
if (target_built_by_default AND supertarget_not_built_by_default)
34+
message(WARNING "Created target ${_name}-${_subproj} is built by default but \"super\"-target ${_name} is not; perhaps it should be?")
35+
endif()
36+
add_dependencies(${_name} ${_name}-${_subproj})
37+
else (TARGET ${_name})
38+
# use ALL if given
39+
if (target_built_by_default)
40+
add_custom_target(${_name} ALL DEPENDS ${_name}-${_subproj})
41+
else (target_built_by_default)
42+
add_custom_target(${_name} DEPENDS ${_name}-${_subproj})
43+
endif(target_built_by_default)
44+
endif (TARGET ${_name})
45+
46+
endmacro()
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Downloaded from
2+
# https://github.com/coderefinery/autocmake/blob/master/modules/safeguards.cmake
3+
# * changed text of in-source message
4+
5+
#.rst:
6+
#
7+
# Provides safeguards against in-source builds and bad build types.
8+
#
9+
# Variables used::
10+
#
11+
# PROJECT_SOURCE_DIR
12+
# PROJECT_BINARY_DIR
13+
# CMAKE_BUILD_TYPE
14+
15+
if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
16+
message(FATAL_ERROR "In-source builds not allowed. Please run CMake from top directory and specify a build directory (e.g., cmake -S. -Bbuild).")
17+
endif()
18+
19+
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
20+
string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper)
21+
22+
if(NOT cmake_build_type_tolower STREQUAL "debug" AND
23+
NOT cmake_build_type_tolower STREQUAL "release" AND
24+
NOT cmake_build_type_tolower STREQUAL "minsizerel" AND
25+
NOT cmake_build_type_tolower STREQUAL "relwithdebinfo")
26+
message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, MinSizeRel, RelWithDebInfo (case-insensitive).")
27+
endif()

include/libint2/config.h.cmake.in

+16
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,22 @@
326326
#define LIBINT_DEPRECATED(msg) LIBINT_XPRAGMA( LIBINT_CONCAT(message, msg) )
327327
#endif
328328

329+
#ifdef __has_cpp_attribute
330+
#if __has_cpp_attribute(maybe_unused)
331+
#define LIBINT_MAYBE_UNUSED [[maybe_unused]]
332+
#endif
333+
#endif // __has_cpp_attribute
334+
#ifndef LIBINT_MAYBE_UNUSED
335+
#if defined __has_attribute
336+
# if __has_attribute (unused)
337+
# define LIBINT_MAYBE_UNUSED __attribute__ ((unused))
338+
# endif
339+
#endif // __has_attribute
340+
#endif // LIBINT_MAYBE_UNUSED
341+
#ifndef LIBINT_MAYBE_UNUSED // fallback
342+
#define LIBINT_MAYBE_UNUSED
343+
#endif
344+
329345
#if @_EXPORT_MODE@
330346
#include "libint2/config2.h"
331347
#endif

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
add_subdirectory(bin)
12
add_subdirectory(lib)

src/bin/CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
add_subdirectory(libint)
2+
3+
include(AddCustomTargetSubproject)
4+
add_custom_target_subproject(
5+
libint2compiler
6+
check
7+
USES_TERMINAL
8+
COMMAND ${CMAKE_CTEST_COMMAND} -V -R "libint2/compiler"
9+
)
10+
11+
if (BUILD_TESTING)
12+
add_subdirectory(test_eri)
13+
# borrows main libint/test.cc from libtool layout
14+
add_subdirectory(profile)
15+
endif()

0 commit comments

Comments
 (0)