-
Notifications
You must be signed in to change notification settings - Fork 25
Conan v2 + OS SDK 3.8.0-rc2 #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
905cc85
926c050
9d7a896
71ece1e
fc81d7a
f8acd6b
036b0f6
b482f2b
2f6d046
d393559
94960f9
bbd89b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,3 +41,4 @@ cppcheck.txt* | |
| clang_format.patch | ||
| conan-cache | ||
| .ccache | ||
| CMakeUserPresets.json | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| # Building with conan v2 | ||
|
|
||
| Check you have `conan >= 2`, and add the `nrel-v2` remote to grab `ruby` and `swig/4.1.1`. | ||
|
|
||
| ```shell | ||
| conan --version | ||
| conan remote add -f nrel-v2 http://conan.openstudio.net/artifactory/api/conan/conan-v2 | ||
| ``` | ||
|
|
||
| ## Install the conan dependencies into a build folder | ||
|
|
||
| ```shell | ||
| conan install . --output-folder=../OSApp-build-release --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release | ||
| ``` | ||
|
Comment on lines
+12
to
+14
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step 2, at root of repo, with conan2 |
||
|
|
||
| You can also do another configuration, such as `Debug`, `RelWithDeb`, etc | ||
|
|
||
| ```shell | ||
| conan install . --output-folder=../OSApp-build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Debug | ||
| ``` | ||
|
|
||
| You'll have the `conan-release` and `conan-debug` CMake Presets in the root folder. Do `cmake --list-presets` to list the available presets (which are in `CMakeUserPresets.json`) | ||
|
|
||
| *Side note:* If you want a specific configure option (such as a build folder in Release mode where you build with `-DBUILD_CSHARP_BINDINGS:BOOL=ON`) in a different build dir for the same source dir, you probably will need to go and edit the `<build_dir>/CMakePresets.json` to rename it to another configuration name so it does not clash with the preset `conan-release` | ||
|
|
||
| ## CMake Configure and build | ||
|
|
||
| ### With presets | ||
|
|
||
| #### Why are Presets recommended | ||
|
|
||
| The recommend flow is to use [CMake Presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html). | ||
|
|
||
| If you notice the messages printed to the console when you run the `conan install` command from above, | ||
| you'll see that the `conanfile` actually defines common build variables for you already, | ||
| such as defining which `CPack` Generators to use depending on your target platform, trying to infer the `Python_ROOT_DIR` etc | ||
|
|
||
| <pre><font color="#75507B"><b>conanfile.py:</b></font> <font color="#75507B"><b>Calling generate()</b></font> | ||
| conanfile.py: Generators folder: /path/to/OSApp-build-release | ||
| conanfile.py: Setting PYTHON_VERSION and Python_ROOT_DIR from your current python: 3.8.13, '/home/julien/.pyenv/versions/3.8.13' | ||
| conanfile.py: CMakeToolchain generated: conan_toolchain.cmake | ||
| conanfile.py: Preset 'conan-release' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-release' if using CMake>=3.23 | ||
| conanfile.py: If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: | ||
| cmake <path> -G Ninja -DCMAKE_TOOLCHAIN_FILE=/path/to/OSApp-build-release/conan_toolchain.cmake \ | ||
| -DBUILD_CLI=ON -DBUILD_RUBY_BINDINGS=ON -DBUILD_PYTHON_BINDINGS=ON \ | ||
| -DBUILD_PYTHON_PIP_PACKAGE=OFF -DBUILD_TESTING=ON -DBUILD_BENCHMARK=ON \ | ||
| -DCPACK_BINARY_TGZ=ON -DCPACK_BINARY_IFW=OFF -DCPACK_BINARY_DEB=ON -DCPACK_BINARY_NSIS=OFF \ | ||
| -DCPACK_BINARY_RPM=OFF -DCPACK_BINARY_STGZ=OFF -DCPACK_BINARY_TBZ2=OFF \ | ||
| -DCPACK_BINARY_TXZ=OFF -DCPACK_BINARY_TZ=OFF \ | ||
| -DPYTHON_VERSION=3.8.13 -DPython_ROOT_DIR=/home/julien/.pyenv/versions/3.8.13 \ | ||
| -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release | ||
| conanfile.py: CMakeToolchain generated: CMakePresets.json | ||
| conanfile.py: CMakeToolchain generated: ../OpenStudio/CMakeUserPresets.json | ||
| <font color="#75507B"><b>conanfile.py:</b></font> <font color="#75507B"><b>Generating aggregated env files</b></font> | ||
| conanfile.py: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] | ||
| <font color="#4E9A06"><b>Install finished successfully</b></font> | ||
| </pre> | ||
|
|
||
| **Note that this is also supported by Visual Studio (MSVC)**. | ||
|
|
||
| #### Configure and build with Presets | ||
|
|
||
| Run these commands from the **source** directory (`OpenStudio/`). | ||
|
|
||
| ```shell | ||
| cmake --preset conan-release [any_futher_configuration_options] | ||
| ``` | ||
|
|
||
| Example: | ||
|
|
||
| ``` | ||
| cmake --preset conan-release \ | ||
| -DQT_INSTALL_DIR:PATH=/opt/Qt/6.6.3/gcc_64 \ | ||
| -DBUILD_PACKAGE:BOOL=ON | ||
| ``` | ||
|
Comment on lines
+71
to
+75
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step 3, at root still |
||
|
|
||
| Building | ||
|
|
||
| ``` | ||
| cmake --build --preset conan-release | ||
| ``` | ||
|
Comment on lines
+77
to
+81
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step 4, at root still. |
||
|
|
||
| ### Atlernatively: manual CMake | ||
|
|
||
| First, go to the **build** directory, and **activate the conan build environment**. | ||
|
|
||
| ```shell | ||
| cd ../OSApp-build-release | ||
| # Unix | ||
| . ./conanbuild.sh | ||
| # Windows | ||
| call conanbuild.bat | ||
| ``` | ||
|
|
||
| Still in the build directory, run cmake, but do pass the `CMAKE_TOOLCHAIN_FILE` | ||
|
|
||
| ``` | ||
| cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE:STRING=Release \ | ||
| -DQT_INSTALL_DIR:PATH=/opt/Qt/6.6.3/gcc_64 \ | ||
| -DBUILD_TESTING:BOOL=ON -DCPACK_BINARY_TGZ:BOOL=ON -DCPACK_BINARY_DEB:BOOL=ON \ | ||
| -DCPACK_BINARY_IFW:BOOL=OFF -DCPACK_BINARY_NSIS:BOOL=OFF -DCPACK_BINARY_RPM:BOOL=OFF -DCPACK_BINARY_STGZ:BOOL=OFF \ | ||
| -DCPACK_BINARY_TBZ2:BOOL=OFF -DCPACK_BINARY_TXZ:BOOL=OFF -DCPACK_BINARY_TZ:BOOL=OFF \ | ||
| -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \ | ||
| ../OpenStudio | ||
| ``` | ||
|
|
||
| You can deactivate now if you want | ||
|
|
||
| ``` | ||
| # Unix | ||
| . ./deactivate_conanbuild.sh | ||
| # Windows | ||
| call deactivate_conanbuild.bat | ||
| ``` | ||
|
|
||
| # Full Example | ||
|
|
||
| ``` | ||
| git clone git@github.com/NREL/OpenStudio.git | ||
| cd OpenStudio | ||
| conan install . --output-folder=../OSApp-build-release --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release | ||
| cmake --preset conan-release | ||
| cmake --build --preset conan-release | ||
| ``` | ||
|
|
||
| # Updating the Conan Lockfile | ||
|
|
||
| If you want to update a dependency in the `conan.lock`, just delete the line, and use this: | ||
|
|
||
|
|
||
| ```shell | ||
| conan install . --output-folder=../OSApp-build-release --build=missing \ | ||
| -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release \ | ||
| --lockfile-partial --lockfile-out=conan.lock | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Step 1