Skip to content

Commit

Permalink
refactor: split into module mp_units.core
Browse files Browse the repository at this point in the history
  • Loading branch information
JohelEGP committed Mar 6, 2023
1 parent 5a4155d commit 2237b11
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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::)
Expand Down
3 changes: 3 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
59 changes: 59 additions & 0 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
@@ -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 <gsl/gsl-lite.hpp>
#include <cassert>

export module mp_units.core;

export import std;

#define UNITS_MODULE

export
{
#include <units/base_dimension.h>
#include <units/bits/unit_text.h>
#include <units/customization_points.h>
#include <units/derived_dimension.h>
#include <units/exponent.h>
#include <units/generic/angle.h>
#include <units/generic/dimensionless.h>
#include <units/generic/solid_angle.h>
#include <units/kind.h>
#include <units/magnitude.h>
#include <units/math.h>
#include <units/point_origin.h>
#include <units/prefix.h>
#include <units/quantity.h>
#include <units/quantity_cast.h>
#include <units/quantity_kind.h>
#include <units/quantity_point.h>
#include <units/quantity_point_kind.h>
#include <units/random.h>
#include <units/ratio.h>
#include <units/reference.h>
#include <units/symbol_text.h>
#include <units/unit.h>
}
File renamed without changes.
26 changes: 1 addition & 25 deletions src/mp_units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,15 @@
module;

#include <gsl/gsl-lite.hpp>
#include <cassert>

export module mp_units;

export import std;
export import mp_units.core;

#define UNITS_MODULE

export
{
// core
#include <units/base_dimension.h>
#include <units/bits/unit_text.h>
#include <units/customization_points.h>
#include <units/derived_dimension.h>
#include <units/exponent.h>
#include <units/generic/dimensionless.h>
#include <units/kind.h>
#include <units/magnitude.h>
#include <units/math.h>
#include <units/point_origin.h>
#include <units/prefix.h>
#include <units/quantity.h>
#include <units/quantity_cast.h>
#include <units/quantity_kind.h>
#include <units/quantity_point.h>
#include <units/quantity_point_kind.h>
#include <units/random.h>
#include <units/ratio.h>
#include <units/reference.h>
#include <units/symbol_text.h>
#include <units/unit.h>

// systems
#include <units/isq/dimensions.h>
#include <units/isq/iec80000/iec80000.h>
Expand Down
1 change: 0 additions & 1 deletion src/systems/si/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/angle_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// SOFTWARE.

#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/generic/angle.h>
#include <units/generic/solid_angle.h>
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/dimension_op_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <units/bits/config/macros.h>
#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/base_dimension.h>
#include <units/bits/dim_unpack.h>
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/fixed_string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// SOFTWARE.

#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/bits/external/fixed_string.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/prime_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// SOFTWARE.

#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/bits/prime.h>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/ratio_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// SOFTWARE.

#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/ratio.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/symbol_text_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// SOFTWARE.

#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/symbol_text.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/test_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <cassert>
#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/bits/equivalent.h>
#include <concepts>
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/type_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// SOFTWARE.

#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/base_dimension.h>
#include <units/bits/external/type_list.h>
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/static/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "test_tools.h"
#ifdef UNITS_MODULE
import mp_units;
import mp_units.core;
#else
#include <units/base_dimension.h>
#include <units/bits/equivalent.h>
Expand Down

0 comments on commit 2237b11

Please sign in to comment.