mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
docs: conanfile.py examples added to the installation chapter
This commit is contained in:
@ -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.
|
project's top-level directory and add **mp-units** as a dependency of your project.
|
||||||
For example, the simplest file may look as follows:
|
For example, the simplest file may look as follows:
|
||||||
|
|
||||||
```ini title="conanfile.txt"
|
=== "_conanfile.txt_"
|
||||||
[requires]
|
|
||||||
mp-units/2.4.0
|
|
||||||
|
|
||||||
[options]
|
```ini
|
||||||
# The below mp-units options are automatically deduced based on the current system's settings.
|
[requires]
|
||||||
# Uncomment and set to an explicit value to override the auto-deduction.
|
mp-units/2.4.0
|
||||||
#
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[layout]
|
[options]
|
||||||
cmake_layout
|
# 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]
|
[layout]
|
||||||
CMakeToolchain
|
cmake_layout
|
||||||
CMakeDeps
|
|
||||||
```
|
[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`:
|
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:
|
4. Download, build, and install Conan dependencies before running the CMake configuration step:
|
||||||
|
|
||||||
```shell
|
=== "_conanfile.txt_ or _conanfile.py_"
|
||||||
conan install . -pr <your_conan_profile> -s compiler.cppstd=20 -b=missing
|
|
||||||
cmake --preset conan-default
|
```shell
|
||||||
cmake --build --preset conan-release
|
conan install . -pr <your_conan_profile> -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 <your_conan_profile> -s compiler.cppstd=20 -b=missing
|
||||||
|
```
|
||||||
|
|
||||||
### Conan + CMake (Live At Head)
|
### 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:
|
2. In your Conan configuration file, provide the package identifier of the `mpusz/testing` stream:
|
||||||
|
|
||||||
```ini title="conanfile.txt" hl_lines="2"
|
=== "_conanfile.txt_"
|
||||||
[requires]
|
|
||||||
mp-units/2.5.0@mpusz/testing
|
|
||||||
|
|
||||||
[options]
|
```ini hl_lines="2"
|
||||||
# The below mp-units options are automatically deduced based on the current system's settings.
|
[requires]
|
||||||
# Uncomment and set to an explicit value to override the auto-deduction.
|
mp-units/2.5.0@mpusz/testing
|
||||||
#
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[layout]
|
[options]
|
||||||
cmake_layout
|
# 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]
|
[layout]
|
||||||
CMakeToolchain
|
cmake_layout
|
||||||
CMakeDeps
|
|
||||||
```
|
[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
|
!!! tip
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user