From 2237b11a2544284da9e04dc5a1657d93acf4f78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 6 Mar 2023 12:16:07 -0400 Subject: [PATCH] refactor: split into module mp_units.core --- src/CMakeLists.txt | 2 +- src/core/CMakeLists.txt | 3 + src/core/core.cpp | 59 +++++++++++++++++++ .../include/units/isq/si/prefixes.h | 0 src/mp_units.cpp | 26 +------- src/systems/si/CMakeLists.txt | 1 - test/unit_test/static/angle_test.cpp | 2 +- test/unit_test/static/dimension_op_test.cpp | 2 +- test/unit_test/static/fixed_string_test.cpp | 2 +- test/unit_test/static/prime_test.cpp | 2 +- test/unit_test/static/ratio_test.cpp | 2 +- test/unit_test/static/symbol_text_test.cpp | 2 +- test/unit_test/static/test_tools.h | 2 +- test/unit_test/static/type_list_test.cpp | 2 +- test/unit_test/static/unit_test.cpp | 2 +- 15 files changed, 73 insertions(+), 36 deletions(-) create mode 100644 src/core/core.cpp rename src/{systems/si => core}/include/units/isq/si/prefixes.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5631083cf..d512b28dd5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,7 +51,7 @@ add_library(mp-units::mp-units ALIAS mp-units) install(TARGETS mp-units EXPORT mp-unitsTargets) # C++ module -add_units_cxx_module(module SOURCES "mp_units.cpp" LINK_LIBRARIES PUBLIC mp-units::mp-units) +add_units_cxx_module(module SOURCES "mp_units.cpp" LINK_LIBRARIES PUBLIC "mp-units::mp-units;mp-units::core-module") # local build export(EXPORT mp-unitsTargets NAMESPACE mp-units::) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 56f462af06..f761daff74 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -46,6 +46,7 @@ add_library( include/units/generic/angle.h include/units/generic/dimensionless.h include/units/generic/solid_angle.h + include/units/isq/si/prefixes.h include/units/kind.h include/units/magnitude.h include/units/math.h @@ -98,6 +99,8 @@ endif() set_target_properties(mp-units-core PROPERTIES EXPORT_NAME core) add_library(mp-units::core ALIAS mp-units-core) +add_units_cxx_module(core-module SOURCES "core.cpp" LINK_LIBRARIES PUBLIC mp-units::core) + # installation install(TARGETS mp-units-core EXPORT mp-unitsTargets) install(DIRECTORY include/units TYPE INCLUDE) diff --git a/src/core/core.cpp b/src/core/core.cpp new file mode 100644 index 0000000000..02a5a92069 --- /dev/null +++ b/src/core/core.cpp @@ -0,0 +1,59 @@ +// 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. + +module; + +#include +#include + +export module mp_units.core; + +export import std; + +#define UNITS_MODULE + +export +{ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +} diff --git a/src/systems/si/include/units/isq/si/prefixes.h b/src/core/include/units/isq/si/prefixes.h similarity index 100% rename from src/systems/si/include/units/isq/si/prefixes.h rename to src/core/include/units/isq/si/prefixes.h diff --git a/src/mp_units.cpp b/src/mp_units.cpp index cb72ea5a6c..27e9730b7b 100644 --- a/src/mp_units.cpp +++ b/src/mp_units.cpp @@ -23,39 +23,15 @@ module; #include -#include export module mp_units; -export import std; +export import mp_units.core; #define UNITS_MODULE export { -// core -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - // systems #include #include diff --git a/src/systems/si/CMakeLists.txt b/src/systems/si/CMakeLists.txt index f4a59f9651..d7ce364bb4 100644 --- a/src/systems/si/CMakeLists.txt +++ b/src/systems/si/CMakeLists.txt @@ -61,7 +61,6 @@ add_units_module( include/units/isq/si/permeability.h include/units/isq/si/permittivity.h include/units/isq/si/power.h - include/units/isq/si/prefixes.h include/units/isq/si/pressure.h include/units/isq/si/radioactivity.h include/units/isq/si/resistance.h diff --git a/test/unit_test/static/angle_test.cpp b/test/unit_test/static/angle_test.cpp index 47292c2a5b..de2722e87f 100644 --- a/test/unit_test/static/angle_test.cpp +++ b/test/unit_test/static/angle_test.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #include diff --git a/test/unit_test/static/dimension_op_test.cpp b/test/unit_test/static/dimension_op_test.cpp index 8b13b16843..b3c9675a0e 100644 --- a/test/unit_test/static/dimension_op_test.cpp +++ b/test/unit_test/static/dimension_op_test.cpp @@ -22,7 +22,7 @@ #include #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #include diff --git a/test/unit_test/static/fixed_string_test.cpp b/test/unit_test/static/fixed_string_test.cpp index d21b99325a..45f924f995 100644 --- a/test/unit_test/static/fixed_string_test.cpp +++ b/test/unit_test/static/fixed_string_test.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #endif diff --git a/test/unit_test/static/prime_test.cpp b/test/unit_test/static/prime_test.cpp index bc4fcf2fa9..4234c9e559 100644 --- a/test/unit_test/static/prime_test.cpp +++ b/test/unit_test/static/prime_test.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #include diff --git a/test/unit_test/static/ratio_test.cpp b/test/unit_test/static/ratio_test.cpp index de9be7e330..84cd508de5 100644 --- a/test/unit_test/static/ratio_test.cpp +++ b/test/unit_test/static/ratio_test.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #endif diff --git a/test/unit_test/static/symbol_text_test.cpp b/test/unit_test/static/symbol_text_test.cpp index 8d22256e45..b683324ff3 100644 --- a/test/unit_test/static/symbol_text_test.cpp +++ b/test/unit_test/static/symbol_text_test.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #endif diff --git a/test/unit_test/static/test_tools.h b/test/unit_test/static/test_tools.h index 17a0cf300d..fdd910ac49 100644 --- a/test/unit_test/static/test_tools.h +++ b/test/unit_test/static/test_tools.h @@ -24,7 +24,7 @@ #include #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #include diff --git a/test/unit_test/static/type_list_test.cpp b/test/unit_test/static/type_list_test.cpp index b047fde87f..1208df9eb3 100644 --- a/test/unit_test/static/type_list_test.cpp +++ b/test/unit_test/static/type_list_test.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #include diff --git a/test/unit_test/static/unit_test.cpp b/test/unit_test/static/unit_test.cpp index 5d6986f785..df719d2b22 100644 --- a/test/unit_test/static/unit_test.cpp +++ b/test/unit_test/static/unit_test.cpp @@ -22,7 +22,7 @@ #include "test_tools.h" #ifdef UNITS_MODULE -import mp_units; +import mp_units.core; #else #include #include