diff --git a/docs/getting_started/installation_and_usage.md b/docs/getting_started/installation_and_usage.md index 6a7577df..d06123a1 100644 --- a/docs/getting_started/installation_and_usage.md +++ b/docs/getting_started/installation_and_usage.md @@ -239,28 +239,68 @@ The following steps may be performed to obtain an official library release: project's top-level directory and add **mp-units** as a dependency of your project. For example, the simplest file may look as follows: - ```ini title="conanfile.txt" - [requires] - mp-units/2.4.0 + === "_conanfile.txt_" - [options] - # The below mp-units options are automatically deduced based on the current system's settings. - # Uncomment and set to an explicit value to override the auto-deduction. - # - # mp-units*:cxx_modules=True - # mp-units*:import_std=False - # mp-units*:std_format=True - # mp-units*:no_crtp=True - # mp-units*:contracts=gsl-lite - # mp-units*:freestanding=False + ```ini + [requires] + mp-units/2.4.0 - [layout] - cmake_layout + [options] + # The below mp-units options are automatically deduced based on the current settings. + # Uncomment and set to an explicit value to override the auto-deduction. + # + # mp-units*:cxx_modules=True + # mp-units*:import_std=False + # mp-units*:std_format=True + # mp-units*:no_crtp=True + # mp-units*:contracts=gsl-lite + # mp-units*:freestanding=False - [generators] - CMakeToolchain - CMakeDeps - ``` + [layout] + cmake_layout + + [generators] + CMakeToolchain + CMakeDeps + ``` + + === "_conanfile.py_" + + ```python + from conan import ConanFile + from conan.tools.build import can_run + from conan.tools.cmake import CMake, cmake_layout + + class MPUnitsTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires( + "mp-units/2.4.0", + options={ + # The below mp-units options are automatically deduced based on the current settings. + # Uncomment and set to an explicit value to override the auto-deduction. + # + # "cxx_modules": False, + # "import_std": False, + # "std_format": True, + # "no_crtp": True, + # "contracts": "gsl-lite", + # "freestanding": False, + }, + ) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + if can_run(self): + cmake.ctest(cli_args=["--output-on-failure"]) + ``` 2. Import **mp-units** and its dependencies definitions with `find_package`: @@ -276,11 +316,20 @@ The following steps may be performed to obtain an official library release: 4. Download, build, and install Conan dependencies before running the CMake configuration step: - ```shell - conan install . -pr -s compiler.cppstd=20 -b=missing - cmake --preset conan-default - cmake --build --preset conan-release - ``` + === "_conanfile.txt_ or _conanfile.py_" + + ```shell + conan install . -pr -s compiler.cppstd=20 -b=missing + cmake --preset conan-default + cmake --build --preset conan-release + cmake --build --preset conan-release --target test + ``` + + === "_conanfile.py_ only" + + ```shell + conan build . -pr -s compiler.cppstd=20 -b=missing + ``` ### Conan + CMake (Live At Head) @@ -306,28 +355,68 @@ with the following differences: 2. In your Conan configuration file, provide the package identifier of the `mpusz/testing` stream: - ```ini title="conanfile.txt" hl_lines="2" - [requires] - mp-units/2.5.0@mpusz/testing + === "_conanfile.txt_" - [options] - # The below mp-units options are automatically deduced based on the current system's settings. - # Uncomment and set to an explicit value to override the auto-deduction. - # - # mp-units*:cxx_modules=True - # mp-units*:import_std=False - # mp-units*:std_format=True - # mp-units*:no_crtp=True - # mp-units*:contracts=gsl-lite - # mp-units*:freestanding=False + ```ini hl_lines="2" + [requires] + mp-units/2.5.0@mpusz/testing - [layout] - cmake_layout + [options] + # The below mp-units options are automatically deduced based on the current settings. + # Uncomment and set to an explicit value to override the auto-deduction. + # + # mp-units*:cxx_modules=True + # mp-units*:import_std=False + # mp-units*:std_format=True + # mp-units*:no_crtp=True + # mp-units*:contracts=gsl-lite + # mp-units*:freestanding=False - [generators] - CMakeToolchain - CMakeDeps - ``` + [layout] + cmake_layout + + [generators] + CMakeToolchain + CMakeDeps + ``` + + === "_conanfile.py_" + + ```python hl_lines="11" + from conan import ConanFile + from conan.tools.build import can_run + from conan.tools.cmake import CMake, cmake_layout + + class MPUnitsTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires( + "mp-units/2.5.0@mpusz/testing", + options={ + # The below mp-units options are automatically deduced based on the current settings. + # Uncomment and set to an explicit value to override the auto-deduction. + # + # "cxx_modules": False, + # "import_std": False, + # "std_format": True, + # "no_crtp": True, + # "contracts": "gsl-lite", + # "freestanding": False, + }, + ) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + if can_run(self): + cmake.ctest(cli_args=["--output-on-failure"]) + ``` !!! tip