diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c53c345e..bfc62bad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 diff --git a/README.md b/README.md index 6cc1e8a1..57e6ebc4 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,45 @@ conan profile detect ``` The installation of `libqasm` dependencies, as well as the compilation, can be done in one go.
-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 @@ -72,7 +103,7 @@ conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm 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: @@ -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++ diff --git a/conan/profiles/debug b/conan/profiles/debug new file mode 100644 index 00000000..405995d9 --- /dev/null +++ b/conan/profiles/debug @@ -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 diff --git a/conan/profiles/debug-compat b/conan/profiles/debug-compat new file mode 100644 index 00000000..e070c6d1 --- /dev/null +++ b/conan/profiles/debug-compat @@ -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 diff --git a/conan/profiles/release b/conan/profiles/release new file mode 100644 index 00000000..7842c688 --- /dev/null +++ b/conan/profiles/release @@ -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 diff --git a/conan/profiles/release-compat b/conan/profiles/release-compat new file mode 100644 index 00000000..696093b8 --- /dev/null +++ b/conan/profiles/release-compat @@ -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 diff --git a/conan/profiles/tests-debug b/conan/profiles/tests-debug new file mode 100644 index 00000000..6021f64d --- /dev/null +++ b/conan/profiles/tests-debug @@ -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 diff --git a/conan/profiles/tests-debug-compat b/conan/profiles/tests-debug-compat new file mode 100644 index 00000000..4a7202d3 --- /dev/null +++ b/conan/profiles/tests-debug-compat @@ -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 diff --git a/conan/profiles/tests-release b/conan/profiles/tests-release new file mode 100644 index 00000000..e0ab99ec --- /dev/null +++ b/conan/profiles/tests-release @@ -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 diff --git a/conan/profiles/tests-release-compat b/conan/profiles/tests-release-compat new file mode 100644 index 00000000..f67282ee --- /dev/null +++ b/conan/profiles/tests-release-compat @@ -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