From ce7eb8b2b296d8e5b6b9ec0f40634857ab49d715 Mon Sep 17 00:00:00 2001 From: Juan Jose Casafranca Date: Mon, 2 Sep 2024 08:22:20 +0000 Subject: [PATCH 1/3] Add compilation instructions in README.md --- README.md | 91 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 01314f3b..28d5bb27 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,86 @@ # Mandos General purpose simulator for c++ and python. -## Build +## External dependencies -This project is built using `CMake` and should work on Windows and Linux. To build the project one needs to have `git`. `cmake`, and a c++ compiler installed. To clone the repository and build it run the following commands: -```sh -git clone --recursive https://github.com/MagiRomanya/Mandos.git -cd Mandos -mkdir build -cd build -cmake .. -cmake --build . +Mandos uses Conan 2 to manage its external dependencies. If you dont have Conan 2, you can install it using `pip install conan` + +Each set of dependencies can be used for several mandos compilations, but the build type of Mandos must be specified when fetching the dependencies (this is a limitation of CMake) + + +``` +conan install . --profile:build conan/profiles/x86_64-gcc-13 --settings:build "&:build_type=Release" --profile:host conan/profiles/x86_64-gcc-13 --settings:host "&:build_type=Release" --settings:host "*:build_type=Release" --build=missing +``` + +Lets break that line: +* `conan install .`: execute conan install with a conanfile in . +* `--profile:build conan/profiles/x86_64-gcc-13`: Profile used for the build machine. It provides information on the machine that runs the compilation process +* `--settings:build "build_type=Release"`: The build tools will be compiled in Release mode +* `--profile:host conan/profiles/x86_64-gcc-13`: Profile used for the host machine. It provides information on the machine that will run Mandos. +* `--settings:host "&:build_type=Release"`: Specifies the build type of our project (`&`) +* `--settings:host "*:build_type=Release"`: Specifies the build type of our dependencies (`*`) +* `--build=missing`: Compile all missing dependencies + +When running the above command, Conan will fetch the dependencies and compile them using the specified profiles and build types and generate files for configuring Mandos with CMake. You can inspect those files inside the `build///generators` directory. + +We provide several Conan profiles +* `x86_64-clang-17` +* `x86_64-clang-18` +* `x86-64-gcc-11` +* `x86_64-gcc-13` + +## Compiling Mandos + +We use CMake for configuring and managing Mandos build and we provide several CMakePresets to ease configuration. + +Once the external dependencies are compiled, you can configure the Mandos project using + +``` +cmake -S . --preset +``` +from the source directory + +We provide several presets + +* `dev-release`: General purpose preset which compiles Mandos in release mode using clang-17 +* `dev-debug`: General purpose preset which compiles Mandos in debug mode using clang-17 + +Take into account that these presets doesn't enable the checks that are used in the CI, so even if the project compiles fine with these presets, the build may fail in the CI. + +You can check the complete list in CMakePresets.json and you can create your own presets in CMakeUserPresets.json + +Once the project is configured using a preset, you can build the project using + +``` +cmake --build --preset +``` +from the source directory + +## Examples + +Mandos provides a high level Python API to simplify the creation of demos and examples. The Python API is compiled by default when using `dev-release` or `dev-debug` presets (check what other presets are doing if needed). + +You can find different examples in the `examples/python` directory. +To run any of them, you need several python dependencies such as meshio or polyscope. You can install them using + +``` +pip install meshio polyscope ``` -## Project architecture -![](./resources/mandos.svg "A simplified high level overview of the Mandos simulator and how it is structured.") +If you prefer, you can also use a Python venv. + +To execute the examples, first, you need the specify to Python where to find Mandos bindings by setting the PYTHONPATH environment variable + +``` +export PYTHONPATH=/lib +``` + +for example, for the `dev-release` preset + +``` +export PYTHONPATH=/build/dev-release/lib +``` + +Note that if you frequently change between presets (for example, from `dev-release` to `dev-debug`), you need to update the PYTHONPATH variable to match the last build. + + -- GitLab From 3d2409fc0c452452679f887cbc2812cd2fdb65d1 Mon Sep 17 00:00:00 2001 From: Juan Jose Casafranca Date: Mon, 29 Jul 2024 14:30:59 +0000 Subject: [PATCH 2/3] Add no-undefined preset --- presets/common.json | 10 ++++++++++ presets/dev.json | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/presets/common.json b/presets/common.json index 3dda609e..b05a8849 100644 --- a/presets/common.json +++ b/presets/common.json @@ -171,6 +171,16 @@ "value": "ON" } } + }, + { + "name": ".no-undefined", + "hidden": true, + "cacheVariables": { + "ENABLE_NO_UNDEFINED": { + "type": "BOOL", + "value": "ON" + } + } } ], "testPresets": [ diff --git a/presets/dev.json b/presets/dev.json index 752f2401..de0bce34 100644 --- a/presets/dev.json +++ b/presets/dev.json @@ -33,7 +33,8 @@ ".x86_64-clang-17", ".dev-base", ".examples", - ".bindings" + ".bindings", + ".no-undefined" ] } ], -- GitLab From 6c9622d3b91d771edce19c257886e5414d12369d Mon Sep 17 00:00:00 2001 From: Juan Jose Casafranca Date: Mon, 2 Sep 2024 09:08:43 +0000 Subject: [PATCH 3/3] fixup! Add compilation instructions in README.md --- README.md | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 28d5bb27..ebd24268 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,20 @@ # Mandos General purpose simulator for c++ and python. +## Tools +Mandos uses standard tools for configuration and compilation. + +| Tool | Version | OS | Description | +|---|---|---|---| +| Conan | 2.0 or above | Linux / Windows | Fetch dependencies | +| CMake | 3.27 or above | Linux / Windows | Configure project | +| clang* | 17 or above | Linux | Compiler | +| gcc* | 11 or above | Linux | Compiler | +| MSVC | 194 or above | Windows | Compiler | + + +> \* Only gcc or clang is needed, although you can have both and compile with both to ensure compatibility + ## External dependencies Mandos uses Conan 2 to manage its external dependencies. If you dont have Conan 2, you can install it using `pip install conan` @@ -9,14 +23,14 @@ Each set of dependencies can be used for several mandos compilations, but the bu ``` -conan install . --profile:build conan/profiles/x86_64-gcc-13 --settings:build "&:build_type=Release" --profile:host conan/profiles/x86_64-gcc-13 --settings:host "&:build_type=Release" --settings:host "*:build_type=Release" --build=missing +conan install . --profile:build conan/profiles/x86_64-clang-17 --settings:build "&:build_type=Release" --profile:host conan/profiles/x86_64-clang-17 --settings:host "&:build_type=Release" --settings:host "*:build_type=Release" --build=missing ``` Lets break that line: * `conan install .`: execute conan install with a conanfile in . -* `--profile:build conan/profiles/x86_64-gcc-13`: Profile used for the build machine. It provides information on the machine that runs the compilation process +* `--profile:build conan/profiles/x86_64-clang-17`: Profile used for the build machine. It provides information on the machine that runs the compilation process * `--settings:build "build_type=Release"`: The build tools will be compiled in Release mode -* `--profile:host conan/profiles/x86_64-gcc-13`: Profile used for the host machine. It provides information on the machine that will run Mandos. +* `--profile:host conan/profiles/x86_64-clang-17`: Profile used for the host machine. It provides information on the machine that will run Mandos. * `--settings:host "&:build_type=Release"`: Specifies the build type of our project (`&`) * `--settings:host "*:build_type=Release"`: Specifies the build type of our dependencies (`*`) * `--build=missing`: Compile all missing dependencies @@ -28,6 +42,7 @@ We provide several Conan profiles * `x86_64-clang-18` * `x86-64-gcc-11` * `x86_64-gcc-13` +* `x86_64-msvc-194` ## Compiling Mandos @@ -36,25 +51,36 @@ We use CMake for configuring and managing Mandos build and we provide several CM Once the external dependencies are compiled, you can configure the Mandos project using ``` -cmake -S . --preset +cmake -S . --preset ``` -from the source directory +from the source directory. -We provide several presets +We provide several configuration presets -* `dev-release`: General purpose preset which compiles Mandos in release mode using clang-17 -* `dev-debug`: General purpose preset which compiles Mandos in debug mode using clang-17 +* `dev-release`: General purpose preset which compiles Mandos in Release mode using clang-17 +* `dev-debug`: General purpose preset which compiles Mandos in Debug mode using clang-17 +* `x86_64-msvc-194`: General purpose preset for MSVC 194 Take into account that these presets doesn't enable the checks that are used in the CI, so even if the project compiles fine with these presets, the build may fail in the CI. -You can check the complete list in CMakePresets.json and you can create your own presets in CMakeUserPresets.json +You can check the complete list in CMakePresets.json. +We recommend your create your own presets in CMakeUserPresets.json as you need. + +Different presets may look for different set of dependencies. Architecture, compiler and build type must match between the Conan profile and the CMake preset. Check ` .x86_64-clang-17`, `.debug` and related base presets in `presets/common.json`. -Once the project is configured using a preset, you can build the project using +Once the project is configured using a preset, you can build the project using a build preset ``` -cmake --build --preset +cmake --build --preset ``` -from the source directory + +from the source directory. + + +> On Linux (technically, when using a single config generator like Ninja), the build type is a property of the configuration preset. On Windows (technically, when using a multi config generator like MSVC), the build type is defined in the build preset. Check the default presets in presets/dev.json to check what each preset is doing. + + +>Mandos developer usually work on Linux systems and Windows builds might not be as tested as Linux builds. Please, open a ticket if you find an issue. ## Examples -- GitLab