Skip to content

Commit

Permalink
Merge 2ce11ec into ba911c1
Browse files Browse the repository at this point in the history
  • Loading branch information
hbivens authored Oct 11, 2024
2 parents ba911c1 + 2ce11ec commit 7e9b9a3
Show file tree
Hide file tree
Showing 33 changed files with 31,518 additions and 252 deletions.
59 changes: 53 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,78 @@ 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

- 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=ON -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 == 'boost' && 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=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
cmake --build build_static_lib_shared_runtime --config Release --target package
#
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
cmake --build build_shared_lib_shared_runtime --config Release --target package
#
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
cmake --build build_shared_lib_static_runtime --config Release --target package
#
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
cmake --build build_static_lib_static_runtime --config Release --target package
# Update the bleeding-edge tag to be current commit
- name: Run latest-tag
uses: EndBug/[email protected]
if: runner.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
83 changes: 77 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ endif()

project( SpecUtils VERSION 1.0.0 )

enable_testing()

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 )
option( SpecUtils_ENABLE_URI_SPECTRA "Enables encoding/decoding spectra to URIs (for, ex, QR-codes) - requires linking to zlib" OFF )
Expand All @@ -21,6 +23,7 @@ option( SpecUtils_BUILD_REGRESSION_TEST "Creates executable to perform interacti
option( SpecUtils_BUILD_EXAMPLE "Builds example SpecUtil applications" OFF )
option( SpecUtils_PYTHON_BINDINGS "Creates python bindings to the c++ code" OFF )
option( SpecUtils_JAVA_SWIG "Creates swig/java bindings to the c++ code" OFF )
option( SpecUtils_FORTRAN_SWIG "Creates swig/FORTRAN bindings to the c++ code" 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 @@ -82,7 +85,7 @@ endif()


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


if( SpecUtils_BUILD_EXAMPLE )
Expand Down Expand Up @@ -330,7 +333,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 @@ -417,6 +420,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 @@ -427,8 +433,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} ${Python3_INCLUDE_DIRS} )
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 @@ -450,9 +456,74 @@ if( SpecUtils_BUILD_FUZZING_TESTS )
add_subdirectory( fuzz_test )
endif( SpecUtils_BUILD_FUZZING_TESTS )

set_property( TARGET SpecUtils PROPERTY POSITION_INDEPENDENT_CODE ON )

# Specify installation rules
include(GNUInstallDirs)


# Install the library
install(TARGETS SpecUtils
EXPORT SpecUtilsTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

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})
# Install the headers
install(FILES ${headers} 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()

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}")
set(CPACK_GENERATOR "ZIP")
include(CPack)
3 changes: 3 additions & 0 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
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

0 comments on commit 7e9b9a3

Please sign in to comment.