Skip to content

Mods to support spectra file IO out of fortran #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 109 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
ba53a82
Add install stuff and support for Finding Specutils in CMake
hbivens Jul 25, 2024
ab9e951
Merge branch 'master' into issue/31-spectra-io-out-of-fortran
wcjohns Jul 25, 2024
cc1b35f
remove install interface thing that doesn't seem to matter.
hbivens Jul 26, 2024
0334e4d
fortran integration mods
hbivens Aug 5, 2024
aed541f
add extension that accesses a count at a given channel
hbivens Aug 6, 2024
aca0c47
make the *_at extensions 1-based, since calling from fortran
hbivens Aug 6, 2024
4b8bdc9
enable testing at the topmost cmakefile
hbivens Aug 8, 2024
aefc329
cherry pick boost test removal
hbivens Aug 8, 2024
fd24efd
syntax highlighting getting confused
hbivens Aug 8, 2024
17cc031
Make API a little easier
hbivens Aug 10, 2024
48421d9
add round trip test
hbivens Aug 12, 2024
0c59d47
use seconds precision
hbivens Aug 12, 2024
8af3a3b
add deviation pairs to test
hbivens Aug 12, 2024
358b706
check neutrons
hbivens Aug 12, 2024
c89674c
use vax string
hbivens Aug 12, 2024
4aef394
Yeah!!! Figured out fortran array to c++ typemap.
hbivens Aug 14, 2024
fb679da
add a few more extensions and include filesystem stuff
hbivens Aug 15, 2024
45bed0e
call correct method
hbivens Aug 28, 2024
c498e6d
trim the filename and add some error diagnostics
hbivens Aug 28, 2024
e6032bb
add realtime check
hbivens Sep 9, 2024
738cd14
merge master
hbivens Sep 9, 2024
6d8371f
Fix issue compiling with fast_float
wcjohns Sep 9, 2024
80d3ce5
fix windows build error
hbivens Sep 12, 2024
7f4a595
update wrapper
hbivens Sep 13, 2024
2b03814
start some tests to map dev pairs
hbivens Sep 13, 2024
ae3c9a3
make strtod default
hbivens Sep 16, 2024
31cb465
Merge remote-tracking branch 'origin/master' into issue/31-spectra-io…
hbivens Sep 16, 2024
af3631d
checkpoint
hbivens Sep 17, 2024
f39635e
pcf spectra file mods
hbivens Sep 18, 2024
0e27b16
updates - add fortran round trip test
hbivens Sep 18, 2024
62e653c
checkpoint
hbivens Sep 20, 2024
46dbbc5
lose the pcf namespace
hbivens Sep 23, 2024
936b7af
figured out deviation pairs
hbivens Sep 26, 2024
48a3268
update fortran wrapper
hbivens Sep 26, 2024
8d547a3
more dev pair mapping
hbivens Sep 27, 2024
9b195e4
cherrypick Will's tag support
hbivens Sep 27, 2024
a96f242
merge master and fix conflicts
hbivens Sep 30, 2024
e0391ad
revert back to default
hbivens Sep 30, 2024
854b836
update test to show Will
hbivens Oct 2, 2024
431c65c
Fix issues with writing and reading deviation pairs to PCF files.
wcjohns Oct 9, 2024
2f35d06
Make compiling the bindings optional (defaulting to off).
wcjohns Oct 9, 2024
e29f078
Promote measurement source and descriptions to be member variables of…
wcjohns Oct 10, 2024
20c6e55
Remove PcfExtensions.
wcjohns Oct 10, 2024
1b77e69
Fix compile issue.
wcjohns Oct 10, 2024
882b503
Fix some function not always returning values in c-interface.
wcjohns Oct 10, 2024
a1e4396
Fix `SpecUtils_Measurement_set_start_time_str` not returning a value.
wcjohns Oct 10, 2024
68babc7
update fortran bindings
hbivens Oct 10, 2024
6a07a20
add ctest args
hbivens Oct 10, 2024
d6e44d7
rename this, I was getting compiler warning:
hbivens Oct 10, 2024
74d4418
add debug print for CICD
hbivens Oct 10, 2024
13bb819
mas debug
hbivens Oct 10, 2024
0caf7ca
add index, size to exception message
hbivens Oct 10, 2024
3981033
add size
hbivens Oct 10, 2024
cdc7ecd
add build script to aid in cicd debug
hbivens Oct 10, 2024
0f58916
up minimum to avoid cmake warning
hbivens Oct 10, 2024
a80f9af
uri spectra causes fortran test to fail
hbivens Oct 10, 2024
074926e
wrong line
hbivens Oct 10, 2024
1047d13
First try at adding an automated release of shared libraries for windows
wcjohns Oct 11, 2024
9c6163e
Merge branch 'issue/31-spectra-io-out-of-fortran' of github.com:sandi…
wcjohns Oct 11, 2024
9451d07
Add package command to CMake, and bring out option for Windows runtim…
wcjohns Oct 11, 2024
fee1904
Merge branch 'issue/31-spectra-io-out-of-fortran' of github.com:sandi…
wcjohns Oct 11, 2024
02c71ab
Merge branch 'master' into issue/31-spectra-io-out-of-fortran
wcjohns Oct 11, 2024
a22e940
Fix a few things up that I think got messed up during various merges.
wcjohns Oct 11, 2024
61f3224
Maybe fix compile error on Windows
wcjohns Oct 11, 2024
65621cb
Add another missing include
wcjohns Oct 11, 2024
3018b0d
Add another missing include
wcjohns Oct 11, 2024
2ce11ec
Ad UTF-8 BOM to test_utf8_limit_str_size.cpp
wcjohns Oct 11, 2024
dccb2e4
Update ci.yml to upload Windows artifact, maybe
wcjohns Oct 11, 2024
ee04054
Update ci.yml to upload Windows artifact, now a little closer maybe
wcjohns Oct 11, 2024
5e97ccc
Update ci.yml to upload Windows artifact, try again
wcjohns Oct 11, 2024
5408630
Update ci.yml to upload Windows artifact, try again
wcjohns Oct 12, 2024
79d81cb
Update ci.yml to upload Windows artifact, try again
wcjohns Oct 12, 2024
ba26b47
Update ci.yml to upload Windows artifact, try again
wcjohns Oct 12, 2024
03d8889
Minor change
wcjohns Oct 12, 2024
960c637
Fix issue when converting to a VAX string.
wcjohns Oct 14, 2024
6f55a3b
Debug windows automated build of shared libraries a bit
wcjohns Oct 14, 2024
4e6c62b
Maybe fix syntax error in ci.yml
wcjohns Oct 14, 2024
6310f65
Maybe fix syntax error in ci.yml
wcjohns Oct 14, 2024
caab293
Maybe fix syntax error in ci.yml
wcjohns Oct 14, 2024
06fcc6e
Try to improve CI install targets
wcjohns Oct 14, 2024
56d8b78
Debugging chany ci.yml
wcjohns Oct 14, 2024
679bf4e
Remove trying to install export file
wcjohns Oct 14, 2024
53b5039
Turn building C bindings on for CI build
wcjohns Oct 14, 2024
160b5bd
Add exporting classes/structs/functions for Windows DLLs.
wcjohns Oct 14, 2024
16643d3
Trye having CMake generate export header.
wcjohns Oct 14, 2024
1359228
Fix missed export
wcjohns Oct 14, 2024
e3ffee4
Temporarily re-include `pcf_det_name_to_dev_pair_index` so fortran bi…
wcjohns Oct 14, 2024
9adcc44
Fix infinite recursion
wcjohns Oct 14, 2024
902074e
add script
hbivens Oct 15, 2024
bb9fb76
Merge remote-tracking branch 'origin/issue/31-spectra-io-out-of-fortr…
hbivens Oct 15, 2024
f1c5e48
add install
hbivens Oct 17, 2024
bf77e65
Turn off c-bindings
hbivens Oct 17, 2024
a93c8c8
add -fPic
hbivens Oct 17, 2024
5b47ea2
Revert "Turn building C bindings on for CI build"
hbivens Oct 18, 2024
301ee76
Revert "Add exporting classes/structs/functions for Windows DLLs."
hbivens Oct 18, 2024
ae11b15
update swig-gen
hbivens Oct 18, 2024
7de1a45
Revert "Fix missed export"
hbivens Oct 18, 2024
2cceea1
make it work
hbivens Oct 18, 2024
874d8a5
keep the swig generated files in repo
hbivens Oct 18, 2024
cbfc685
update interface
hbivens Oct 21, 2024
1cd879c
update test
hbivens Oct 21, 2024
0e9ebde
Add method to update detector name
hbivens Oct 22, 2024
9ca9f3c
cmake mods to enable valgrind memcheck with ctest
hbivens Oct 23, 2024
ef7c3dc
update version and add to cpack file
hbivens Jan 28, 2025
01c8443
Merge remote-tracking branch 'origin/master' into issue/31-spectra-io…
hbivens Jan 29, 2025
d87b2db
Update SpecUtils_config.h.in
hbivens Jan 29, 2025
ecf3d0e
maybe fix macos wheel build
hbivens Jan 29, 2025
4e70828
Make so install stuff is only called if building as a top-level project.
wcjohns Jan 30, 2025
4f0f402
Fix last commit not generating SpecUtils_config.h
wcjohns Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 82 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
num-parse-method: FastFloat
- os: windows-latest
num-parse-method: FromChars
- os: windows-latest
num-parse-method: strtod
# - os: windows-latest
# num-parse-method: strtod

steps:
- name: Checkout code
Expand All @@ -43,31 +43,105 @@ jobs:
# For linux, we will perform developer checks, so we need boost
- name: Set up dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y build-essential libboost-all-dev
run: sudo apt-get update && sudo apt-get install -y build-essential libboost-all-dev gfortran zlib1g-dev

- name: Create build directory
run: mkdir build

- name: Configure CMake on Windows
if: runner.os == 'Windows'
run: cmake -S ${{ github.workspace }} -B build -DSpecUtils_BUILD_UNIT_TESTS=ON -DSpecUtils_BUILD_REGRESSION_TEST=ON -DSpecUtils_ENABLE_EQUALITY_CHECKS=ON -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=OFF -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON
run: cmake -S ${{ github.workspace }} -B build -DSpecUtils_BUILD_UNIT_TESTS=ON -DSpecUtils_BUILD_REGRESSION_TEST=ON -DSpecUtils_ENABLE_EQUALITY_CHECKS=ON -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=OFF -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON -DSpecUtils_C_BINDINGS=OFF -DCMAKE_INSTALL_PREFIX=install_prefix

# On linux we will perform developer checks and compile as debug to catch asserts
- name: Configure CMake on Linux
if: runner.os == 'Linux'
run: cmake -S ${{ github.workspace }} -B build -DSpecUtils_BUILD_UNIT_TESTS=ON -DSpecUtils_BUILD_REGRESSION_TEST=ON -DSpecUtils_ENABLE_EQUALITY_CHECKS=ON -DPERFORM_DEVELOPER_CHECKS=ON -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=ON -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON
run: cmake -S ${{ github.workspace }} -B build -DSpecUtils_BUILD_UNIT_TESTS=ON -DSpecUtils_BUILD_REGRESSION_TEST=ON -DSpecUtils_ENABLE_EQUALITY_CHECKS=ON -DPERFORM_DEVELOPER_CHECKS=ON -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=OFF -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON -DSpecUtils_C_BINDINGS=ON -DSpecUtils_FORTRAN_SWIG=ON -DCMAKE_INSTALL_PREFIX=install_prefix

- name: Configure CMake on macOS
if: runner.os == 'macOS'
run: cmake -S ${{ github.workspace }} -B build -DSpecUtils_BUILD_UNIT_TESTS=ON -DSpecUtils_BUILD_REGRESSION_TEST=ON -DSpecUtils_ENABLE_EQUALITY_CHECKS=ON -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=ON -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON
run: cmake -S ${{ github.workspace }} -B build -DSpecUtils_BUILD_UNIT_TESTS=ON -DSpecUtils_BUILD_REGRESSION_TEST=ON -DSpecUtils_ENABLE_EQUALITY_CHECKS=ON -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=ON -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON -DSpecUtils_C_BINDINGS=ON -DCMAKE_INSTALL_PREFIX=install_prefix

- name: Build macOS and Windows
if: runner.os != 'Linux'
run: cmake --build build --config Release

- name: Build Linux
if: runner.os == 'Linux'
run: cmake --build build --config Debug
run: cmake --build build --config Release -j $(nproc)

- name: Run tests
run: ctest --test-dir build -C Release
run: ctest --rerun-failed --output-on-failure --test-dir build -C Release

- name: Package Lib
if: runner.os == 'Windows'
run: |
cmake -S ${{ github.workspace }} -B build_static_lib_shared_runtime -DSpecUtils_BUILD_UNIT_TESTS=OFF -DSpecUtils_BUILD_REGRESSION_TEST=OFF -DSpecUtils_ENABLE_EQUALITY_CHECKS=OFF -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=OFF -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON -DCMAKE_INSTALL_PREFIX=install_prefix_static_lib_shared_runtime -DSpecUtils_USE_MSVC_MultiThreadDLL=ON -DSpecUtils_SHARED_LIB=OFF
cmake --build build_static_lib_shared_runtime --config Release --target package
echo "Files present after package build_static_lib_shared_runtime"
ls
ls build_static_lib_shared_runtime
ls build_static_lib_shared_runtime/Release
ls build_static_lib_shared_runtime/x64/Release
#
cmake -S ${{ github.workspace }} -B build_shared_lib_shared_runtime -DSpecUtils_BUILD_UNIT_TESTS=OFF -DSpecUtils_BUILD_REGRESSION_TEST=OFF -DSpecUtils_ENABLE_EQUALITY_CHECKS=OFF -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=OFF -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON -DCMAKE_INSTALL_PREFIX=install_prefix_build_shared_lib_shared_runtime -DSpecUtils_USE_MSVC_MultiThreadDLL=ON -DSpecUtils_SHARED_LIB=ON
cmake --build build_shared_lib_shared_runtime --config Release --target package
echo "Files present after package build_shared_lib_shared_runtime"
ls
ls build_shared_lib_shared_runtime
ls build_shared_lib_shared_runtime/Release
ls build_shared_lib_shared_runtime/x64/Release
#
cmake -S ${{ github.workspace }} -B build_shared_lib_static_runtime -DSpecUtils_BUILD_UNIT_TESTS=OFF -DSpecUtils_BUILD_REGRESSION_TEST=OFF -DSpecUtils_ENABLE_EQUALITY_CHECKS=OFF -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=OFF -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON -DCMAKE_INSTALL_PREFIX=install_prefix_build_shared_lib_static_runtime -DSpecUtils_USE_MSVC_MultiThreadDLL=OFF -DSpecUtils_SHARED_LIB=ON
cmake --build build_shared_lib_static_runtime --config Release --target package
echo "Files present after package build_shared_lib_static_runtime"
ls
ls build_shared_lib_static_runtime
ls build_shared_lib_static_runtime/Release
ls build_shared_lib_static_runtime/x64/Release
#
cmake -S ${{ github.workspace }} -B build_static_lib_static_runtime -DSpecUtils_BUILD_UNIT_TESTS=OFF -DSpecUtils_BUILD_REGRESSION_TEST=OFF -DSpecUtils_ENABLE_EQUALITY_CHECKS=OFF -DPERFORM_DEVELOPER_CHECKS=OFF -DSpecUtils_ENABLE_D3_CHART=ON -DSpecUtils_D3_SUPPORT_FILE_STATIC=ON -DSpecUtils_ENABLE_URI_SPECTRA=OFF -DCMAKE_BUILD_TYPE=Release -DSpecUtils_FLT_PARSE_METHOD=${{ matrix.num-parse-method }} -DSpecUtils_FETCH_FAST_FLOAT=ON -DCMAKE_INSTALL_PREFIX=install_prefix_build_static_lib_static_runtime -DSpecUtils_USE_MSVC_MultiThreadDLL=OFF -DSpecUtils_SHARED_LIB=OFF
cmake --build build_static_lib_static_runtime --config Release --target package
echo "Files present after package build_static_lib_static_runtime"
ls
ls build_static_lib_static_runtime
ls build_static_lib_static_runtime/Release
ls build_static_lib_static_runtime/x64/Release


# Update the bleeding-edge tag to be current commit
- name: Run latest-tag
uses: EndBug/[email protected]
if: matrix.os == 'Windows'
with:
ref: bleeding-edge
description: Latest successful automated build

- name: Upload windows build to GitHub Artifact
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: SpecUtils_${{ runner.os }}_latest
path: '.\build_*\*.zip'

- name: Create Release
uses: ncipollo/[email protected]
if: runner.os == 'Windows'
with:
artifacts: '.\build_*\*.zip'
draft: false
prerelease: true
body: "An automated, and untested build of the latest code pushed to the repository."
allowUpdates: true
generateReleaseNotes: false
name: "Bleeding Edge Build"
removeArtifacts: true
replacesArtifacts: true
tag: 'bleeding-edge'
commit: ${{ github.sha }}
makeLatest: true
# Delete all the zip files we created
- name: "Cleanup and finish"
if: runner.os == 'Windows'
run: |
Get-ChildItem '.\build_*\*.zip' | foreach { Remove-Item -Path $_.FullName }
echo "Job status is ${{ job.status }}."
108 changes: 101 additions & 7 deletions CMakeLists.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If SpecUtils_FLT_PARSE_METHOD is left as 'default_value' here, there is some logic below to hopefully pick the most reasonable float parsing method. Like for MSVC ≥2019, it should pick 'FromChars'.
Is there is reason to default to the slowest common denominator, or was it giving you an issue?

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

project( SpecUtils VERSION 1.0.0 )
project( SpecUtils VERSION 2025.1.0 )
enable_testing() # Enable here to allow running `ctest` from top-most build dir

# Add this line to specify the architectures for MacOS
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for MacOS" FORCE)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wcjohns so everything builds ok but macos*. Copilot said to add this but that didn't help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's Explain Error button:

image

Copy link
Collaborator

@wcjohns wcjohns Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove that added line; I think the macOS architectures are set by the nanobind stuff.

I just triggered a build on the main branch, and it ran fine.
It looks like the problem is that on this branch, it is installing all the headers, and I think crucially the static SpecUtils.a library, into the Python wheel. When delocate is ran on the wheel, the .a file is causing the failure.

Below is the step that is installing stuff into the python package:

image
image

And the actual error:
image
Which looks to be being triggered by the .a file.


option( SpecUtils_ENABLE_D3_CHART "Enables exporting of the D3 chart format" ON )
option( SpecUtils_D3_SUPPORT_FILE_STATIC "Compiles the JS and CSS files into memory, rather than reading files on disk; disable to allow changing JS/CSS without having to recompile" ON )
Expand All @@ -20,6 +24,9 @@ option( SpecUtils_BUILD_FUZZING_TESTS "Builds fuzzing tests, requires clang" OFF
option( SpecUtils_BUILD_REGRESSION_TEST "Creates executable to perform interactive regression test" OFF )
option( SpecUtils_BUILD_EXAMPLE "Builds example SpecUtil applications" OFF )
option( SpecUtils_JAVA_SWIG "Creates swig/java bindings to the c++ code" OFF )
option( SpecUtils_FORTRAN_SWIG "Enables build/test of swig/FORTRAN bindings" OFF )
option( SpecUtils_FORTRAN_SWIG_GEN "When this is on, cmake will attemp to generate swig fortran bindings.
Requires swig-fortran: https://github.com/swig-fortran/swig" OFF )
option( SpecUtils_C_BINDINGS "Creates C bindings to the c++ code" OFF )
option( SpecUtils_INJA_TEMPLATES "Creates inja template interface" OFF )
option( SpecUtils_USE_SIMD "Use SIMD operations; i386/x64 only right now, and very alpha, and extremely minimally used" OFF )
Expand Down Expand Up @@ -256,6 +263,19 @@ endif( SpecUtils_SHARED_LIB )
add_library( SpecUtils ${SpecUtils_LIB_TYPE} ${sources} ${headers} ${OTHER_SUPPORT_FILES} )
set_target_properties( SpecUtils PROPERTIES PREFIX "lib" OUTPUT_NAME "SpecUtils" )


# Include the GenerateExportHeader module
include(GenerateExportHeader)
generate_export_header(SpecUtils
BASE_NAME SpecUtils
EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/SpecUtilsExport.h
)

if( NOT SpecUtils_SHARED_LIB )
target_compile_definitions( SpecUtils PRIVATE SPECUTILS_STATIC_DEFINE )
endif()


set( SpecUtils_USE_FAST_FLOAT OFF ) # Uses https://github.com/fastfloat/fast_float . If fast_float.h isnt found, will be fetched
set( SpecUtils_USE_FROM_CHARS OFF ) # Supported by MSVC >= 2019, and gcc >= 12. Not supported by Apple clang. In MSVC, about 50% slower than boost::spirit
set( SpecUtils_USE_BOOST_SPIRIT OFF ) # Uses boost::spirit, and fasted method (maybe a hair faster than fastfloat)
Expand Down Expand Up @@ -308,7 +328,7 @@ if( SpecUtils_USE_FAST_FLOAT )
FetchContent_GetProperties( fast_float )
FetchContent_MakeAvailable( fast_float )

target_include_directories( SpecUtils PUBLIC ${fast_float_SOURCE_DIR} )
target_include_directories( SpecUtils PRIVATE ${fast_float_SOURCE_DIR} )
endif( SpecUtils_FETCH_FAST_FLOAT )
endif( NOT FAST_FLOAT_FILE_PATH )
endif( SpecUtils_USE_FAST_FLOAT )
Expand Down Expand Up @@ -383,6 +403,9 @@ if( SpecUtils_JAVA_SWIG )
target_link_libraries( SpecUtils PUBLIC ${JAVA_LIBRARIES} )
endif( SpecUtils_JAVA_SWIG )

if( SpecUtils_FORTRAN_SWIG )
add_subdirectory(bindings/swig/fortran)
endif( SpecUtils_FORTRAN_SWIG )

if( MINGW )
target_link_libraries( SpecUtils PUBLIC -static-libgcc -static libshlwapi.a libpthread.a libstdc++.a libwinpthread.a libmsvcrt.a )
Expand All @@ -393,8 +416,8 @@ elseif( WIN32 )
target_link_libraries( SpecUtils PUBLIC "Shlwapi.lib" )
endif( MINGW )

target_include_directories( SpecUtils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${THIRD_PARTY_DIR} )
target_include_directories( SpecUtils PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
PRIVATE ${THIRD_PARTY_DIR} ${PYTHON_INCLUDE_DIRS} )

if( SpecUtils_BUILD_REGRESSION_TEST )
if( NOT SpecUtils_ENABLE_EQUALITY_CHECKS )
Expand All @@ -406,8 +429,7 @@ endif( SpecUtils_BUILD_REGRESSION_TEST )


if( SpecUtils_BUILD_UNIT_TESTS )
enable_testing() # Enable here to allow running `ctest` from top-most build dir

include (CTest)
add_subdirectory( unit_tests )
endif( SpecUtils_BUILD_UNIT_TESTS )

Expand All @@ -416,9 +438,81 @@ if( SpecUtils_BUILD_FUZZING_TESTS )
add_subdirectory( fuzz_test )
endif( SpecUtils_BUILD_FUZZING_TESTS )

set_property( TARGET SpecUtils PROPERTY POSITION_INDEPENDENT_CODE ON )

set( SpecUtils_config_OUT ${CMAKE_CURRENT_BINARY_DIR}/SpecUtils_config.h )
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/SpecUtils/SpecUtils_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/SpecUtils_config.h
${SpecUtils_config_OUT}
)
LIST(APPEND headers ${SpecUtils_config_OUT})

get_directory_property(hasParent PARENT_DIRECTORY)
if( NOT hasParent )
# Specify installation rules
include(GNUInstallDirs)


# Install the library
install(TARGETS SpecUtils
EXPORT SpecUtilsTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # For shared libraries on UNIX-like systems
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # For static libraries and import libraries on Windows
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # For DLLs
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# Install the headers
install(FILES ${headers} ${CMAKE_BINARY_DIR}/SpecUtilsExport.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SpecUtils)

# Create and install the CMake package configuration files
include(CMakePackageConfigHelpers)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/SpecUtilsConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SpecUtils
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SpecUtils
)

install(EXPORT SpecUtilsTargets
FILE SpecUtilsTargets.cmake
NAMESPACE SpecUtils::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SpecUtils
)

set(CPACK_PACKAGE_NAME "SpecUtils")


if( SpecUtils_SHARED_LIB )
set( SpecUtils_PACKAGE_POSTFIX "SharedLib" )
else( SpecUtils_SHARED_LIB )
set( SpecUtils_PACKAGE_POSTFIX "StaticLib" )
endif( SpecUtils_SHARED_LIB )

if( DEFINED ${PROJECT_NAME}_USE_MSVC_MultiThreadDLL )
if( ${PROJECT_NAME}_USE_MSVC_MultiThreadDLL )
set( SpecUtils_PACKAGE_POSTFIX "${SpecUtils_PACKAGE_POSTFIX}-SharedRuntime" )
else()
set( SpecUtils_PACKAGE_POSTFIX "${SpecUtils_PACKAGE_POSTFIX}-StaticRuntime" )
endif()
endif()

# Lets just use the MAJOR.MINOR version of the compiler in the name.
string(REGEX MATCH "^[0-9]+\\.[0-9]+" COMPILER_VERSION_SHORT "${CMAKE_CXX_COMPILER_VERSION}")

set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-${COMPILER_VERSION_SHORT}-${SpecUtils_PACKAGE_POSTFIX}")
set(CPACK_GENERATOR "ZIP")
include(CPack)
endif( NOT hasParent )
2 changes: 1 addition & 1 deletion SpecUtils/DateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace SpecUtils
Returns empty string if input is not valid.
Ex. "19-Sep-2014 14:12:01.62"
*/
std::string to_vax_string( const time_point_t &t );
std::string to_vax_string( time_point_t t );

/** \brief Describes how to attempt to parse date/times when it is ambigous,
and you might have some prior information based on the source.
Expand Down
10 changes: 8 additions & 2 deletions SpecUtils/EnergyCalibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
*/
namespace SpecUtils
{

using DevPair = std::pair<float,float>;
using DeviationPairs = std::vector<DevPair>;
/** The energy (or FWHM) calibration type that the calibration coefficients
should be interpreted as.

Expand Down Expand Up @@ -288,15 +291,18 @@ namespace SpecUtils
\sa set_polynomial, EnergyCalCheckType::Normal
*/
static const float sm_polynomial_offset_limit;

protected:

/** Checks the channel energies is acceptable (e.g., enough channels, and monotonically
increasing values).

Throws exception if error is found.
*/
void check_lower_energies( const size_t nchannels, const std::vector<float> &energies );

DeviationPairs & mutable_deviation_pairs()
{
return m_deviation_pairs;
}
EnergyCalType m_type;
std::vector<float> m_coefficients;
std::vector<std::pair<float,float>> m_deviation_pairs;
Expand Down
3 changes: 3 additions & 0 deletions SpecUtils/ParseUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <istream>
#include <ostream>

#include "SpecUtils/StringAlgo.h"

/** Some functions and definitions that help to parse and write spectrum files,
but maybe dont fit in other sections of code.
*/
Expand Down Expand Up @@ -290,6 +292,7 @@ Integral float_to_integral( float d )
static constexpr Integral max_int_val = std::numeric_limits<Integral>::max();
return std::signbit(d) ? min_int_val : max_int_val;
}//float_to_integral

}//namespace SpecUtils

#endif //SpecUtils_ParseUtils_h
Expand Down
Loading
Loading