diff --git a/conanfile.py b/conanfile.py index ff27e6cc..d8d8e141 100644 --- a/conanfile.py +++ b/conanfile.py @@ -104,7 +104,7 @@ class MPUnitsConan(ConanFile): def requirements(self): self.requires("gsl-lite/0.40.0") if self._use_libfmt: - self.requires("fmt/10.1.0") + self.requires("fmt/10.1.1") def build_requirements(self): if self._build_all: diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 5c4bc3c4..33d09727 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -22,15 +22,25 @@ cmake_minimum_required(VERSION 3.5) +# find dependencies +if(NOT TARGET gsl::gsl-lite) + find_package(gsl-lite CONFIG REQUIRED) +endif() + add_library(example_utils INTERFACE) target_include_directories(example_utils INTERFACE include) +target_link_libraries(example_utils INTERFACE gsl::gsl-lite) # -# add_example(target ...) +# add_example(target ...) # function(add_example target) add_executable(${target} ${target}.cpp) - target_link_libraries(${target} PRIVATE ${ARGN}) + if(TARGET mp-units::modules) + target_link_libraries(${target} PRIVATE mp-units::modules) + else() + target_link_libraries(${target} PRIVATE ${ARGN}) + endif() endfunction() add_example(avg_speed mp-units::core-io mp-units::si mp-units::cgs mp-units::usc) @@ -49,7 +59,8 @@ add_example( add_example(conversion_factor mp-units::core-fmt mp-units::core-io mp-units::si) add_example(currency mp-units::core-io) add_example(foot_pound_second mp-units::core-fmt mp-units::international mp-units::imperial) -add_example(glide_computer mp-units::core-fmt mp-units::international mp-units::utility glide_computer_lib) +add_example(glide_computer mp-units::core-fmt mp-units::international mp-units::utility) +target_link_libraries(glide_computer PRIVATE glide_computer_lib) add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::usc) add_example(measurement mp-units::core-io mp-units::si) add_example(si_constants mp-units::core-fmt mp-units::si) @@ -60,14 +71,9 @@ add_example( ) add_example(total_energy mp-units::core-io mp-units::si mp-units::natural mp-units::utility) add_example( - unmanned_aerial_vehicle - mp-units::core-fmt - mp-units::core-io - mp-units::si - mp-units::international - mp-units::utility - example_utils + unmanned_aerial_vehicle mp-units::core-fmt mp-units::core-io mp-units::si mp-units::international mp-units::utility ) +target_link_libraries(unmanned_aerial_vehicle PRIVATE example_utils) add_subdirectory(glide_computer_lib) add_subdirectory(kalman_filter) diff --git a/example/avg_speed.cpp b/example/avg_speed.cpp index 6744ede1..4443fb6d 100644 --- a/example/avg_speed.cpp +++ b/example/avg_speed.cpp @@ -25,13 +25,17 @@ // !!! renders correctly in the documentation "Examples" section. !!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include -#include -#include -#include -#include +#include +#include +#endif namespace { diff --git a/example/capacitor_time_curve.cpp b/example/capacitor_time_curve.cpp index d1fb12ce..02bbc271 100644 --- a/example/capacitor_time_curve.cpp +++ b/example/capacitor_time_curve.cpp @@ -20,11 +20,15 @@ physical_quantities */ +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include // IWYU pragma: keep #include #include #include -#include +#endif int main() { diff --git a/example/clcpp_response.cpp b/example/clcpp_response.cpp index fb9f93e3..58cdd912 100644 --- a/example/clcpp_response.cpp +++ b/example/clcpp_response.cpp @@ -15,6 +15,11 @@ along with this program. If not, see http://www.gnu.org/licenses./ */ +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include @@ -24,7 +29,7 @@ #include #include #include -#include +#endif namespace { diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 5a4eaa97..2b666b9c 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -15,12 +15,17 @@ along with this program. If not, see http://www.gnu.org/licenses./ */ +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include -#include -#include +#endif /* get conversion factor from one dimensionally equivalent diff --git a/example/currency.cpp b/example/currency.cpp index 28af832e..57cf5a57 100644 --- a/example/currency.cpp +++ b/example/currency.cpp @@ -20,11 +20,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units.core_io; +#else #include #include #include -#include -#include +#endif using namespace mp_units; diff --git a/example/foot_pound_second.cpp b/example/foot_pound_second.cpp index 9177cd0c..bfb5719d 100644 --- a/example/foot_pound_second.cpp +++ b/example/foot_pound_second.cpp @@ -20,14 +20,19 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include #include -#include -#include +#endif using namespace mp_units; using namespace mp_units::international::unit_symbols; diff --git a/example/glide_computer.cpp b/example/glide_computer.cpp index 09531727..cefe692e 100644 --- a/example/glide_computer.cpp +++ b/example/glide_computer.cpp @@ -22,10 +22,6 @@ #include "glide_computer_lib.h" #include -#include -#include -#include -#include #include #include #include @@ -33,6 +29,14 @@ #include #include #include +#ifdef MP_UNITS_MODULES +import mp_units; +#else +#include +#include +#include +#include +#endif namespace { diff --git a/example/glide_computer_lib/CMakeLists.txt b/example/glide_computer_lib/CMakeLists.txt index 9534977d..65d11b35 100644 --- a/example/glide_computer_lib/CMakeLists.txt +++ b/example/glide_computer_lib/CMakeLists.txt @@ -23,5 +23,10 @@ cmake_minimum_required(VERSION 3.5) add_library(glide_computer_lib STATIC glide_computer_lib.cpp include/glide_computer_lib.h) -target_link_libraries(glide_computer_lib PRIVATE mp-units::core-fmt PUBLIC mp-units::si mp-units::utility example_utils) +if(TARGET mp-units::modules) + target_link_libraries(glide_computer_lib PUBLIC gsl::gsl-lite mp-units::modules) +else() + target_link_libraries(glide_computer_lib PRIVATE mp-units::core-fmt PUBLIC mp-units::si mp-units::utility) +endif() +target_link_libraries(glide_computer_lib PUBLIC example_utils) target_include_directories(glide_computer_lib PUBLIC include) diff --git a/example/glide_computer_lib/glide_computer_lib.cpp b/example/glide_computer_lib/glide_computer_lib.cpp index c0fa44d7..70d26edf 100644 --- a/example/glide_computer_lib/glide_computer_lib.cpp +++ b/example/glide_computer_lib/glide_computer_lib.cpp @@ -21,10 +21,14 @@ // SOFTWARE. #include "glide_computer_lib.h" -#include #include #include #include +#ifdef MP_UNITS_MODULES +import mp_units.core_fmt; +#else +#include +#endif namespace glide_computer { diff --git a/example/glide_computer_lib/include/glide_computer_lib.h b/example/glide_computer_lib/include/glide_computer_lib.h index daa3fcf5..50229a9b 100644 --- a/example/glide_computer_lib/include/glide_computer_lib.h +++ b/example/glide_computer_lib/include/glide_computer_lib.h @@ -22,11 +22,9 @@ #pragma once +#include +// #include "geographic.h" -#include -#include // IWYU pragma: keep -#include -#include #include #include #include @@ -35,6 +33,14 @@ #include #include // IWYU pragma: keep #include +#ifdef MP_UNITS_MODULES +import mp_units; +#else +#include +#include // IWYU pragma: keep +#include +#include +#endif // An example of a really simplified tactical glide computer // Simplifications: diff --git a/example/hello_units.cpp b/example/hello_units.cpp index e537a7a6..6bc12235 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -25,12 +25,17 @@ // !!! renders correctly in the documentation "Examples" section. !!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include -#include +#endif using namespace mp_units; diff --git a/example/include/geographic.h b/example/include/geographic.h index f66fd1cf..ade0f6e0 100644 --- a/example/include/geographic.h +++ b/example/include/geographic.h @@ -24,6 +24,13 @@ #include "ranged_representation.h" #include +#include +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include @@ -31,10 +38,7 @@ #include #include #include -#include -#include -#include -#include +#endif namespace geographic { diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index 82f51846..2b7fff52 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -24,11 +24,15 @@ #include "validated_type.h" #include -#include -#include #include #include #include +#ifdef MP_UNITS_MODULES +import mp_units.core; +#else +#include +#include +#endif template) auto Min, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to) auto Max> diff --git a/example/include/validated_type.h b/example/include/validated_type.h index 15d540bc..77422ccc 100644 --- a/example/include/validated_type.h +++ b/example/include/validated_type.h @@ -23,11 +23,16 @@ #pragma once #include +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units.core_fmt; +#else #include #include #include -#include -#include +#endif inline constexpr struct validated_tag { } validated; diff --git a/example/kalman_filter/CMakeLists.txt b/example/kalman_filter/CMakeLists.txt index ef91cdcb..4c7954d9 100644 --- a/example/kalman_filter/CMakeLists.txt +++ b/example/kalman_filter/CMakeLists.txt @@ -27,7 +27,11 @@ cmake_minimum_required(VERSION 3.5) # function(add_example target) add_executable(${target} ${target}.cpp) - target_link_libraries(${target} PRIVATE ${ARGN}) + if(TARGET mp-units::modules) + target_link_libraries(${target} PRIVATE mp-units::modules) + else() + target_link_libraries(${target} PRIVATE ${ARGN}) + endif() endfunction() add_example(kalman_filter-example_1 mp-units::core-fmt mp-units::si mp-units::utility) diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index dd925f55..310d9941 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -23,12 +23,16 @@ #pragma once #include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include -#include +#endif namespace kalman { diff --git a/example/kalman_filter/kalman_filter-example_1.cpp b/example/kalman_filter/kalman_filter-example_1.cpp index bee71761..c038f253 100644 --- a/example/kalman_filter/kalman_filter-example_1.cpp +++ b/example/kalman_filter/kalman_filter-example_1.cpp @@ -21,11 +21,15 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/alphabeta.html#ex1 diff --git a/example/kalman_filter/kalman_filter-example_2.cpp b/example/kalman_filter/kalman_filter-example_2.cpp index ac748ca3..0260d2de 100644 --- a/example/kalman_filter/kalman_filter-example_2.cpp +++ b/example/kalman_filter/kalman_filter-example_2.cpp @@ -21,11 +21,15 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/alphabeta.html#ex2 diff --git a/example/kalman_filter/kalman_filter-example_3.cpp b/example/kalman_filter/kalman_filter-example_3.cpp index 1fb2e32f..5d453d48 100644 --- a/example/kalman_filter/kalman_filter-example_3.cpp +++ b/example/kalman_filter/kalman_filter-example_3.cpp @@ -21,11 +21,15 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/alphabeta.html#ex3 diff --git a/example/kalman_filter/kalman_filter-example_4.cpp b/example/kalman_filter/kalman_filter-example_4.cpp index cc5044ea..00696c02 100644 --- a/example/kalman_filter/kalman_filter-example_4.cpp +++ b/example/kalman_filter/kalman_filter-example_4.cpp @@ -21,11 +21,15 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/alphabeta.html#ex4 diff --git a/example/kalman_filter/kalman_filter-example_5.cpp b/example/kalman_filter/kalman_filter-example_5.cpp index e50114eb..b4be7e3c 100644 --- a/example/kalman_filter/kalman_filter-example_5.cpp +++ b/example/kalman_filter/kalman_filter-example_5.cpp @@ -21,12 +21,16 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/kalman1d.html#ex5 diff --git a/example/kalman_filter/kalman_filter-example_6.cpp b/example/kalman_filter/kalman_filter-example_6.cpp index 23660370..a6ab2131 100644 --- a/example/kalman_filter/kalman_filter-example_6.cpp +++ b/example/kalman_filter/kalman_filter-example_6.cpp @@ -21,13 +21,17 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/kalman1d.html#ex6 diff --git a/example/kalman_filter/kalman_filter-example_7.cpp b/example/kalman_filter/kalman_filter-example_7.cpp index d82d7323..49c832fe 100644 --- a/example/kalman_filter/kalman_filter-example_7.cpp +++ b/example/kalman_filter/kalman_filter-example_7.cpp @@ -21,13 +21,17 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/kalman1d.html#ex7 diff --git a/example/kalman_filter/kalman_filter-example_8.cpp b/example/kalman_filter/kalman_filter-example_8.cpp index ca02b7bd..474ecff7 100644 --- a/example/kalman_filter/kalman_filter-example_8.cpp +++ b/example/kalman_filter/kalman_filter-example_8.cpp @@ -21,13 +21,17 @@ // SOFTWARE. #include "kalman.h" +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include -#include -#include +#endif // Based on: https://www.kalmanfilter.net/kalman1d.html#ex8 diff --git a/example/measurement.cpp b/example/measurement.cpp index cd36aa92..0f3813e7 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -20,13 +20,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include -#include -#include -#include +#endif namespace { diff --git a/example/si_constants.cpp b/example/si_constants.cpp index 255f8054..35d855d5 100644 --- a/example/si_constants.cpp +++ b/example/si_constants.cpp @@ -25,9 +25,14 @@ // !!! renders correctly in the documentation "Examples" section. !!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include -#include +#endif template requires mp_units::is_scalar diff --git a/example/spectroscopy_units.cpp b/example/spectroscopy_units.cpp index 363605a1..7a6270d6 100644 --- a/example/spectroscopy_units.cpp +++ b/example/spectroscopy_units.cpp @@ -20,11 +20,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include -#include -#include +#endif // This example implements a table of units provided in the following article // http://cds.cern.ch/record/1481609/files/978-3-642-18018-7_BookBackMatter.pdf diff --git a/example/storage_tank.cpp b/example/storage_tank.cpp index d975e9e0..84d1c42c 100644 --- a/example/storage_tank.cpp +++ b/example/storage_tank.cpp @@ -20,6 +20,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#include +#include +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include @@ -28,11 +38,7 @@ #include #include #include -#include -#include -#include -#include -#include +#endif // allows standard gravity (acceleration) and weight (force) to be expressed with scalar representation // types instead of requiring the usage of Linear Algebra library for this simple example diff --git a/example/strong_angular_quantities.cpp b/example/strong_angular_quantities.cpp index 7d375e3c..298a097e 100644 --- a/example/strong_angular_quantities.cpp +++ b/example/strong_angular_quantities.cpp @@ -20,11 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include -#include +#endif template requires mp_units::is_scalar diff --git a/example/total_energy.cpp b/example/total_energy.cpp index fa83a6cd..116ac4ad 100644 --- a/example/total_energy.cpp +++ b/example/total_energy.cpp @@ -20,14 +20,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include #include -#include -#include +#endif template requires mp_units::is_scalar @@ -56,31 +60,21 @@ void si_example() std::cout << "\n*** SI units (c = " << c << " = " << c.in(si::metre / s) << ") ***\n"; - std::cout << "\n[in `GeV` and `c`]\n" - << "p = " << p1 << "\n" - << "m = " << m1 << "\n" - << "E = " << E << "\n"; + std::cout << "\n[in `GeV` and `c`]\n" << "p = " << p1 << "\n" << "m = " << m1 << "\n" << "E = " << E << "\n"; const auto p2 = p1.in(GeV / (m / s)); const auto m2 = m1.in(GeV / pow<2>(m / s)); const auto E2 = total_energy(p2, m2, c).in(GeV); - std::cout << "\n[in `GeV`]\n" - << "p = " << p2 << "\n" - << "m = " << m2 << "\n" - << "E = " << E2 << "\n"; + std::cout << "\n[in `GeV`]\n" << "p = " << p2 << "\n" << "m = " << m2 << "\n" << "E = " << E2 << "\n"; const auto p3 = p1.in(kg * m / s); const auto m3 = m1.in(kg); const auto E3 = total_energy(p3, m3, c).in(J); - std::cout << "\n[in SI base units]\n" - << "p = " << p3 << "\n" - << "m = " << m3 << "\n" - << "E = " << E3 << "\n"; + std::cout << "\n[in SI base units]\n" << "p = " << p3 << "\n" << "m = " << m3 << "\n" << "E = " << E3 << "\n"; - std::cout << "\n[converted from SI units back to GeV]\n" - << "E = " << E3.force_in(GeV) << "\n"; + std::cout << "\n[converted from SI units back to GeV]\n" << "E = " << E3.force_in(GeV) << "\n"; } void natural_example() diff --git a/example/unmanned_aerial_vehicle.cpp b/example/unmanned_aerial_vehicle.cpp index fe465f68..6e089939 100644 --- a/example/unmanned_aerial_vehicle.cpp +++ b/example/unmanned_aerial_vehicle.cpp @@ -21,13 +21,18 @@ // SOFTWARE. #include "geographic.h" +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include -#include -#include +#endif using namespace mp_units; using namespace geographic; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 739e553e..0c5a3fe7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,9 @@ set(projectPrefix MP_UNITS_) option(${projectPrefix}AS_SYSTEM_HEADERS "Exports library as system headers" OFF) message(STATUS "${projectPrefix}AS_SYSTEM_HEADERS: ${${projectPrefix}AS_SYSTEM_HEADERS}") +option(${projectPrefix}BUILD_CXX_MODULES "Add C++ modules to the list of default targets" OFF) +message(STATUS "${projectPrefix}BUILD_CXX_MODULES: ${${projectPrefix}BUILD_CXX_MODULES}") + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") include(AddUnitsModule) @@ -37,7 +40,9 @@ if(${projectPrefix}AS_SYSTEM_HEADERS) set(unitsAsSystem SYSTEM) endif() +add_subdirectory(core-macros) add_subdirectory(core) +add_subdirectory(core-fmt-macros) add_subdirectory(core-fmt) add_subdirectory(core-io) add_subdirectory(systems) @@ -51,6 +56,59 @@ target_link_libraries( add_library(mp-units::mp-units ALIAS mp-units) install(TARGETS mp-units EXPORT mp-unitsTargets) +# C++ modules +if(${projectPrefix}BUILD_CXX_MODULES) + add_library(mp-units-core-module) + add_library(mp-units::core-module ALIAS mp-units-core-module) + target_sources( + mp-units-core-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES + "mp-units-core.cpp" + ) + target_compile_definitions(mp-units-core-module INTERFACE MP_UNITS_MODULES) + target_link_libraries(mp-units-core-module PRIVATE mp-units::core PUBLIC mp-units::core-macros) + if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18) + target_compile_options(mp-units-core-module PUBLIC "-Wno-include-angled-in-module-purview") + endif() + + add_library(mp-units-core-fmt-module) + add_library(mp-units::core-fmt-module ALIAS mp-units-core-fmt-module) + target_sources( + mp-units-core-fmt-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES + "mp-units-core-fmt.cpp" + ) + target_link_libraries( + mp-units-core-fmt-module PRIVATE mp-units::core-fmt PUBLIC mp-units::core-fmt-macros mp-units::core-module + ) + + add_library(mp-units-core-io-module) + add_library(mp-units::core-io-module ALIAS mp-units-core-io-module) + target_sources( + mp-units-core-io-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES + "mp-units-core-io.cpp" + ) + target_link_libraries(mp-units-core-io-module PRIVATE mp-units::core-io PUBLIC mp-units::core-module) + + add_library(mp-units-systems-module) + add_library(mp-units::systems-module ALIAS mp-units-systems-module) + target_sources( + mp-units-systems-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES + "mp-units-systems.cpp" + ) + target_link_libraries( + mp-units-systems-module PRIVATE mp-units::systems mp-units::utility PUBLIC mp-units::core-module + ) + + add_library(mp-units-modules) + add_library(mp-units::modules ALIAS mp-units-modules) + target_sources( + mp-units-modules PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES "mp-units.cpp" + ) + target_link_libraries( + mp-units-modules PUBLIC mp-units::core-module mp-units::core-fmt-module mp-units::core-io-module + mp-units::systems-module + ) +endif() + # local build export(EXPORT mp-unitsTargets NAMESPACE mp-units::) configure_file("mp-unitsConfig.cmake" "." COPYONLY) diff --git a/src/core-fmt-macros/CMakeLists.txt b/src/core-fmt-macros/CMakeLists.txt new file mode 100644 index 00000000..8f6bc13c --- /dev/null +++ b/src/core-fmt-macros/CMakeLists.txt @@ -0,0 +1,45 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Mateusz Pusz +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +cmake_minimum_required(VERSION 3.19) + +# core-fmt-macros library definition +add_library(mp-units-core-fmt-macros INTERFACE include/mp-units/bits/fmt_hacks.h) +target_include_directories( + mp-units-core-fmt-macros ${unitsAsSystem} INTERFACE $ + $ +) +target_link_libraries(mp-units-core-fmt-macros INTERFACE mp-units::core-macros) + +if(${projectPrefix}USE_LIBFMT) + if(NOT TARGET fmt::fmt) + find_package(fmt CONFIG REQUIRED) + endif() + target_link_libraries(mp-units-core-fmt-macros INTERFACE fmt::fmt) +endif() + +set_target_properties(mp-units-core-fmt-macros PROPERTIES EXPORT_NAME core-fmt-macros) +add_library(mp-units::core-fmt-macros ALIAS mp-units-core-fmt-macros) + +# installation +install(TARGETS mp-units-core-fmt-macros EXPORT mp-unitsTargets) +install(DIRECTORY include/mp-units TYPE INCLUDE) diff --git a/src/core-fmt/include/mp-units/bits/fmt_hacks.h b/src/core-fmt-macros/include/mp-units/bits/fmt_hacks.h similarity index 99% rename from src/core-fmt/include/mp-units/bits/fmt_hacks.h rename to src/core-fmt-macros/include/mp-units/bits/fmt_hacks.h index 008c3159..3ac40aad 100644 --- a/src/core-fmt/include/mp-units/bits/fmt_hacks.h +++ b/src/core-fmt-macros/include/mp-units/bits/fmt_hacks.h @@ -27,6 +27,8 @@ // // For the license information refer to format.h. +#pragma once + #include #ifndef MP_UNITS_USE_LIBFMT diff --git a/src/core-fmt/CMakeLists.txt b/src/core-fmt/CMakeLists.txt index 99f2ce04..35a59370 100644 --- a/src/core-fmt/CMakeLists.txt +++ b/src/core-fmt/CMakeLists.txt @@ -27,6 +27,7 @@ message(STATUS "${projectPrefix}USE_LIBFMT: ${${projectPrefix}USE_LIBFMT}") add_units_module(core-fmt DEPENDENCIES mp-units::core HEADERS include/mp-units/format.h) target_compile_definitions(mp-units-core-fmt INTERFACE ${projectPrefix}USE_LIBFMT=$) +target_link_libraries(mp-units-core-fmt INTERFACE mp-units::core-fmt-macros) if(${projectPrefix}USE_LIBFMT) if(NOT TARGET fmt::fmt) diff --git a/src/core-macros/CMakeLists.txt b/src/core-macros/CMakeLists.txt new file mode 100644 index 00000000..38bfe974 --- /dev/null +++ b/src/core-macros/CMakeLists.txt @@ -0,0 +1,40 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Mateusz Pusz +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +cmake_minimum_required(VERSION 3.19) + +# core-macros library definition +add_library( + mp-units-core-macros INTERFACE include/mp-units/bits/external/hacks.h include/mp-units/quantity_spec_macro.h +) +target_compile_features(mp-units-core-macros INTERFACE cxx_std_20) +target_include_directories( + mp-units-core-macros ${unitsAsSystem} INTERFACE $ + $ +) + +set_target_properties(mp-units-core-macros PROPERTIES EXPORT_NAME core-macros) +add_library(mp-units::core-macros ALIAS mp-units-core-macros) + +# installation +install(TARGETS mp-units-core-macros EXPORT mp-unitsTargets) +install(DIRECTORY include/mp-units TYPE INCLUDE) diff --git a/src/core-macros/include/mp-units/bits/core-gmf.h b/src/core-macros/include/mp-units/bits/core-gmf.h new file mode 100644 index 00000000..fdcd10ad --- /dev/null +++ b/src/core-macros/include/mp-units/bits/core-gmf.h @@ -0,0 +1,50 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +// core +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// utility +#include +#include +#include diff --git a/src/core/include/mp-units/bits/external/hacks.h b/src/core-macros/include/mp-units/bits/external/hacks.h similarity index 100% rename from src/core/include/mp-units/bits/external/hacks.h rename to src/core-macros/include/mp-units/bits/external/hacks.h diff --git a/src/core-macros/include/mp-units/quantity_spec_macro.h b/src/core-macros/include/mp-units/quantity_spec_macro.h new file mode 100644 index 00000000..9e45b833 --- /dev/null +++ b/src/core-macros/include/mp-units/quantity_spec_macro.h @@ -0,0 +1,37 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#ifdef __cpp_explicit_this_parameter + +#define QUANTITY_SPEC(name, ...) \ + inline constexpr struct name : ::mp_units::quantity_spec<__VA_ARGS__> { \ + } name + +#else + +#define QUANTITY_SPEC(name, ...) \ + inline constexpr struct name : ::mp_units::quantity_spec { \ + } name + +#endif diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7159996e..0abde4e6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -33,7 +33,6 @@ add_library( INTERFACE include/mp-units/bits/external/algorithm.h include/mp-units/bits/external/fixed_string.h - include/mp-units/bits/external/hacks.h include/mp-units/bits/external/math_concepts.h include/mp-units/bits/external/prime.h include/mp-units/bits/external/type_list.h @@ -44,6 +43,7 @@ add_library( include/mp-units/bits/get_associated_quantity.h include/mp-units/bits/get_common_base.h include/mp-units/bits/magnitude.h + include/mp-units/bits/math_core.h include/mp-units/bits/quantity_cast.h include/mp-units/bits/quantity_concepts.h include/mp-units/bits/quantity_point_concepts.h @@ -67,8 +67,7 @@ add_library( include/mp-units/system_reference.h include/mp-units/unit.h ) -target_compile_features(mp-units-core INTERFACE cxx_std_20) -target_link_libraries(mp-units-core INTERFACE gsl::gsl-lite) +target_link_libraries(mp-units-core INTERFACE gsl::gsl-lite mp-units::core-macros) target_include_directories( mp-units-core ${unitsAsSystem} INTERFACE $ $ diff --git a/src/utility/include/mp-units/bits/math_core.h b/src/core/include/mp-units/bits/math_core.h similarity index 100% rename from src/utility/include/mp-units/bits/math_core.h rename to src/core/include/mp-units/bits/math_core.h diff --git a/src/core/include/mp-units/core.h b/src/core/include/mp-units/core.h index b6c3682d..209076f0 100644 --- a/src/core/include/mp-units/core.h +++ b/src/core/include/mp-units/core.h @@ -22,6 +22,7 @@ #pragma once +#include #include #include #include diff --git a/src/core/include/mp-units/quantity_spec.h b/src/core/include/mp-units/quantity_spec.h index c9b242d4..4550c1e7 100644 --- a/src/core/include/mp-units/quantity_spec.h +++ b/src/core/include/mp-units/quantity_spec.h @@ -32,6 +32,7 @@ #include #include #include +#include #include namespace mp_units { @@ -364,20 +365,6 @@ struct quantity_spec : quantity_spec { static constexpr quantity_character character = detail::quantity_character_init(Eq.character); }; -#ifdef __cpp_explicit_this_parameter - -#define QUANTITY_SPEC(name, ...) \ - inline constexpr struct name : ::mp_units::quantity_spec<__VA_ARGS__> { \ - } name - -#else - -#define QUANTITY_SPEC(name, ...) \ - inline constexpr struct name : ::mp_units::quantity_spec { \ - } name - -#endif - /** * @brief A specification of a derived quantity diff --git a/src/mp-units-core-fmt.cpp b/src/mp-units-core-fmt.cpp new file mode 100644 index 00000000..8576e7bb --- /dev/null +++ b/src/mp-units-core-fmt.cpp @@ -0,0 +1,13 @@ +module; + +#include +#include + +export module mp_units.core_fmt; + +export import mp_units.core; + +export +{ +#include +} diff --git a/src/mp-units-core-io.cpp b/src/mp-units-core-io.cpp new file mode 100644 index 00000000..db16a2df --- /dev/null +++ b/src/mp-units-core-io.cpp @@ -0,0 +1,13 @@ +module; + +#include +#include + +export module mp_units.core_io; + +export import mp_units.core; + +export +{ +#include +} diff --git a/src/mp-units-core.cpp b/src/mp-units-core.cpp new file mode 100644 index 00000000..b0ddbb81 --- /dev/null +++ b/src/mp-units-core.cpp @@ -0,0 +1,11 @@ +module; + +#include + +export module mp_units.core; + +export +{ +// core +#include +} diff --git a/src/mp-units-systems.cpp b/src/mp-units-systems.cpp new file mode 100644 index 00000000..250bd9eb --- /dev/null +++ b/src/mp-units-systems.cpp @@ -0,0 +1,32 @@ +module; + +#include +#include + +export module mp_units.systems; + +export import mp_units.core; + +export +{ +// systems +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// utility +#include +#include +#include +#include +} diff --git a/src/mp-units.cpp b/src/mp-units.cpp new file mode 100644 index 00000000..30218060 --- /dev/null +++ b/src/mp-units.cpp @@ -0,0 +1,8 @@ +module; + +export module mp_units; + +export import mp_units.core; +export import mp_units.core_fmt; +export import mp_units.core_io; +export import mp_units.systems; diff --git a/src/utility/include/mp-units/math.h b/src/utility/include/mp-units/math.h index 0a37935d..c8d9dce2 100644 --- a/src/utility/include/mp-units/math.h +++ b/src/utility/include/mp-units/math.h @@ -29,5 +29,5 @@ // This header is intentionally empty and just include other headers // `math.h` is just a convenience wrapper for not modular code // With C++20 modules: -// - math_core will be a part of the mp_units.core module -// - math_si and math_angular will be provided with the mp_units.systems module +// - math_core is be a part of the mp_units.core module +// - math_si and math_angular is provided with the mp_units.systems module diff --git a/test/unit_test/runtime/CMakeLists.txt b/test/unit_test/runtime/CMakeLists.txt index 29846ad2..21686ab5 100644 --- a/test/unit_test/runtime/CMakeLists.txt +++ b/test/unit_test/runtime/CMakeLists.txt @@ -25,7 +25,12 @@ cmake_minimum_required(VERSION 3.5) find_package(Catch2 3 CONFIG REQUIRED) add_executable(unit_tests_runtime distribution_test.cpp fmt_test.cpp math_test.cpp) -target_link_libraries(unit_tests_runtime PRIVATE mp-units::mp-units Catch2::Catch2WithMain) +if(TARGET mp-units::modules) + target_link_libraries(unit_tests_runtime PRIVATE mp-units::modules) +else() + target_link_libraries(unit_tests_runtime PRIVATE mp-units::mp-units) +endif() +target_link_libraries(unit_tests_runtime PRIVATE Catch2::Catch2WithMain) if(${projectPrefix}BUILD_LA) find_package(wg21_linear_algebra CONFIG REQUIRED) diff --git a/test/unit_test/runtime/almost_equals.h b/test/unit_test/runtime/almost_equals.h index 264182f3..8a871fe9 100644 --- a/test/unit_test/runtime/almost_equals.h +++ b/test/unit_test/runtime/almost_equals.h @@ -21,9 +21,14 @@ // SOFTWARE. #include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include -#include +#endif namespace mp_units { diff --git a/test/unit_test/runtime/distribution_test.cpp b/test/unit_test/runtime/distribution_test.cpp index 5b14ae7f..d3786989 100644 --- a/test/unit_test/runtime/distribution_test.cpp +++ b/test/unit_test/runtime/distribution_test.cpp @@ -21,14 +21,18 @@ // SOFTWARE. #include -#include -#include -#include -#include #include #include #include #include +#ifdef MP_UNITS_MODULES +import mp_units; +#else +#include +#include +#include +#include +#endif using namespace mp_units; diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index bda7b936..482838b4 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -22,6 +22,13 @@ #include #include +#include +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include @@ -29,9 +36,7 @@ #include #include #include -#include -#include -#include +#endif template requires mp_units::is_scalar diff --git a/test/unit_test/runtime/linear_algebra_test.cpp b/test/unit_test/runtime/linear_algebra_test.cpp index 492e3bf8..4e227728 100644 --- a/test/unit_test/runtime/linear_algebra_test.cpp +++ b/test/unit_test/runtime/linear_algebra_test.cpp @@ -21,6 +21,12 @@ // SOFTWARE. #include +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include @@ -28,8 +34,7 @@ #include #include #include -#include -#include +#endif template using vector = STD_LA::fixed_size_column_vector; diff --git a/test/unit_test/runtime/math_test.cpp b/test/unit_test/runtime/math_test.cpp index 47e78d74..c6dcc589 100644 --- a/test/unit_test/runtime/math_test.cpp +++ b/test/unit_test/runtime/math_test.cpp @@ -22,13 +22,17 @@ #include "almost_equals.h" #include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include #include -#include +#endif using namespace mp_units; using namespace mp_units::si::unit_symbols; diff --git a/test/unit_test/static/CMakeLists.txt b/test/unit_test/static/CMakeLists.txt index 09e09ffd..37cb00c7 100644 --- a/test/unit_test/static/CMakeLists.txt +++ b/test/unit_test/static/CMakeLists.txt @@ -23,7 +23,11 @@ cmake_minimum_required(VERSION 3.5) add_library(unit_tests_static_truncating quantity_test.cpp) -target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::mp-units) +if(TARGET mp-units::modules) + target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::modules) +else() + target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::mp-units) +endif() target_compile_options( unit_tests_static_truncating PRIVATE $,/wd4242 /wd4244,-Wno-conversion> ) @@ -64,5 +68,9 @@ add_library( usc_test.cpp ) -target_link_libraries(unit_tests_static PRIVATE mp-units::mp-units) -target_link_libraries(unit_tests_static PRIVATE unit_tests_static_truncating mp-units::mp-units) +if(TARGET mp-units::modules) + target_link_libraries(unit_tests_static PRIVATE mp-units::modules) +else() + target_link_libraries(unit_tests_static PRIVATE mp-units::mp-units) +endif() +target_link_libraries(unit_tests_static PRIVATE unit_tests_static_truncating) diff --git a/test/unit_test/static/angular_test.cpp b/test/unit_test/static/angular_test.cpp index c3010dfe..c0c5a23b 100644 --- a/test/unit_test/static/angular_test.cpp +++ b/test/unit_test/static/angular_test.cpp @@ -20,8 +20,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include #include +#ifdef MP_UNITS_MODULES +import mp_units; +#else +#include +#endif namespace { diff --git a/test/unit_test/static/cgs_test.cpp b/test/unit_test/static/cgs_test.cpp index c58c5885..2d2bbf0c 100644 --- a/test/unit_test/static/cgs_test.cpp +++ b/test/unit_test/static/cgs_test.cpp @@ -21,10 +21,14 @@ // SOFTWARE. #include "test_tools.h" +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include +#endif template requires mp_units::is_scalar diff --git a/test/unit_test/static/chrono_test.cpp b/test/unit_test/static/chrono_test.cpp index b8c61fa5..df5fa356 100644 --- a/test/unit_test/static/chrono_test.cpp +++ b/test/unit_test/static/chrono_test.cpp @@ -21,11 +21,16 @@ // SOFTWARE. #include "test_tools.h" +#include +#ifdef MP_UNITS_MODULES +#include +import mp_units; +#else #include #include #include #include -#include +#endif namespace { diff --git a/test/unit_test/static/compare_test.cpp b/test/unit_test/static/compare_test.cpp index 5de812d9..6c966f19 100644 --- a/test/unit_test/static/compare_test.cpp +++ b/test/unit_test/static/compare_test.cpp @@ -20,8 +20,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include +#endif namespace { diff --git a/test/unit_test/static/concepts_test.cpp b/test/unit_test/static/concepts_test.cpp index 4312e638..2c050f8b 100644 --- a/test/unit_test/static/concepts_test.cpp +++ b/test/unit_test/static/concepts_test.cpp @@ -20,16 +20,20 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include #include -#include -#include -#include -#include +#endif template inline constexpr bool mp_units::is_scalar> = true; diff --git a/test/unit_test/static/custom_rep_test_min_expl.cpp b/test/unit_test/static/custom_rep_test_min_expl.cpp index 689c9666..9288679d 100644 --- a/test/unit_test/static/custom_rep_test_min_expl.cpp +++ b/test/unit_test/static/custom_rep_test_min_expl.cpp @@ -20,11 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include -#include -#include +#endif namespace { diff --git a/test/unit_test/static/custom_rep_test_min_impl.cpp b/test/unit_test/static/custom_rep_test_min_impl.cpp index 7d18effd..2ebc01a6 100644 --- a/test/unit_test/static/custom_rep_test_min_impl.cpp +++ b/test/unit_test/static/custom_rep_test_min_impl.cpp @@ -20,8 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include +#include #include +#ifdef MP_UNITS_MODULES +import mp_units; +#else +#include +#endif namespace { diff --git a/test/unit_test/static/dimension_test.cpp b/test/unit_test/static/dimension_test.cpp index 808620d7..04a95357 100644 --- a/test/unit_test/static/dimension_test.cpp +++ b/test/unit_test/static/dimension_test.cpp @@ -21,11 +21,15 @@ // SOFTWARE. #include "test_tools.h" +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include +#endif namespace { diff --git a/test/unit_test/static/fixed_string_test.cpp b/test/unit_test/static/fixed_string_test.cpp index 4835fbdf..c4a56aed 100644 --- a/test/unit_test/static/fixed_string_test.cpp +++ b/test/unit_test/static/fixed_string_test.cpp @@ -20,7 +20,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include +#endif using namespace mp_units; diff --git a/test/unit_test/static/fractional_exponent_quantity.cpp b/test/unit_test/static/fractional_exponent_quantity.cpp index d8a1b513..6014b34e 100644 --- a/test/unit_test/static/fractional_exponent_quantity.cpp +++ b/test/unit_test/static/fractional_exponent_quantity.cpp @@ -20,9 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include +#endif namespace { diff --git a/test/unit_test/static/hep_test.cpp b/test/unit_test/static/hep_test.cpp index 93a95321..d5e2384a 100644 --- a/test/unit_test/static/hep_test.cpp +++ b/test/unit_test/static/hep_test.cpp @@ -20,10 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include +#endif template requires mp_units::is_scalar diff --git a/test/unit_test/static/iau_test.cpp b/test/unit_test/static/iau_test.cpp index 6e414b0b..54738538 100644 --- a/test/unit_test/static/iau_test.cpp +++ b/test/unit_test/static/iau_test.cpp @@ -20,9 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include +#endif /* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */ diff --git a/test/unit_test/static/iec80000_test.cpp b/test/unit_test/static/iec80000_test.cpp index 2718758f..1021a6cc 100644 --- a/test/unit_test/static/iec80000_test.cpp +++ b/test/unit_test/static/iec80000_test.cpp @@ -20,10 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include +#endif /* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */ diff --git a/test/unit_test/static/imperial_test.cpp b/test/unit_test/static/imperial_test.cpp index 7b3b3a74..13d1ed26 100644 --- a/test/unit_test/static/imperial_test.cpp +++ b/test/unit_test/static/imperial_test.cpp @@ -20,9 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include +#endif namespace { diff --git a/test/unit_test/static/international_test.cpp b/test/unit_test/static/international_test.cpp index a5a31219..910c9e26 100644 --- a/test/unit_test/static/international_test.cpp +++ b/test/unit_test/static/international_test.cpp @@ -20,12 +20,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include #include +#endif template requires mp_units::is_scalar diff --git a/test/unit_test/static/isq_angle_test.cpp b/test/unit_test/static/isq_angle_test.cpp index ef597076..fdb32496 100644 --- a/test/unit_test/static/isq_angle_test.cpp +++ b/test/unit_test/static/isq_angle_test.cpp @@ -20,8 +20,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include +#endif namespace { diff --git a/test/unit_test/static/isq_test.cpp b/test/unit_test/static/isq_test.cpp index 4d7333f2..9a67d44e 100644 --- a/test/unit_test/static/isq_test.cpp +++ b/test/unit_test/static/isq_test.cpp @@ -20,9 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include +#endif namespace { diff --git a/test/unit_test/static/magnitude_test.cpp b/test/unit_test/static/magnitude_test.cpp index eaf2cc17..f0eb031b 100644 --- a/test/unit_test/static/magnitude_test.cpp +++ b/test/unit_test/static/magnitude_test.cpp @@ -20,9 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include +#endif using namespace units; using namespace units::detail; diff --git a/test/unit_test/static/math_test.cpp b/test/unit_test/static/math_test.cpp index 528ea206..d4f52037 100644 --- a/test/unit_test/static/math_test.cpp +++ b/test/unit_test/static/math_test.cpp @@ -20,11 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include // IWYU pragma: keep #include #include #include -#include +#endif namespace { diff --git a/test/unit_test/static/natural_test.cpp b/test/unit_test/static/natural_test.cpp index 7880642b..f24f31e1 100644 --- a/test/unit_test/static/natural_test.cpp +++ b/test/unit_test/static/natural_test.cpp @@ -20,8 +20,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include +#endif template requires mp_units::is_scalar diff --git a/test/unit_test/static/prime_test.cpp b/test/unit_test/static/prime_test.cpp index 0fd724bd..d6647a10 100644 --- a/test/unit_test/static/prime_test.cpp +++ b/test/unit_test/static/prime_test.cpp @@ -20,9 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include #include #include +#ifdef MP_UNITS_MODULES +import mp_units; +#else +#include +#endif using namespace mp_units::detail; diff --git a/test/unit_test/static/quantity_point_test.cpp b/test/unit_test/static/quantity_point_test.cpp index 4ebfb5ad..b44da9f0 100644 --- a/test/unit_test/static/quantity_point_test.cpp +++ b/test/unit_test/static/quantity_point_test.cpp @@ -21,14 +21,19 @@ // SOFTWARE. #include "test_tools.h" +#include +#include +#include +#ifdef MP_UNITS_MODULES +#include +import mp_units; +#else #include #include #include #include #include -#include -#include -#include +#endif namespace { diff --git a/test/unit_test/static/quantity_spec_test.cpp b/test/unit_test/static/quantity_spec_test.cpp index ab7694c1..d9713686 100644 --- a/test/unit_test/static/quantity_spec_test.cpp +++ b/test/unit_test/static/quantity_spec_test.cpp @@ -21,10 +21,14 @@ // SOFTWARE. #include "test_tools.h" +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include +#endif namespace { diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 47ed833c..11721955 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -21,12 +21,17 @@ // SOFTWARE. #include "test_tools.h" +#include +#include +#ifdef MP_UNITS_MODULES +#include +import mp_units; +#else #include #include #include #include -#include -#include +#endif template<> inline constexpr bool mp_units::is_vector = true; diff --git a/test/unit_test/static/ratio_test.cpp b/test/unit_test/static/ratio_test.cpp index 5bf9bec0..fd2113bc 100644 --- a/test/unit_test/static/ratio_test.cpp +++ b/test/unit_test/static/ratio_test.cpp @@ -20,7 +20,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include +#endif namespace { diff --git a/test/unit_test/static/reference_test.cpp b/test/unit_test/static/reference_test.cpp index 3aac7e59..8da7fa48 100644 --- a/test/unit_test/static/reference_test.cpp +++ b/test/unit_test/static/reference_test.cpp @@ -21,6 +21,9 @@ // SOFTWARE. #include "test_tools.h" +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include @@ -28,6 +31,7 @@ #include #include #include +#endif namespace { diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 69d83096..8ce65935 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -20,8 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include +#endif namespace { diff --git a/test/unit_test/static/symbol_text_test.cpp b/test/unit_test/static/symbol_text_test.cpp index 1eb4700b..950c39e6 100644 --- a/test/unit_test/static/symbol_text_test.cpp +++ b/test/unit_test/static/symbol_text_test.cpp @@ -20,7 +20,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include +#endif using namespace mp_units; diff --git a/test/unit_test/static/test_tools.h b/test/unit_test/static/test_tools.h index 42cbc61e..bf6f77a5 100644 --- a/test/unit_test/static/test_tools.h +++ b/test/unit_test/static/test_tools.h @@ -22,8 +22,13 @@ #pragma once -#include #include +#ifdef MP_UNITS_MODULES +#include +import mp_units; +#else +#include +#endif template inline constexpr bool is_of_type = std::is_same_v, T>; diff --git a/test/unit_test/static/type_list_test.cpp b/test/unit_test/static/type_list_test.cpp index 6720ebbb..c3d61d52 100644 --- a/test/unit_test/static/type_list_test.cpp +++ b/test/unit_test/static/type_list_test.cpp @@ -20,8 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include +#endif namespace { diff --git a/test/unit_test/static/typographic_test.cpp b/test/unit_test/static/typographic_test.cpp index 9a47469c..71c713d1 100644 --- a/test/unit_test/static/typographic_test.cpp +++ b/test/unit_test/static/typographic_test.cpp @@ -20,9 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include +#endif namespace { diff --git a/test/unit_test/static/unit_symbol_test.cpp b/test/unit_test/static/unit_symbol_test.cpp index d5a41358..24fe56fa 100644 --- a/test/unit_test/static/unit_symbol_test.cpp +++ b/test/unit_test/static/unit_symbol_test.cpp @@ -20,9 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include +#endif namespace { diff --git a/test/unit_test/static/unit_test.cpp b/test/unit_test/static/unit_test.cpp index ca4ae1cc..d187467a 100644 --- a/test/unit_test/static/unit_test.cpp +++ b/test/unit_test/static/unit_test.cpp @@ -21,11 +21,15 @@ // SOFTWARE. #include "test_tools.h" +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include #include +#endif namespace { diff --git a/test/unit_test/static/usc_test.cpp b/test/unit_test/static/usc_test.cpp index c4e35e9e..42c29389 100644 --- a/test/unit_test/static/usc_test.cpp +++ b/test/unit_test/static/usc_test.cpp @@ -20,10 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include +#ifdef MP_UNITS_MODULES +import mp_units; +#else #include #include #include #include +#endif namespace {