Skip to content

Commit

Permalink
Conan 2 (#373)
Browse files Browse the repository at this point in the history
* Update to Conan 2 and use new cmake-conan dependency provider
* Fix warning about defining the CMakeDeps generator being mandatory in the future
* Generate and log conan lock file
* Document the update to Conan 2
* Bump CMake to 3.28.3, apart from on ubuntu-14.04
* Fix conan.io recipe link
  • Loading branch information
garethsb authored Feb 18, 2024
1 parent d1ee2ca commit ba267fa
Show file tree
Hide file tree
Showing 15 changed files with 792 additions and 150 deletions.
102 changes: 68 additions & 34 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ jobs:
- name: install conan
if: matrix.use_conan == true
run: |
pip install conan~=1.47
conan config set general.revisions_enabled=1
pip install conan~=2.0.5
- name: install cmake
- name: 'ubuntu-14.04: install cmake'
if: matrix.os == 'ubuntu-14.04'
uses: lukka/[email protected]

- name: install cmake
if: matrix.os != 'ubuntu-14.04'
uses: lukka/[email protected]

- name: setup bash path
working-directory: ${{ env.GITHUB_WORKSPACE }}
shell: bash
Expand All @@ -139,7 +143,7 @@ jobs:
if: runner.os == 'Windows'
run: |
# set compiler to cl.exe to avoid building with gcc.
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe" >> $env:GITHUB_ENV
echo "CMAKE_COMPILER_ARGS=-DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe" >> $env:GITHUB_ENV
# disable unused network interface
netsh interface set interface name="vEthernet (nat)" admin=DISABLED
# get host IP address
Expand Down Expand Up @@ -269,13 +273,11 @@ jobs:
cmake .. -DCMAKE_BUILD_TYPE:STRING="Release" -DWERROR:BOOL="0" -DBUILD_SAMPLES:BOOL="0" -DBUILD_TESTS:BOOL="0"
make -j 2 && sudo make install
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DWEBSOCKETPP_INCLUDE_DIR:PATH=\"${{ env.RUNNER_WORKSPACE }}/cpprestsdk/Release/libs/websocketpp\"" >> $GITHUB_ENV
- name: disable conan
if: matrix.use_conan == false
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_USE_CONAN:BOOL=\"0\"" >> $GITHUB_ENV
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }}" \
"-DWEBSOCKETPP_INCLUDE_DIR:PATH=\"${{ env.RUNNER_WORKSPACE }}/cpprestsdk/Release/libs/websocketpp\"" \
"-DNMOS_CPP_USE_SUPPLIED_JSON_SCHEMA_VALIDATOR:BOOL=\"1\"" \
"-DNMOS_CPP_USE_SUPPLIED_JWT_CPP:BOOL=\"1\"" \
>> $GITHUB_ENV
- name: ubuntu avahi setup
if: runner.os == 'Linux' && matrix.install_mdns == false
Expand All @@ -292,10 +294,20 @@ jobs:
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_USE_AVAHI:BOOL=\"1\"" >> $GITHUB_ENV
- name: force cpprest asio
if: matrix.force_cpprest_asio == true
if: matrix.force_cpprest_asio == true && matrix.use_conan == true
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_CONAN_OPTIONS:STRING=\"cpprestsdk:http_client_impl=asio;cpprestsdk:http_listener_impl=asio\"" >> $GITHUB_ENV
echo "CONAN_INSTALL_EXTRA_ARGS=--options\;cpprestsdk/*:http_client_impl=asio\;--options\;cpprestsdk/*:http_listener_impl=asio" >> $GITHUB_ENV
- name: enable conan
if: matrix.use_conan == true
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }}" \
"-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES:STRING=\"third_party/cmake/conan_provider.cmake\"" \
"-DCONAN_INSTALL_ARGS:STRING=\"--build=missing\;${{ env.CONAN_INSTALL_EXTRA_ARGS }}\;--lockfile-out=conan.lock\"" \
>> $GITHUB_ENV
cat $GITHUB_ENV
- name: setup developer command prompt for Microsoft Visual C++
if: runner.os == 'Windows'
Expand All @@ -307,7 +319,12 @@ jobs:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ env.GITHUB_WORKSPACE }}/Development/CMakeLists.txt'
buildDirectory: '${{ env.RUNNER_WORKSPACE }}/build/'
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ env.RUNNER_WORKSPACE }}/install" ${{ env.CMAKE_EXTRA_ARGS }}'
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ env.RUNNER_WORKSPACE }}/install" ${{ env.CMAKE_COMPILER_ARGS }} ${{ env.CMAKE_EXTRA_ARGS }}'

- name: dump conan lockfile
if: matrix.use_conan == true
run: |
cat ${{ env.RUNNER_WORKSPACE }}/build/conan.lock
- name: unit test
run: |
Expand Down Expand Up @@ -344,10 +361,10 @@ jobs:
cmakeAppendedArgs: '-GNinja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG="1"
-DCMAKE_MODULE_PATH="${{ env.CMAKE_WORKSPACE }}/build"
-DCMAKE_MODULE_PATH="${{ env.CMAKE_WORKSPACE }}/build/conan"
-DCMAKE_PREFIX_PATH="${{ env.CMAKE_WORKSPACE }}/install"
-DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_WORKSPACE }}/build"
${{ env.CMAKE_EXTRA_ARGS }}'
-DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_WORKSPACE }}/build/conan"
${{ env.CMAKE_COMPILER_ARGS }}'

- name: install test log
run: |
Expand Down Expand Up @@ -660,12 +677,16 @@ jobs:
- name: install conan
if: matrix.use_conan == true
run: |
pip install conan~=1.47
conan config set general.revisions_enabled=1
pip install conan~=2.0.5
- name: install cmake
- name: 'ubuntu-14.04: install cmake'
if: matrix.os == 'ubuntu-14.04'
uses: lukka/[email protected]

- name: install cmake
if: matrix.os != 'ubuntu-14.04'
uses: lukka/[email protected]

- name: setup bash path
working-directory: ${{ env.GITHUB_WORKSPACE }}
shell: bash
Expand All @@ -678,7 +699,7 @@ jobs:
if: runner.os == 'Windows'
run: |
# set compiler to cl.exe to avoid building with gcc.
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe" >> $env:GITHUB_ENV
echo "CMAKE_COMPILER_ARGS=-DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe" >> $env:GITHUB_ENV
# disable unused network interface
netsh interface set interface name="vEthernet (nat)" admin=DISABLED
# get host IP address
Expand Down Expand Up @@ -808,13 +829,11 @@ jobs:
cmake .. -DCMAKE_BUILD_TYPE:STRING="Release" -DWERROR:BOOL="0" -DBUILD_SAMPLES:BOOL="0" -DBUILD_TESTS:BOOL="0"
make -j 2 && sudo make install
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DWEBSOCKETPP_INCLUDE_DIR:PATH=\"${{ env.RUNNER_WORKSPACE }}/cpprestsdk/Release/libs/websocketpp\"" >> $GITHUB_ENV
- name: disable conan
if: matrix.use_conan == false
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_USE_CONAN:BOOL=\"0\"" >> $GITHUB_ENV
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }}" \
"-DWEBSOCKETPP_INCLUDE_DIR:PATH=\"${{ env.RUNNER_WORKSPACE }}/cpprestsdk/Release/libs/websocketpp\"" \
"-DNMOS_CPP_USE_SUPPLIED_JSON_SCHEMA_VALIDATOR:BOOL=\"1\"" \
"-DNMOS_CPP_USE_SUPPLIED_JWT_CPP:BOOL=\"1\"" \
>> $GITHUB_ENV
- name: ubuntu avahi setup
if: runner.os == 'Linux' && matrix.install_mdns == false
Expand All @@ -831,10 +850,20 @@ jobs:
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_USE_AVAHI:BOOL=\"1\"" >> $GITHUB_ENV
- name: force cpprest asio
if: matrix.force_cpprest_asio == true
if: matrix.force_cpprest_asio == true && matrix.use_conan == true
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_CONAN_OPTIONS:STRING=\"cpprestsdk:http_client_impl=asio;cpprestsdk:http_listener_impl=asio\"" >> $GITHUB_ENV
echo "CONAN_INSTALL_EXTRA_ARGS=--options\;cpprestsdk/*:http_client_impl=asio\;--options\;cpprestsdk/*:http_listener_impl=asio" >> $GITHUB_ENV
- name: enable conan
if: matrix.use_conan == true
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }}" \
"-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES:STRING=\"third_party/cmake/conan_provider.cmake\"" \
"-DCONAN_INSTALL_ARGS:STRING=\"--build=missing\;${{ env.CONAN_INSTALL_EXTRA_ARGS }}\;--lockfile-out=conan.lock\"" \
>> $GITHUB_ENV
cat $GITHUB_ENV
- name: setup developer command prompt for Microsoft Visual C++
if: runner.os == 'Windows'
Expand All @@ -846,7 +875,12 @@ jobs:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ env.GITHUB_WORKSPACE }}/Development/CMakeLists.txt'
buildDirectory: '${{ env.RUNNER_WORKSPACE }}/build/'
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ env.RUNNER_WORKSPACE }}/install" ${{ env.CMAKE_EXTRA_ARGS }}'
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ env.RUNNER_WORKSPACE }}/install" ${{ env.CMAKE_COMPILER_ARGS }} ${{ env.CMAKE_EXTRA_ARGS }}'

- name: dump conan lockfile
if: matrix.use_conan == true
run: |
cat ${{ env.RUNNER_WORKSPACE }}/build/conan.lock
- name: unit test
run: |
Expand Down Expand Up @@ -883,10 +917,10 @@ jobs:
cmakeAppendedArgs: '-GNinja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG="1"
-DCMAKE_MODULE_PATH="${{ env.CMAKE_WORKSPACE }}/build"
-DCMAKE_MODULE_PATH="${{ env.CMAKE_WORKSPACE }}/build/conan"
-DCMAKE_PREFIX_PATH="${{ env.CMAKE_WORKSPACE }}/install"
-DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_WORKSPACE }}/build"
${{ env.CMAKE_EXTRA_ARGS }}'
-DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_WORKSPACE }}/build/conan"
${{ env.CMAKE_COMPILER_ARGS }}'

- name: install test log
run: |
Expand Down
38 changes: 25 additions & 13 deletions .github/workflows/src/build-setup.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
- name: install conan
if: matrix.use_conan == true
run: |
pip install conan~=1.47
conan config set general.revisions_enabled=1
pip install conan~=2.0.5
- name: install cmake
- name: 'ubuntu-14.04: install cmake'
if: matrix.os == 'ubuntu-14.04'
uses: lukka/[email protected]

- name: install cmake
if: matrix.os != 'ubuntu-14.04'
uses: lukka/[email protected]

- name: setup bash path
working-directory: ${{ env.GITHUB_WORKSPACE }}
shell: bash
Expand All @@ -19,7 +23,7 @@
if: runner.os == 'Windows'
run: |
# set compiler to cl.exe to avoid building with gcc.
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe" >> $env:GITHUB_ENV
echo "CMAKE_COMPILER_ARGS=-DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe" >> $env:GITHUB_ENV
# disable unused network interface
netsh interface set interface name="vEthernet (nat)" admin=DISABLED
# get host IP address
Expand Down Expand Up @@ -149,13 +153,11 @@
cmake .. -DCMAKE_BUILD_TYPE:STRING="Release" -DWERROR:BOOL="0" -DBUILD_SAMPLES:BOOL="0" -DBUILD_TESTS:BOOL="0"
make -j 2 && sudo make install
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DWEBSOCKETPP_INCLUDE_DIR:PATH=\"${{ env.RUNNER_WORKSPACE }}/cpprestsdk/Release/libs/websocketpp\"" >> $GITHUB_ENV
- name: disable conan
if: matrix.use_conan == false
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_USE_CONAN:BOOL=\"0\"" >> $GITHUB_ENV
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }}" \
"-DWEBSOCKETPP_INCLUDE_DIR:PATH=\"${{ env.RUNNER_WORKSPACE }}/cpprestsdk/Release/libs/websocketpp\"" \
"-DNMOS_CPP_USE_SUPPLIED_JSON_SCHEMA_VALIDATOR:BOOL=\"1\"" \
"-DNMOS_CPP_USE_SUPPLIED_JWT_CPP:BOOL=\"1\"" \
>> $GITHUB_ENV
- name: ubuntu avahi setup
if: runner.os == 'Linux' && matrix.install_mdns == false
Expand All @@ -172,7 +174,17 @@
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_USE_AVAHI:BOOL=\"1\"" >> $GITHUB_ENV
- name: force cpprest asio
if: matrix.force_cpprest_asio == true
if: matrix.force_cpprest_asio == true && matrix.use_conan == true
shell: bash
run: |
echo "CONAN_INSTALL_EXTRA_ARGS=--options\;cpprestsdk/*:http_client_impl=asio\;--options\;cpprestsdk/*:http_listener_impl=asio" >> $GITHUB_ENV
- name: enable conan
if: matrix.use_conan == true
shell: bash
run: |
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }} -DNMOS_CPP_CONAN_OPTIONS:STRING=\"cpprestsdk:http_client_impl=asio;cpprestsdk:http_listener_impl=asio\"" >> $GITHUB_ENV
echo "CMAKE_EXTRA_ARGS=${{ env.CMAKE_EXTRA_ARGS }}" \
"-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES:STRING=\"third_party/cmake/conan_provider.cmake\"" \
"-DCONAN_INSTALL_ARGS:STRING=\"--build=missing\;${{ env.CONAN_INSTALL_EXTRA_ARGS }}\;--lockfile-out=conan.lock\"" \
>> $GITHUB_ENV
cat $GITHUB_ENV
7 changes: 6 additions & 1 deletion .github/workflows/src/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ env.GITHUB_WORKSPACE }}/Development/CMakeLists.txt'
buildDirectory: '${{ env.RUNNER_WORKSPACE }}/build/'
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ env.RUNNER_WORKSPACE }}/install" ${{ env.CMAKE_EXTRA_ARGS }}'
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ env.RUNNER_WORKSPACE }}/install" ${{ env.CMAKE_COMPILER_ARGS }} ${{ env.CMAKE_EXTRA_ARGS }}'

- name: dump conan lockfile
if: matrix.use_conan == true
run: |
cat ${{ env.RUNNER_WORKSPACE }}/build/conan.lock
6 changes: 3 additions & 3 deletions .github/workflows/src/install-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
cmakeAppendedArgs: '-GNinja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG="1"
-DCMAKE_MODULE_PATH="${{ env.CMAKE_WORKSPACE }}/build"
-DCMAKE_MODULE_PATH="${{ env.CMAKE_WORKSPACE }}/build/conan"
-DCMAKE_PREFIX_PATH="${{ env.CMAKE_WORKSPACE }}/install"
-DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_WORKSPACE }}/build"
${{ env.CMAKE_EXTRA_ARGS }}'
-DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_WORKSPACE }}/build/conan"
${{ env.CMAKE_COMPILER_ARGS }}'

- name: install test log
run: |
Expand Down
9 changes: 3 additions & 6 deletions Development/cmake/NmosCppCommon.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
set(NMOS_CPP_USE_CONAN ON CACHE BOOL "Use Conan to acquire dependencies")
mark_as_advanced(FORCE NMOS_CPP_USE_CONAN)

if(NMOS_CPP_USE_CONAN)
include(cmake/NmosCppConan.cmake)
endif()
# since moving to Conan 2 and CMake 3.24 or higher, the injection point is used to configure conan
# see https://cmake.org/cmake/help/v3.24/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.html
unset(NMOS_CPP_USE_CONAN CACHE)

include(GNUInstallDirs)

Expand Down
56 changes: 0 additions & 56 deletions Development/cmake/NmosCppConan.cmake

This file was deleted.

Loading

0 comments on commit ba267fa

Please sign in to comment.