Skip to content

Commit 7e9b9a3

Browse files
authored
Merge 2ce11ec into ba911c1
2 parents ba911c1 + 2ce11ec commit 7e9b9a3

33 files changed

+31518
-252
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,78 @@ jobs:
4343
# For linux, we will perform developer checks, so we need boost
4444
- name: Set up dependencies
4545
if: runner.os == 'Linux'
46-
run: sudo apt-get update && sudo apt-get install -y build-essential libboost-all-dev
46+
run: sudo apt-get update && sudo apt-get install -y build-essential libboost-all-dev gfortran
4747

4848
- name: Create build directory
4949
run: mkdir build
5050

5151
- name: Configure CMake on Windows
5252
if: runner.os == 'Windows'
53-
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
53+
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=ON -DCMAKE_INSTALL_PREFIX=install_prefix
5454

5555
# On linux we will perform developer checks and compile as debug to catch asserts
5656
- name: Configure CMake on Linux
5757
if: runner.os == 'Linux'
58-
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
58+
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
5959

6060
- name: Configure CMake on macOS
6161
if: runner.os == 'macOS'
62-
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
62+
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
6363

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

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

7272
- name: Run tests
73-
run: ctest --test-dir build -C Release
73+
run: ctest --rerun-failed --output-on-failure --test-dir build -C Release
74+
75+
- name: Package Lib
76+
if: runner.os == 'boost' && runner.os == 'Windows'
77+
run: |
78+
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=ON -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
79+
cmake --build build_static_lib_shared_runtime --config Release --target package
80+
#
81+
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=ON -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
82+
cmake --build build_shared_lib_shared_runtime --config Release --target package
83+
#
84+
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=ON -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
85+
cmake --build build_shared_lib_static_runtime --config Release --target package
86+
#
87+
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=ON -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
88+
cmake --build build_static_lib_static_runtime --config Release --target package
89+
90+
# Update the bleeding-edge tag to be current commit
91+
- name: Run latest-tag
92+
uses: EndBug/[email protected]
93+
if: runner.os == 'Windows'
94+
with:
95+
ref: bleeding-edge
96+
description: Latest successful automated build
97+
98+
- name: Upload windows build to GitHub Artifact
99+
uses: actions/upload-artifact@v4
100+
if: runner.os == 'Windows'
101+
with:
102+
name: SpecUtils_${{ runner.os }}_latest
103+
path: '.\build_*\*.zip'
104+
105+
- name: Create Release
106+
uses: ncipollo/[email protected]
107+
if: runner.os == 'Windows'
108+
with:
109+
artifacts: '.\build_*\*.zip'
110+
draft: false
111+
prerelease: true
112+
body: "An automated, and untested build of the latest code pushed to the repository."
113+
allowUpdates: true
114+
generateReleaseNotes: false
115+
name: "Bleeding Edge Build"
116+
removeArtifacts: true
117+
replacesArtifacts: true
118+
tag: 'bleeding-edge'
119+
commit: ${{ github.sha }}
120+
makeLatest: true

CMakeLists.txt

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ endif()
1010

1111
project( SpecUtils VERSION 1.0.0 )
1212

13+
enable_testing()
14+
1315
option( SpecUtils_ENABLE_D3_CHART "Enables exporting of the D3 chart format" ON )
1416
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 )
1517
option( SpecUtils_ENABLE_URI_SPECTRA "Enables encoding/decoding spectra to URIs (for, ex, QR-codes) - requires linking to zlib" OFF )
@@ -21,6 +23,7 @@ option( SpecUtils_BUILD_REGRESSION_TEST "Creates executable to perform interacti
2123
option( SpecUtils_BUILD_EXAMPLE "Builds example SpecUtil applications" OFF )
2224
option( SpecUtils_PYTHON_BINDINGS "Creates python bindings to the c++ code" OFF )
2325
option( SpecUtils_JAVA_SWIG "Creates swig/java bindings to the c++ code" OFF )
26+
option( SpecUtils_FORTRAN_SWIG "Creates swig/FORTRAN bindings to the c++ code" OFF )
2427
option( SpecUtils_C_BINDINGS "Creates C bindings to the c++ code" OFF )
2528
option( SpecUtils_INJA_TEMPLATES "Creates inja template interface" OFF )
2629
option( SpecUtils_USE_SIMD "Use SIMD operations; i386/x64 only right now, and very alpha, and extremely minimally used" OFF )
@@ -82,7 +85,7 @@ endif()
8285

8386

8487
# If we are building this on Windows, not as a sub-project, lets enable selecting C++ runtime
85-
if( MSVC AND (SpecUtils_PYTHON_BINDINGS OR SpecUtils_BUILD_UNIT_TESTS) )
88+
if( MSVC )
8689
get_directory_property(hasParent PARENT_DIRECTORY)
8790
if(NOT hasParent)
8891
option(${PROJECT_NAME}_USE_MSVC_MultiThreadDLL "Use dynamically-link runtime library." OFF)
@@ -96,7 +99,7 @@ if( MSVC AND (SpecUtils_PYTHON_BINDINGS OR SpecUtils_BUILD_UNIT_TESTS) )
9699
endif()
97100
message(STATUS "Using CMAKE_MSVC_RUNTIME_LIBRARY ${CMAKE_MSVC_RUNTIME_LIBRARY}")
98101
endif(NOT hasParent)
99-
endif( MSVC AND (SpecUtils_PYTHON_BINDINGS OR SpecUtils_BUILD_UNIT_TESTS) )
102+
endif( MSVC )
100103

101104

102105
if( SpecUtils_BUILD_EXAMPLE )
@@ -330,7 +333,7 @@ if( SpecUtils_USE_FAST_FLOAT )
330333
FetchContent_GetProperties( fast_float )
331334
FetchContent_MakeAvailable( fast_float )
332335

333-
target_include_directories( SpecUtils PUBLIC ${fast_float_SOURCE_DIR} )
336+
target_include_directories( SpecUtils PRIVATE ${fast_float_SOURCE_DIR} )
334337
endif( SpecUtils_FETCH_FAST_FLOAT )
335338
endif( NOT FAST_FLOAT_FILE_PATH )
336339
endif( SpecUtils_USE_FAST_FLOAT )
@@ -417,6 +420,9 @@ if( SpecUtils_JAVA_SWIG )
417420
target_link_libraries( SpecUtils PUBLIC ${JAVA_LIBRARIES} )
418421
endif( SpecUtils_JAVA_SWIG )
419422

423+
if( SpecUtils_FORTRAN_SWIG )
424+
add_subdirectory(bindings/swig/fortran)
425+
endif( SpecUtils_FORTRAN_SWIG )
420426

421427
if( MINGW )
422428
target_link_libraries( SpecUtils PUBLIC -static-libgcc -static libshlwapi.a libpthread.a libstdc++.a libwinpthread.a libmsvcrt.a )
@@ -427,8 +433,8 @@ elseif( WIN32 )
427433
target_link_libraries( SpecUtils PUBLIC "Shlwapi.lib" )
428434
endif( MINGW )
429435

430-
target_include_directories( SpecUtils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
431-
PRIVATE ${THIRD_PARTY_DIR} ${Python3_INCLUDE_DIRS} )
436+
target_include_directories( SpecUtils PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
437+
PRIVATE ${THIRD_PARTY_DIR} ${PYTHON_INCLUDE_DIRS} )
432438

433439
if( SpecUtils_BUILD_REGRESSION_TEST )
434440
if( NOT SpecUtils_ENABLE_EQUALITY_CHECKS )
@@ -450,9 +456,74 @@ if( SpecUtils_BUILD_FUZZING_TESTS )
450456
add_subdirectory( fuzz_test )
451457
endif( SpecUtils_BUILD_FUZZING_TESTS )
452458

459+
set_property( TARGET SpecUtils PROPERTY POSITION_INDEPENDENT_CODE ON )
460+
461+
# Specify installation rules
462+
include(GNUInstallDirs)
463+
464+
465+
# Install the library
466+
install(TARGETS SpecUtils
467+
EXPORT SpecUtilsTargets
468+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
469+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
470+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
471+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
472+
)
473+
474+
set( SpecUtils_config_OUT ${CMAKE_CURRENT_BINARY_DIR}/SpecUtils_config.h )
453475
configure_file(
454476
${CMAKE_CURRENT_SOURCE_DIR}/SpecUtils/SpecUtils_config.h.in
455-
${CMAKE_CURRENT_BINARY_DIR}/SpecUtils_config.h
477+
${SpecUtils_config_OUT}
456478
)
479+
LIST(APPEND headers ${SpecUtils_config_OUT})
480+
# Install the headers
481+
install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SpecUtils)
457482

483+
# Create and install the CMake package configuration files
484+
include(CMakePackageConfigHelpers)
485+
486+
write_basic_package_version_file(
487+
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfigVersion.cmake"
488+
VERSION ${PROJECT_VERSION}
489+
COMPATIBILITY AnyNewerVersion
490+
)
491+
492+
configure_package_config_file(
493+
"${CMAKE_CURRENT_SOURCE_DIR}/SpecUtilsConfig.cmake.in"
494+
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfig.cmake"
495+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SpecUtils
496+
)
497+
498+
install(FILES
499+
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfig.cmake"
500+
"${CMAKE_CURRENT_BINARY_DIR}/SpecUtilsConfigVersion.cmake"
501+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SpecUtils
502+
)
503+
504+
install(EXPORT SpecUtilsTargets
505+
FILE SpecUtilsTargets.cmake
506+
NAMESPACE SpecUtils::
507+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SpecUtils
508+
)
509+
510+
set(CPACK_PACKAGE_NAME "SpecUtils")
511+
512+
513+
if( SpecUtils_SHARED_LIB )
514+
set( SpecUtils_PACKAGE_POSTFIX "SharedLib" )
515+
else( SpecUtils_SHARED_LIB )
516+
set( SpecUtils_PACKAGE_POSTFIX "StaticLib" )
517+
endif( SpecUtils_SHARED_LIB )
518+
519+
if( DEFINED ${PROJECT_NAME}_USE_MSVC_MultiThreadDLL )
520+
if( ${PROJECT_NAME}_USE_MSVC_MultiThreadDLL )
521+
set( SpecUtils_PACKAGE_POSTFIX "${SpecUtils_PACKAGE_POSTFIX}-SharedRuntime" )
522+
else()
523+
set( SpecUtils_PACKAGE_POSTFIX "${SpecUtils_PACKAGE_POSTFIX}-StaticRuntime" )
524+
endif()
525+
endif()
458526

527+
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}-${SpecUtils_PACKAGE_POSTFIX}")
528+
set(CPACK_GENERATOR "ZIP")
529+
include(CPack)

SpecUtils/EnergyCalibration.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
*/
4242
namespace SpecUtils
4343
{
44+
45+
using DevPair = std::pair<float,float>;
46+
using DeviationPairs = std::vector<DevPair>;
4447
/** The energy (or FWHM) calibration type that the calibration coefficients
4548
should be interpreted as.
4649

SpecUtils/ParseUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <istream>
3232
#include <ostream>
3333

34+
#include "SpecUtils/StringAlgo.h"
35+
3436
/** Some functions and definitions that help to parse and write spectrum files,
3537
but maybe dont fit in other sections of code.
3638
*/
@@ -290,6 +292,7 @@ Integral float_to_integral( float d )
290292
static constexpr Integral max_int_val = std::numeric_limits<Integral>::max();
291293
return std::signbit(d) ? min_int_val : max_int_val;
292294
}//float_to_integral
295+
293296
}//namespace SpecUtils
294297

295298
#endif //SpecUtils_ParseUtils_h

0 commit comments

Comments
 (0)