feat: proper exports implemented for C++ modules

This commit is contained in:
Mateusz Pusz
2024-02-23 21:09:17 +01:00
parent 6546878e5e
commit 5ca9168381
99 changed files with 439 additions and 304 deletions

View File

@@ -23,9 +23,6 @@
cmake_minimum_required(VERSION 3.5)
add_library(unit_tests_static_truncating quantity_test.cpp)
if(${projectPrefix}BUILD_CXX_MODULES)
target_compile_definitions(unit_tests_static_truncating PUBLIC ${projectPrefix}MODULES)
endif()
target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::mp-units)
target_compile_options(
unit_tests_static_truncating PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/wd4242 /wd4244,-Wno-conversion>
@@ -68,7 +65,4 @@ add_library(
)
target_link_libraries(unit_tests_static PRIVATE mp-units::mp-units)
if(${projectPrefix}BUILD_CXX_MODULES)
target_compile_definitions(unit_tests_static PUBLIC ${projectPrefix}MODULES)
endif()
target_link_libraries(unit_tests_static PRIVATE unit_tests_static_truncating)

View File

@@ -20,12 +20,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <numbers>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/systems/isq_angle/isq_angle.h>
#endif
#include <numbers>
namespace {

View File

@@ -21,14 +21,10 @@
// SOFTWARE.
#include "test_tools.h"
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/systems/cgs/cgs.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@@ -21,15 +21,10 @@
// SOFTWARE.
#include "test_tools.h"
#include <ratio>
#ifdef MP_UNITS_MODULES
#include <chrono>
import mp_units;
#else
#include <mp-units/bits/external/type_traits.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/si/si.h>
#endif
#include <ratio>
namespace {

View File

@@ -20,12 +20,8 @@
// 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 <mp-units/compare.h>
#include <mp-units/systems/si/si.h>
#endif
namespace {

View File

@@ -20,19 +20,15 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <chrono>
#include <complex>
#include <optional>
#include <string>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/concepts.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/natural/natural.h>
#include <mp-units/systems/si/si.h>
#endif
#include <chrono>
#include <complex>
#include <optional>
#include <string>
template<typename T>
inline constexpr bool mp_units::is_scalar<std::complex<T>> = true;

View File

@@ -21,13 +21,9 @@
// SOFTWARE.
#include <mp-units/bits/external/hacks.h>
#include <mp-units/systems/si/units.h>
#include <concepts>
#include <type_traits>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/systems/si/units.h>
#endif
namespace {

View File

@@ -21,15 +21,11 @@
// SOFTWARE.
#include "test_tools.h"
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/dimension.h>
#include <mp-units/quantity.h>
#include <mp-units/quantity_spec.h>
#include <mp-units/reference.h>
#include <mp-units/unit.h>
#endif
namespace {

View File

@@ -20,11 +20,7 @@
// 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 <mp-units/bits/external/fixed_string.h>
#endif
using namespace mp_units;

View File

@@ -21,13 +21,9 @@
// SOFTWARE.
#include <mp-units/compat_macros.h>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/math.h>
#include <mp-units/systems/isq/electromagnetism.h>
#include <mp-units/systems/si/units.h>
#endif
namespace {

View File

@@ -20,14 +20,10 @@
// 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 <mp-units/systems/hep/hep.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/si.h>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@@ -20,14 +20,10 @@
// 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 <mp-units/math.h>
#include <mp-units/systems/iau/iau.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/si.h>
#endif
/* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */

View File

@@ -20,14 +20,10 @@
// 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 <mp-units/quantity.h>
#include <mp-units/reference.h>
#include <mp-units/systems/iec80000/iec80000.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
/* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */

View File

@@ -20,13 +20,9 @@
// 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 <mp-units/systems/imperial/imperial.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
namespace {

View File

@@ -20,16 +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 <mp-units/math.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/constants.h>
#include <mp-units/systems/si/units.h>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@@ -20,12 +20,8 @@
// 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 <mp-units/systems/isq_angle/isq_angle.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
namespace {

View File

@@ -20,13 +20,9 @@
// 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 <mp-units/reference.h>
#include <mp-units/systems/isq/isq.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
namespace {

View File

@@ -21,14 +21,10 @@
// SOFTWARE.
#include <optional>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/math.h> // IWYU pragma: keep
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
namespace {

View File

@@ -20,12 +20,8 @@
// 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 <mp-units/math.h>
#include <mp-units/systems/natural/natural.h>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@@ -20,13 +20,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/external/prime.h>
#include <type_traits>
#include <utility>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/bits/external/prime.h>
#endif
using namespace mp_units::detail;

View File

@@ -24,15 +24,10 @@
#include <limits>
#include <type_traits>
#include <utility>
#ifdef MP_UNITS_MODULES
#include <chrono>
import mp_units;
#else
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/isq.h>
#include <mp-units/systems/si/si.h>
#include <mp-units/systems/usc/usc.h>
#endif
namespace {

View File

@@ -21,14 +21,10 @@
// SOFTWARE.
#include "test_tools.h"
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/quantity.h>
#include <mp-units/quantity_spec.h>
#include <mp-units/reference.h>
#include <mp-units/unit.h>
#endif
namespace {

View File

@@ -20,19 +20,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/external/hacks.h>
//
#include "test_tools.h"
#include <limits>
#include <utility>
#ifdef MP_UNITS_MODULES
#include <chrono>
import mp_units;
#else
#include <mp-units/bits/external/hacks.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/si.h>
#endif
#include <limits>
#include <utility>
template<>
inline constexpr bool mp_units::is_vector<int> = true;

View File

@@ -20,11 +20,7 @@
// 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 <mp-units/bits/ratio.h>
#endif
namespace {

View File

@@ -21,9 +21,6 @@
// SOFTWARE.
#include "test_tools.h"
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/dimension.h>
#include <mp-units/quantity.h>
#include <mp-units/quantity_spec.h>
@@ -31,7 +28,6 @@ import mp_units;
#include <mp-units/system_reference.h>
#include <mp-units/systems/si/prefixes.h>
#include <mp-units/unit.h>
#endif
namespace {

View File

@@ -21,12 +21,8 @@
// SOFTWARE.
#include <type_traits>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/math.h>
#include <mp-units/systems/si/si.h>
#endif
namespace {

View File

@@ -20,11 +20,7 @@
// 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 <mp-units/bits/symbol_text.h>
#endif
using namespace mp_units;

View File

@@ -23,12 +23,7 @@
#pragma once
#include <type_traits>
#ifdef MP_UNITS_MODULES
#include <mp-units/compat_macros.h>
import mp_units;
#else
#include <mp-units/quantity_spec.h>
#endif
template<auto V, typename T>
inline constexpr bool is_of_type = std::is_same_v<std::remove_cvref_t<decltype(V)>, T>;

View File

@@ -20,13 +20,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <type_traits>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/bits/external/type_list.h>
#include <mp-units/bits/external/type_traits.h>
#endif
#include <type_traits>
namespace {

View File

@@ -20,13 +20,9 @@
// 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 <mp-units/systems/international/international.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/typographic/typographic.h>
#endif
namespace {

View File

@@ -20,13 +20,9 @@
// 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 <mp-units/systems/iau/iau.h>
#include <mp-units/systems/iec80000/iec80000.h>
#include <mp-units/systems/si/si.h>
#endif
namespace {

View File

@@ -21,15 +21,11 @@
// SOFTWARE.
#include "test_tools.h"
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/dimension.h>
#include <mp-units/quantity.h>
#include <mp-units/reference.h>
#include <mp-units/systems/si/prefixes.h>
#include <mp-units/unit.h>
#endif
namespace {

View File

@@ -21,14 +21,10 @@
// SOFTWARE.
#include <mp-units/bits/external/hacks.h>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/usc/usc.h>
#endif
namespace {