Skip to content

Commit

Permalink
Merge pull request #164 from QuTech-Delft/add_conan_profiles
Browse files Browse the repository at this point in the history
Add conan profiles
  • Loading branch information
rturrado authored Sep 27, 2023
2 parents f267c98 + 765d0ab commit 91e6971
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 6 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ jobs:
- name: Configure and build
run: |
conan profile detect
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=${{ matrix.build_type }} -o libqasm/*:build_tests=True -o libqasm/*:compat=True -o libqasm/*:asan_enabled=True -b missing
build_type=${{ matrix.build_type }}
lowercase_build_type=$(echo ${build_type} | tr '[:upper:]' '[:lower:]')
conan build . -pr=conan/profiles/tests-${lowercase_build_type}-compat -b missing
shell: bash
- name: Test
working-directory: build/${{ matrix.build_type }}
run: ctest -C ${{ matrix.build_type }} --output-on-failure
Expand Down Expand Up @@ -87,7 +90,7 @@ jobs:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip conan
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Release -o libqasm/*:build_tests=True -o libqasm/*:compat=True -o libqasm/*:asan_enabled=True -b missing
conan build . -pr=conan/profiles/tests-release-compat -b missing
- name: Test
working-directory: build/Release
run: ctest -C Release --output-on-failure
Expand Down
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,53 @@ conan profile detect
```

The installation of `libqasm` dependencies, as well as the compilation, can be done in one go.<br/>
Notice the command below is building `libqasm` in Debug mode with tests.

```
git clone https://github.com/QuTech-Delft/libqasm.git
cd libqasm
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm/*:build_tests=True -b missing
conan build . -pr=conan/profiles/tests-debug -b missing
```

The command above is building `libqasm` in Debug mode with tests using the `tests-debug` profile.

The `-b missing` parameter asks `conan` to build packages from sources
in case it cannot find the binary packages for the current configuration (platform, OS, compiler, build type...).

### Build profiles


A group of predefined profiles is provided under the `conan/profiles` folder.
They follow the `[tests-](debug|release)[-compat]` naming convention. For example:
- `release` is a Release build without tests and compatibility with the original API.
- `tests-debug-compat` is a Debug build with tests and compatibility enabled.

All the profiles set the C++ standard to 20. All the `tests` profiles enable Address Sanitizer.

### Build options

Profiles are a shorthand for command line options. The command above could be written as well as:

```
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm/*:asan_enabled=True -o libqasm/*:build_tests=True -o libqasm/*:compat=False -b missing
```

These are the list of options that could be specified whether in a profile or in the command line:

- `libqasm/*:build_tests={True,False}`: builds tests or not.
- `libqasm/*:build_type={Debug,Release}`: builds in debug or release mode.
- `libqasm/*:asan_enabled={True,False}`: enables Address Sanitizer.
- `libqasm/*:compat={True,False}`: enables installation of the headers for the original API,
on top of the ones for the new API.
- `libqasm/*:shared={True,False}`: builds a shared object library instead of a static library, if applicable.

## Install

### From Python

Install from the project root directory as follows:

```
python -m pip install --verbose .
python3 -m pip install --verbose .
```

or if you'd rather use conda:
Expand All @@ -85,7 +116,7 @@ conda install libqasm --use-local
You can test if it works by running:

```
python -m pytest
python3 -m pytest
```

### From C++
Expand Down
10 changes: 10 additions & 0 deletions conan/profiles/debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/debug-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=True
10 changes: 10 additions & 0 deletions conan/profiles/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/release-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=True
10 changes: 10 additions & 0 deletions conan/profiles/tests-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=True
libqasm/*:build_tests=True
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/tests-debug-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=True
libqasm/*:build_tests=True
libqasm/*:compat=True
10 changes: 10 additions & 0 deletions conan/profiles/tests-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=True
libqasm/*:build_tests=True
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/tests-release-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=True
libqasm/*:build_tests=True
libqasm/*:compat=True

0 comments on commit 91e6971

Please sign in to comment.