Skip to content

Commit ee93781

Browse files
committed
base lib
take 2 take 3 take 4 take 5 take 6 take 7 take 8 take 9 take 10 take 11 take 12 take 13 take 14
1 parent 82c98d3 commit ee93781

File tree

12 files changed

+556
-51
lines changed

12 files changed

+556
-51
lines changed

.github/workflows/ci_cmake.yml

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
- os: macos-latest
2121
cxx: clang++
2222
cc: clang
23+
- build_type: Release
24+
build_shared_libs: ON
25+
- build_type: Debug
26+
build_shared_libs: OFF
2327

2428
name: "Repo • ${{ matrix.os }}: ${{ matrix.cxx }} ${{ matrix.build_type }}"
2529
runs-on: ${{ matrix.os }}
@@ -32,7 +36,7 @@ jobs:
3236
BUILD_CONFIG : >
3337
-G Ninja
3438
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
35-
-DBUILD_SHARED_LIBS=OFF
39+
-DBUILD_SHARED_LIBS=${{ matrix.build_shared_libs }}
3640
-DMPIEXEC_PREFLAGS='--bind-to;none;--allow-run-as-root'
3741
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/library
3842
-DWITH_MAX_AM=2;2
@@ -112,10 +116,154 @@ jobs:
112116
cmake -S ../.. -B build $BUILD_CONFIG --log-level=DEBUG
113117
cmake --build build --target check-libint2compiler
114118
119+
- name: Generate Libint export
120+
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
121+
shell: bash
122+
working-directory: ${{github.workspace}}/build/compiler
123+
run: |
124+
cmake --build build --target export
125+
cd build && echo "ARTIFACT=`ls -1 libint*tgz`" >> $GITHUB_ENV
126+
127+
- name: Archive Library Tarball
128+
if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.build_type == 'Release'}}
129+
uses: actions/upload-artifact@v3
130+
with:
131+
if-no-files-found: error
132+
name: ${{ runner.os }}-${{ matrix.cxx }}
133+
path: ${{github.workspace}}/build/compiler/build/${{ env.ARTIFACT }}
134+
retention-days: 1
135+
115136
- name: Generate Libint library
116137
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
117138
shell: bash
118139
working-directory: ${{github.workspace}}/build/compiler
119140
run: |
120-
cmake --build build --target libint-library-generate
141+
cmake --build build --target library check-libint2
142+
cd build && echo "ARTIFACT=`ls -1 libint*tgz`" >> $GITHUB_ENV
143+
144+
#rm -rf buildcm/ && cmake -S. -Bbuildcm -GNinja -DEXPORT_COMPRESSOR=bzip2 -DWITH_MAX_AM="2;2" -DWITH_ERI_MAX_AM="2;2" -DWITH_ERI3_MAX_AM="3;2" -DENABLE_ERI=1 -DENABLE_ERI3=1 -DMULTIPOLE_MAX_ORDER=2 -DBUILD_SHARED_LIBS=ON && time cmake --build buildcm --target check-libint2
145+
146+
build_export:
147+
needs: build_repo
148+
if: always() && (needs.build_repo.outputs.should_skip != 'true')
149+
strategy:
150+
fail-fast: false
151+
matrix:
152+
cfg:
153+
- runs-on: ubuntu-latest
154+
lane: ubuntu-gnu
155+
libargs: >
156+
-DBUILD_SHARED_LIBS=ON
157+
testargs: ""
158+
159+
- runs-on: windows-latest
160+
lane: windows-clang-cl
161+
libargs: >
162+
-GNinja
163+
-DCMAKE_BUILD_TYPE=Release
164+
-DBUILD_SHARED_LIBS=OFF
165+
-DCMAKE_CXX_COMPILER=clang-cl
166+
-DCMAKE_C_COMPILER=clang-cl
167+
testargs: >
168+
-GNinja
169+
-DCMAKE_BUILD_TYPE=Release
170+
-DCMAKE_CXX_COMPILER=clang-cl
171+
-DCMAKE_C_COMPILER=clang-cl
172+
173+
- runs-on: macos-latest
174+
lane: macos-clang
175+
libargs: >
176+
-DBUILD_SHARED_LIBS=ON
177+
testargs: ""
178+
179+
- runs-on: ubuntu-latest
180+
lane: ubuntu-intel
181+
libargs: >
182+
-DCMAKE_CXX_COMPILER=icpx
183+
-DCMAKE_CXX_FLAGS="--gcc-toolchain=${CONDA_PREFIX} --sysroot=${CONDA_PREFIX}/${HOST}/sysroot -target ${HOST}"
184+
testargs: >
185+
-DCMAKE_CXX_COMPILER=icpx
186+
-DCMAKE_CXX_FLAGS="--gcc-toolchain=${CONDA_PREFIX} --sysroot=${CONDA_PREFIX}/${HOST}/sysroot -target ${HOST}"
187+
188+
name: "Export • ${{ matrix.cfg.lane }}"
189+
runs-on: ${{ matrix.cfg.runs-on }}
190+
191+
steps:
192+
# Note we're not checking out the repo. All src from Linux tarball generated above.
193+
194+
- name: Write a Conda Env File
195+
shell: bash -l {0}
196+
run: |
197+
cat > export.yaml <<EOF
198+
name: test
199+
channels:
200+
- conda-forge
201+
dependencies:
202+
- cmake
203+
- ninja
204+
- cxx-compiler
205+
- python
206+
- boost
207+
- eigen
208+
- numpy
209+
- scipy
210+
- pybind11
211+
#- dpcpp_linux-64
212+
EOF
213+
if [[ "${{ runner.os }}" == "Windows" ]]; then
214+
sed -i "s/- cxx/#- cxx/g" export.yaml
215+
fi
216+
if [[ "${{ matrix.cfg.lane }}" == "ubuntu-intel" ]]; then
217+
sed -i "s/#- dpcpp_linux-64/- dpcpp_linux-64/g" export.yaml
218+
fi
219+
cat export.yaml
220+
221+
- name: Create Conda Environment
222+
uses: conda-incubator/setup-miniconda@v2
223+
with:
224+
miniforge-variant: Mambaforge
225+
use-mamba: true
226+
python-version: "3.9"
227+
activate-environment: test
228+
channels: conda-forge
229+
environment-file: export.yaml
230+
show-channel-urls: true
231+
232+
- name: Environment Information
233+
shell: bash -l {0}
234+
run: |
235+
conda info
236+
conda list
237+
238+
- name: Prepare compiler environment for Windows
239+
if: ${{ runner.os == 'Windows' }}
240+
uses: ilammy/msvc-dev-cmd@v1
241+
with:
242+
arch: x64
243+
244+
- uses: actions/download-artifact@v3
245+
with:
246+
name: Linux-g++-10
247+
248+
- name: Extract, Build, Install Libint Library
249+
shell: bash -l {0}
250+
run: |
251+
tar -zxf libint*tgz
252+
mkdir libint && mv libint-2*/* libint/ && cd libint/
253+
cmake \
254+
-S. \
255+
-Bbuild \
256+
-GNinja \
257+
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/installed" \
258+
-DCMAKE_CXX_COMPILER=${CXX} \
259+
-DLIBINT2_PYTHON=OFF \
260+
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
261+
${{ matrix.cfg.libargs }}
262+
cmake --build build --target install
263+
264+
- name: Test Libint library - unit tests
265+
shell: bash -l {0}
266+
working-directory: ${{github.workspace}}/libint/build
267+
run: |
268+
cmake --build . --target check
121269

.github/workflows/cmake.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
cmake_minimum_required(VERSION 3.19) # string(json
22
cmake_policy(SET CMP0074 NEW)
3-
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
3+
if (POLICY CMP0135)
44
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
55
cmake_policy(SET CMP0135 NEW)
6-
endif()
7-
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0")
8-
# needed by DynamicVersion
9-
cmake_policy(SET CMP0140 NEW)
10-
endif()
6+
endif ()
117

128
############################# Version and Metadata #############################
139

@@ -111,6 +107,10 @@ option_with_default(LIBINT2_ENABLE_PYTHON
111107
option_with_default(LIBINT2_PREFIX_PYTHON_INSTALL
112108
"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)
113109

110+
option_with_print(BUILD_SHARED_LIBS
111+
"Build Libint library as shared, not static" OFF)
112+
option_with_print(LIBINT2_BUILD_SHARED_AND_STATIC_LIBS
113+
"Build both shared and static Libint libraries in one shot. Uses -fPIC." OFF)
114114

115115
# <<< Which Integrals Classes, Which Derivative Levels >>>
116116

@@ -269,6 +269,8 @@ option_with_print(LIBINT_PROFILE
269269
"Turn on profiling instrumentation of the library. (Generated code will require C++11!)" OFF)
270270
option_with_print(LIBINT2_ENABLE_MPFR
271271
"Use GNU MPFR library for high-precision testing (EXPERTS ONLY). Consumed at library build-time." OFF)
272+
option_with_default(EXPORT_COMPRESSOR
273+
"Export tarball with compression gzip or bzip2" gzip)
272274
# next one defined by `include(CTest)`
273275
message(STATUS "Showing option BUILD_TESTING: ${BUILD_TESTING}")
274276

@@ -305,6 +307,16 @@ booleanize01(LIBINT_ACCUM_INTS)
305307
booleanize01(LIBINT_FLOP_COUNT)
306308
booleanize01(LIBINT_PROFILE)
307309

310+
if (EXPORT_COMPRESSOR STREQUAL "gzip")
311+
set(EXPORT_COMPRESSOR_CMD "cfz")
312+
set(EXPORT_COMPRESSOR_EXT "tgz")
313+
elseif (EXPORT_COMPRESSOR STREQUAL "bzip2")
314+
set(EXPORT_COMPRESSOR_CMD "jcf")
315+
set(EXPORT_COMPRESSOR_EXT "tbz2")
316+
else()
317+
message(FATAL_ERROR "No valid compressor; invoke CMake with -DEXPORT_COMPRESSOR=gzip|bzip2")
318+
endif()
319+
308320

309321
################################## Dependencies #################################
310322

INSTALL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ Note that options, docs, and CMake components are focused on the C++ interface,
267267
### Build Library How (G L) (TARBALL)
268268
269269
* `CMAKE_BUILD_TYPE` — G L — [Standard CMake variable](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) [Default=Release]
270+
* `BUILD_SHARED_LIBS` — L — Build Libint library as shared, not static. [Standard CMake variable](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html) [Default=OFF]
271+
* `LIBINT2_BUILD_SHARED_AND_STATIC_LIBS` — L — Build both shared and static Libint libraries in one shot. Uses `-fPIC`. [Default=OFF]
270272
271273
### Detecting Dependencies (G L C) (TARBALL)
272274

cmake/modules/DynamicVersion.cmake

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Helper module to get the project's version dynamically. Format is compatible wit
1515

1616
include_guard()
1717
list(APPEND CMAKE_MESSAGE_CONTEXT DynamicVersion)
18+
if (POLICY CMP0140)
19+
# Enable using return(PROPAGATE)
20+
# TODO: Remove when cmake 3.25 is commonly distributed
21+
cmake_policy(SET CMP0140 NEW)
22+
endif ()
1823

1924
#[==============================================================================================[
2025
# Preparations #
@@ -118,9 +123,6 @@ function(dynamic_version)
118123
`${OUTPUT_FOLDER}/.git_commit`
119124
Current commit
120125
121-
`${OUTPUT_FOLDER}/.git_distance`
122-
Current git distance from tag
123-
124126
## See also
125127
- [pypa/setuptools_scm](https://github.com/pypa/setuptools_scm)
126128
@@ -227,10 +229,14 @@ function(dynamic_version)
227229
COMMAND_ERROR_IS_FATAL ANY)
228230

229231
# Copy all configured files
230-
foreach (file IN ITEMS .DynamicVersion.json .version .git_describe .git_commit .git_distance)
231-
if (EXISTS ${file})
232-
file(COPY_FILE ${ARGS_TMP_FOLDER}/${file} ${ARGS_OUTPUT_FOLDER}/${file})
233-
endif ()
232+
foreach (file IN ITEMS .DynamicVersion.json .version .git_describe .git_commit)
233+
if (EXISTS ${ARGS_TMP_FOLDER}/${file})
234+
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
235+
file(COPY_FILE ${ARGS_TMP_FOLDER}/${file} ${ARGS_OUTPUT_FOLDER}/${file})
236+
else ()
237+
file(COPY ${ARGS_TMP_FOLDER}/${file} DESTINATION ${ARGS_OUTPUT_FOLDER}/)
238+
endif ()
239+
endif ()
234240
endforeach ()
235241

236242
# Check configuration state
@@ -359,13 +365,13 @@ function(get_dynamic_version)
359365
# Set fallback values
360366
if (DEFINED ARGS_FALLBACK_VERSION)
361367
string(JSON data SET
362-
${data} version ${ARGS_FALLBACK_VERSION})
368+
${data} version \"${ARGS_FALLBACK_VERSION}\")
363369
file(WRITE ${ARGS_TMP_FOLDER}/.DynamicVersion.json ${data})
364370
file(WRITE ${ARGS_TMP_FOLDER}/.version ${ARGS_FALLBACK_VERSION})
365371
endif ()
366372
if (DEFINED ARGS_FALLBACK_HASH)
367373
string(JSON data SET
368-
${data} commit ${ARGS_FALLBACK_HASH})
374+
${data} commit \"${ARGS_FALLBACK_HASH}\")
369375
file(WRITE ${ARGS_TMP_FOLDER}/.DynamicVersion.json ${data})
370376
file(WRITE ${ARGS_TMP_FOLDER}/.git_commit ${ARGS_FALLBACK_HASH})
371377
endif ()
@@ -403,8 +409,11 @@ function(get_dynamic_version)
403409
${data} version \"${CMAKE_MATCH_2}\")
404410
file(WRITE ${ARGS_TMP_FOLDER}/.version ${CMAKE_MATCH_2})
405411
# Get commit hash
412+
# Cannot use Regex match from here, need to run string(REGEX MATCH) again
413+
# https://gitlab.kitware.com/cmake/cmake/-/issues/23770
406414
file(STRINGS ${ARGS_GIT_ARCHIVAL_FILE} node
407415
REGEX "^node:[ ]?(.*)")
416+
string(REGEX MATCH "^node:[ ]?(.*)" node "${node}")
408417
string(JSON data SET
409418
${data} commit \"${CMAKE_MATCH_1}\")
410419
file(WRITE ${ARGS_TMP_FOLDER}/.git_commit ${CMAKE_MATCH_1})
@@ -433,13 +442,13 @@ function(get_dynamic_version)
433442
OUTPUT_STRIP_TRAILING_WHITESPACE
434443
COMMAND_ERROR_IS_FATAL ANY)
435444
# Get version and describe-name
436-
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match=?[0-9.]*
445+
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --long --abbrev=8 --match=?[0-9.]*
437446
WORKING_DIRECTORY ${ARGS_PROJECT_SOURCE}
438447
OUTPUT_VARIABLE describe-name
439448
OUTPUT_STRIP_TRAILING_WHITESPACE
440449
COMMAND_ERROR_IS_FATAL ANY)
441450
# Match any part containing digits and periods (strips out rc and so on)
442-
if (NOT describe-name MATCHES "^([v]?([0-9\\.]+).*)")
451+
if (NOT describe-name MATCHES "^([v]?([0-9\\.]+)-([0-9]+)-g(.*))")
443452
message(${error_message_type}
444453
"Version tag is ill-formatted\n"
445454
" Describe-name: ${describe-name}"
@@ -452,26 +461,13 @@ function(get_dynamic_version)
452461
string(JSON data SET
453462
${data} version \"${CMAKE_MATCH_2}\")
454463
file(WRITE ${ARGS_TMP_FOLDER}/.version ${CMAKE_MATCH_2})
464+
string(JSON data SET
465+
${data} distance \"${CMAKE_MATCH_3}\")
466+
string(JSON data SET
467+
${data} short_sha \"${CMAKE_MATCH_4}\")
455468
string(JSON data SET
456469
${data} commit \"${git-hash}\")
457470
file(WRITE ${ARGS_TMP_FOLDER}/.git_commit ${git-hash})
458-
# Get full describe with distance
459-
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --long --match=?[0-9.]*
460-
WORKING_DIRECTORY ${ARGS_PROJECT_SOURCE}
461-
OUTPUT_VARIABLE describe-name-long
462-
OUTPUT_STRIP_TRAILING_WHITESPACE
463-
COMMAND_ERROR_IS_FATAL ANY)
464-
# Match version (as above) and distance
465-
if (NOT describe-name-long MATCHES "^([v]?([0-9\\.]+)-([0-9]+)-.*)")
466-
message(${error_message_type}
467-
"Version tag is ill-formatted\n"
468-
" Describe-name-long: ${describe-name-long}"
469-
)
470-
return()
471-
endif ()
472-
string(JSON data SET
473-
${data} distance \"${CMAKE_MATCH_3}\")
474-
file(WRITE ${ARGS_TMP_FOLDER}/.git_distance ${CMAKE_MATCH_3})
475471
message(DEBUG
476472
"Found appropriate tag from git"
477473
)
@@ -507,3 +503,5 @@ if (DynamicVersion_RUN)
507503
endif ()
508504
get_dynamic_version(${DynamicVersion_ARGS})
509505
endif ()
506+
507+
list(POP_BACK CMAKE_MESSAGE_CONTEXT)

include/libint2/config2.h.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#define LIBINT2_ALIGN_SIZE @LIBINT2_ALIGN_SIZE@
4141

4242
/* User-defined real type */
43-
#cmakedefine LIBINT2_REALTYPE "@LIBINT2_REALTYPE@"
43+
#cmakedefine LIBINT2_REALTYPE @LIBINT2_REALTYPE@
4444

4545
/* Specifies the ordering of solid harmonics Gaussians in a shell. Retired Jan 2023 in favor of becoming a generator-time-only option */
4646
/* #cmakedefine LIBINT_SHGSHELL_ORDERING @LIBINT_SHGSHELL_ORDERING@ */

src/bin/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ add_subdirectory(libint)
22

33
include(AddCustomTargetSubproject)
44
add_custom_target_subproject(
5-
libint2compiler
6-
check
5+
libint2compiler check # target check-libint2compiler
76
USES_TERMINAL
87
COMMAND ${CMAKE_CTEST_COMMAND} -V -R "libint2/compiler"
98
)

0 commit comments

Comments
 (0)