mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 19:04:27 +02:00
test: test_package now use libfmt when needed
This commit is contained in:
@@ -27,3 +27,4 @@ find_package(mp-units CONFIG REQUIRED)
|
|||||||
|
|
||||||
add_executable(test_package test_package.cpp)
|
add_executable(test_package test_package.cpp)
|
||||||
target_link_libraries(test_package PRIVATE mp-units::mp-units)
|
target_link_libraries(test_package PRIVATE mp-units::mp-units)
|
||||||
|
target_compile_definitions(test_package PRIVATE MP_UNITS_USE_LIBFMT=$<BOOL:${MP_UNITS_USE_LIBFMT}>)
|
||||||
|
@@ -24,12 +24,20 @@ import os
|
|||||||
|
|
||||||
from conan import ConanFile
|
from conan import ConanFile
|
||||||
from conan.tools.build import can_run
|
from conan.tools.build import can_run
|
||||||
from conan.tools.cmake import CMake, cmake_layout
|
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||||
|
from conan.tools.scm import Version
|
||||||
|
|
||||||
|
|
||||||
class TestPackageConan(ConanFile):
|
class TestPackageConan(ConanFile):
|
||||||
settings = "os", "arch", "compiler", "build_type"
|
settings = "os", "arch", "compiler", "build_type"
|
||||||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
|
generators = "CMakeDeps"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _use_libfmt(self):
|
||||||
|
compiler = self.settings.compiler
|
||||||
|
version = Version(self.settings.compiler.version)
|
||||||
|
std_support = compiler == "msvc" and version >= 193 and compiler.cppstd == 23
|
||||||
|
return not std_support
|
||||||
|
|
||||||
def requirements(self):
|
def requirements(self):
|
||||||
self.requires(self.tested_reference_str)
|
self.requires(self.tested_reference_str)
|
||||||
@@ -37,6 +45,11 @@ class TestPackageConan(ConanFile):
|
|||||||
def layout(self):
|
def layout(self):
|
||||||
cmake_layout(self)
|
cmake_layout(self)
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
tc = CMakeToolchain(self)
|
||||||
|
tc.variables["MP_UNITS_USE_LIBFMT"] = self._use_libfmt
|
||||||
|
tc.generate()
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
cmake.configure()
|
cmake.configure()
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
|
#include <mp-units/format.h>
|
||||||
#include <mp-units/ostream.h>
|
#include <mp-units/ostream.h>
|
||||||
#include <mp-units/systems/isq/space_and_time.h>
|
#include <mp-units/systems/isq/space_and_time.h>
|
||||||
#include <mp-units/systems/si/unit_symbols.h>
|
#include <mp-units/systems/si/unit_symbols.h>
|
||||||
@@ -35,5 +36,5 @@ constexpr QuantityOf<isq::speed> auto avg_speed(QuantityOf<isq::distance> auto d
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
using namespace mp_units::si::unit_symbols;
|
using namespace mp_units::si::unit_symbols;
|
||||||
std::cout << "Average speed = " << avg_speed(240 * km, 2 * h) << '\n';
|
std::cout << MP_UNITS_STD_FMT::format("Average speed = {}\n", avg_speed(240 * km, 2 * h));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user