Skip to content

Commit 4e43e36

Browse files
committed
Use cmake presets on conan builds
1 parent ad3b950 commit 4e43e36

File tree

4 files changed

+34
-37
lines changed

4 files changed

+34
-37
lines changed

.github/workflows/cmake_ubuntu.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,25 @@ jobs:
3232
- name: Create default profile
3333
run: conan profile detect
3434

35-
- name: Create Build Environment
36-
# Some projects don't allow in-source building, so create a separate build directory
37-
# We'll use this as our working directory for all subsequent commands
38-
run: cmake -E make_directory ${{github.workspace}}/build
39-
4035
- name: Install conan dependencies
41-
working-directory: ${{github.workspace}}/build
42-
run: conan install ${{github.workspace}}/conanfile.py -s build_type=${{env.BUILD_TYPE}} --build=missing
36+
run: conan install conanfile.py -s build_type=${{env.BUILD_TYPE}} --build=missing
37+
38+
- name: Normalize build type
39+
shell: bash
40+
# The build type is Capitalized, e.g. Release, but the preset is all lowercase, e.g. release.
41+
# There is no built in way to do string manipulations on GHA as far as I know.`
42+
run: echo "BUILD_TYPE_LOWERCASE=$(echo "${BUILD_TYPE}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
4343

4444
- name: Configure CMake
4545
shell: bash
46-
working-directory: ${{github.workspace}}/build
47-
run: cmake ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${{env.BUILD_TYPE}}/generators/conan_toolchain.cmake
46+
run: cmake --preset conan-${{ env.BUILD_TYPE_LOWERCASE }}
4847

4948
- name: Build
5049
shell: bash
51-
working-directory: ${{github.workspace}}/build
52-
run: cmake --build . --config ${{env.BUILD_TYPE}}
50+
run: cmake --build --preset conan-${{ env.BUILD_TYPE_LOWERCASE }}
5351

5452
- name: run test (Linux)
55-
working-directory: ${{github.workspace}}/build/tests
56-
run: ctest
53+
run: ctest --test-dir build/${{env.BUILD_TYPE}}
5754

5855
- name: Upload coverage reports to Codecov
5956
uses: codecov/codecov-action@v3

.github/workflows/cmake_windows.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,23 @@ jobs:
3232
- name: Create default profile
3333
run: conan profile detect
3434

35-
- name: Create Build Environment
36-
# Some projects don't allow in-source building, so create a separate build directory
37-
# We'll use this as our working directory for all subsequent commands
38-
run: cmake -E make_directory ${{github.workspace}}/build
39-
4035
- name: Install conan dependencies
41-
working-directory: ${{github.workspace}}/build
42-
run: conan install ${{github.workspace}}/conanfile.py -s build_type=${{env.BUILD_TYPE}} --build=missing
36+
run: conan install conanfile.py -s build_type=${{env.BUILD_TYPE}} --build=missing
37+
38+
- name: Normalize build type
39+
shell: bash
40+
# The build type is Capitalized, e.g. Release, but the preset is all lowercase, e.g. release.
41+
# There is no built in way to do string manipulations on GHA as far as I know.`
42+
run: echo "BUILD_TYPE_LOWERCASE=$(echo "${BUILD_TYPE}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
4343

4444
- name: Configure CMake
4545
shell: bash
46-
working-directory: ${{github.workspace}}/build
47-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake
46+
run: cmake --preset conan-${{ env.BUILD_TYPE_LOWERCASE }}
4847

4948
- name: Build
50-
working-directory: ${{github.workspace}}/build
5149
shell: bash
52-
run: cmake --build . --config ${{env.BUILD_TYPE}}
50+
run: cmake --build --preset conan-${{ env.BUILD_TYPE_LOWERCASE }}
5351

5452
- name: run test (Windows)
55-
working-directory: ${{github.workspace}}/build
53+
working-directory: ${{github.workspace}}/build/${{env.BUILD_TYPE}}
5654
run: $env:PATH+=";${{env.BUILD_TYPE}}"; tests/${{env.BUILD_TYPE}}/behaviortree_cpp_test.exe

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ Three build systems are supported:
6161

6262
Compiling with [conan](https://conan.io/):
6363

64+
> [!NOTE]
65+
> Conan builds require CMake 3.23 or newer.
66+
6467
Assuming that you are in the **root** directory of `BehaviorTree.CPP`:
6568

6669
```
67-
mkdir build_release
68-
conan install . -of build_release -s build_type=Release --build=missing
69-
cmake -S . -B build_release -DCMAKE_TOOLCHAIN_FILE="build_release/build/Release/generators/conan_toolchain.cmake"
70-
cmake --build build_release --parallel
70+
conan install . -s build_type=Release --build=missing
71+
cmake --preset conan-release
72+
cmake --build --preset conan-release
7173
```
7274

7375
If you have dependencies such as ZeroMQ and SQlite already installed and you don't want to

conanfile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ def requirements(self):
2626
def generate(self):
2727
tc = CMakeToolchain(self)
2828

29-
#tc.variables["USE_VENDORED_CPPSQLITE"] = False
30-
tc.variables["USE_VENDORED_CPPZMQ"] = False
31-
tc.variables["USE_VENDORED_FLATBUFFERS"] = False
32-
#tc.variables["USE_VENDORED_LEXY"] = False
33-
tc.variables["USE_VENDORED_MINICORO"] = False
34-
tc.variables["USE_VENDORED_MINITRACE"] = False
35-
tc.variables["USE_VENDORED_TINYXML2"] = False
36-
#tc.variables["USE_VENDORED_WILDCARDS"] = False
29+
#tc.cache_variables["USE_VENDORED_CPPSQLITE"] = False
30+
tc.cache_variables["USE_VENDORED_CPPZMQ"] = False
31+
tc.cache_variables["USE_VENDORED_FLATBUFFERS"] = False
32+
#tc.cache_variables["USE_VENDORED_LEXY"] = False
33+
tc.cache_variables["USE_VENDORED_MINICORO"] = False
34+
tc.cache_variables["USE_VENDORED_MINITRACE"] = False
35+
tc.cache_variables["USE_VENDORED_TINYXML2"] = False
36+
#tc.cache_variables["USE_VENDORED_WILDCARDS"] = False
3737
tc.generate()
3838

3939
deps = CMakeDeps(self)

0 commit comments

Comments
 (0)