Skip to content

Commit

Permalink
Automated formatting of repo files
Browse files Browse the repository at this point in the history
  • Loading branch information
HELICS-bot committed Aug 13, 2021
1 parent 8a56760 commit 172fc7b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aliases:
cd build
eval cmake .. ${CMAKE_FLAGS}
make -j 4
- &run_units
name: run_units
environment:
Expand Down
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ if(UNITS_INSTALL)
if(UNITS_WITH_CMAKE_PACKAGE AND NOT UNITS_BINARY_ONLY_INSTALL)
install(EXPORT unitsConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/units)
export(EXPORT unitsConfig)
write_basic_package_version_file(${PROJECT_BINARY_DIR}/unitsConfigVersion.cmake COMPATIBILITY AnyNewerVersion)
install(FILES ${PROJECT_BINARY_DIR}/unitsConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/units)
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/unitsConfigVersion.cmake
COMPATIBILITY AnyNewerVersion
)
install(FILES ${PROJECT_BINARY_DIR}/unitsConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/units
)
endif()
endif()
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (!meas.units().is_convertible(out)

## Limitations

- The powers represented by units by default are limited see [Unit representation](#unit_representation) and only normal physical units or common operations are supported, this can be modified at compile time to support a much broader range at the expense of size and computation.
- The powers represented by units by default are limited see [Unit representation](#unit_representation) and only normal physical units or common operations are supported, this can be modified at compile time to support a much broader range at the expense of size and computation.
- The library uses floating point and double precision for the multipliers which is generally good enough for most engineering contexts, but does come with the limits and associated loss of precision for long series of calculations on floating point numbers.
- Currency is supported as a unit but it is not recommended to use this for anything beyond basic financial calculations. So if you are doing a lot of financial calculations or accounting use something more specific for currency manipulations.
- Fractional unit powers are not supported in general. While some mathematical operations on units are supported any root operations `sqrt` or `cbrt` will only produce valid results if the result is integral powers of the base units. One exception is limited support for √Hz operations in measurements of Amplitude spectral density. A specific definition of a unit representing square root of Hz is available and will work in combination with other units.
Expand Down Expand Up @@ -143,7 +143,7 @@ The seven [SI units](https://www.nist.gov/pml/weights-and-measures/metric-si/si-

These ranges were chosen to represent nearly all physical quantities that could be found in various disciplines we have encountered.

The CMake variable `UNITS_BASE_TYPE` if set to a 64 bit type like `uint64_t` will double the space requirements but also change the ranges to be at least a power of 4 larger than the above table. See [Cmake Reference](https://units.readthedocs.io/en/latest/installation/cmake_variables.html) for more details.
The CMake variable `UNITS_BASE_TYPE` if set to a 64 bit type like `uint64_t` will double the space requirements but also change the ranges to be at least a power of 4 larger than the above table. See [Cmake Reference](https://units.readthedocs.io/en/latest/installation/cmake_variables.html) for more details.

### Discussion points

Expand Down Expand Up @@ -172,7 +172,7 @@ There are two parts of the library a header only portion that can simply be copi

The second part is a few cpp files that can add some additional functionality. The primary additions from the cpp file are an ability to take roots of units and measurements and convert to and from strings. These files can be built as a standalone static library or included in the source code of whatever project want to use them. The code should build with an C++11 compiler. Most of the library is tagged with constexpr so can be run at compile time to link units that are known at compile time. Unit numerical conversions are not at compile time, so will have a run-time cost. A `quick_convert` function is available to do simple conversions. with a requirement that the units have the same base and not be an equation unit. The cpp code also includes some functions for commodities and will eventually have r20 and x12 conversions, though this is not complete yet.

It builds by default with the static library. Using `UNIT_BUILD_SHARED_LIBRARY` or `BUILD_SHARED_LIBS` will build the shared library instead. Either one can be used with CMake as units::units. The header only library target can also be generate `units::header_only`
It builds by default with the static library. Using `UNIT_BUILD_SHARED_LIBRARY` or `BUILD_SHARED_LIBS` will build the shared library instead. Either one can be used with CMake as units::units. The header only library target can also be generate `units::header_only`

## Try it out

Expand Down
114 changes: 59 additions & 55 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,64 +132,68 @@ else()
)
endif()


if(UNITS_INSTALL_PACKAGE_TESTS)
set(UNITS_PACKAGE_SEARCH_LOC)

set(UNITS_PACKAGE_SEARCH_LOC)

if(NOT MSVC)
set(package_test_command --test-command "${CMAKE_CTEST_COMMAND}")
else() # don't try to run the tests on MSVC since that would require copying the
# dll's and doing some other setup that isn't that important to run on
# all OS
set(package_test_command)
endif()

if(NOT MSVC)
set(package_test_command --test-command "${CMAKE_CTEST_COMMAND}")
else() # don't try to run the tests on MSVC since that would require copying the dll's and doing
# some other setup that isn't that important to run on all OS
set(package_test_command)
endif()
if(CMAKE_BUILD_TYPE)
set(UNITS_PACKAGE_TEST_BUILD_TYPE ${CMAKE_BUILD_TYPE})
else()
set(UNITS_PACKAGE_TEST_BUILD_TYPE Release)
endif()

if(CMAKE_BUILD_TYPE)
set(UNITS_PACKAGE_TEST_BUILD_TYPE ${CMAKE_BUILD_TYPE})
else()
set(UNITS_PACKAGE_TEST_BUILD_TYPE Release)
endif()

file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests")

if(MSVC AND ${CMAKE_VERSION} VERSION_GREATER 3.12.9)
# Tests for other CMake projects including and using UNITS using find_package
add_test(
NAME find-package-testsA
COMMAND
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -A "${CMAKE_GENERATOR_PLATFORM}"
${UNITS_PACKAGE_SEARCH_LOC}
"-DUNITS_BUILD_SHARED_LIBRARY=${UNITS_BUILD_SHARED_LIBRARY}"
"-DUNITS_HEADER_ONLY=${UNITS_HEADER_ONLY}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
"${CMAKE_CURRENT_SOURCE_DIR}/find_package_tests"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests"
)
else()
add_test(
NAME find-package-testsA
COMMAND
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${UNITS_PACKAGE_SEARCH_LOC}
"-DUNITS_BUILD_SHARED_LIBRARY=${UNITS_BUILD_SHARED_LIBRARY}"
"-DUNITS_HEADER_ONLY=${UNITS_HEADER_ONLY}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
"${CMAKE_CURRENT_SOURCE_DIR}/find_package_tests"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests"
)
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests")

if(MSVC AND ${CMAKE_VERSION} VERSION_GREATER 3.12.9)
# Tests for other CMake projects including and using UNITS using
# find_package
add_test(
NAME find-package-testsA
COMMAND
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -A
"${CMAKE_GENERATOR_PLATFORM}" ${UNITS_PACKAGE_SEARCH_LOC}
"-DUNITS_BUILD_SHARED_LIBRARY=${UNITS_BUILD_SHARED_LIBRARY}"
"-DUNITS_HEADER_ONLY=${UNITS_HEADER_ONLY}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
"${CMAKE_CURRENT_SOURCE_DIR}/find_package_tests"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests"
)
else()
add_test(
NAME find-package-testsA
COMMAND
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${UNITS_PACKAGE_SEARCH_LOC}
"-DUNITS_BUILD_SHARED_LIBRARY=${UNITS_BUILD_SHARED_LIBRARY}"
"-DUNITS_HEADER_ONLY=${UNITS_HEADER_ONLY}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
"${CMAKE_CURRENT_SOURCE_DIR}/find_package_tests"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests"
)
endif()

add_test(NAME find-package-testsB
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests" --config
${UNITS_PACKAGE_TEST_BUILD_TYPE}
)
add_test(
NAME find-package-testsB
COMMAND
${CMAKE_COMMAND} --build
"${CMAKE_CURRENT_BINARY_DIR}/find_package_tests" --config
${UNITS_PACKAGE_TEST_BUILD_TYPE}
)

add_test(NAME find-package-testsC COMMAND ${CMAKE_CTEST_COMMAND} -C
${UNITS_PACKAGE_TEST_BUILD_TYPE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests"
)
endif() #UNITS_INSTALL_PACKAGE_TESTS
add_test(
NAME find-package-testsC
COMMAND ${CMAKE_CTEST_COMMAND} -C ${UNITS_PACKAGE_TEST_BUILD_TYPE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/find_package_tests"
)
endif() # UNITS_INSTALL_PACKAGE_TESTS
endif() # UNITS_HEADER_ONLY
4 changes: 1 addition & 3 deletions test/find_package_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ if(UNITS_BUILD_SHARED_LIBRARY)
target_link_libraries(shared-library-test-exe units::units)

add_test(NAME shared-library-test COMMAND shared-library-test-exe)
set_property(
TEST shared-library-test PROPERTY PASS_REGULAR_EXPRESSION "10.7"
)
set_property(TEST shared-library-test PROPERTY PASS_REGULAR_EXPRESSION "10.7")

# Test the C and C++98 targets
elseif(UNITS_HEADER_ONLY)
Expand Down

0 comments on commit 172fc7b

Please sign in to comment.