Skip to content

Commit

Permalink
Upgrade to Conan 2 (#92)
Browse files Browse the repository at this point in the history
* Attempt migration to conan version 2. Fails when finding Thrift executable as the provided FindTHRIFT.cmake is not used.

* Update to Conan 2

* Try a different way to get Conan in GitHub Actions

* Actually install the intended GCC version

* Set the CONAN_EXPORTED CMake variable again

* Revert to using specific dependency versions

* Try a different way of specifying dependencies

* Adapt to Thrift dependency version constraints

* Use Conan 1.x in the "Build" GH Actions workflow

* Support recent Conan 1.x versions too

* Remove support for running Conan from within CMake

* Reinstate tests on CI, clean up workflows

* Add OSP remote in build+test workflow

* Fix toolchain path on Windows CI

* Quote Windows path and try newer Linux distro

* Github action update

* Github action update

* Uploading artifacts to jfrog

gcc9 builds are not available from conancenter. Built libraries are uploaded to osp jfrog.

---------

Co-authored-by: kristoffere <kristoffer.eide@sintef.no>
Co-authored-by: David Heejong Park <hee.jong.park@dnv.com>
Co-authored-by: David Heejong Park <88651540+davidhjp01@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 19, 2024
1 parent 91fa071 commit 748059f
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 1,112 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build and test

on: [push, workflow_dispatch]

jobs:
linux:
name: Linux
runs-on: ${{ matrix.os }}
env:
CC: gcc-${{ matrix.compiler_version }}
CXX: g++-${{ matrix.compiler_version }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
build_type: [Debug, Release]
compiler_version: [ 9 ]
compiler_libcxx: [ libstdc++11 ]
steps:
- uses: actions/checkout@v4
- name: Install Conan
uses: turtlebrowser/get-conan@main
- name: Configure Conan
run: |
conan profile detect
conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
- name: Install dependencies
run: conan install --build=missing --output-folder=build -s build_type=${{ matrix.build_type }} .
- name: Generate build system
working-directory: build
run: >
cmake ..
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DPROXYFMU_BUILD_EXAMPLES=ON
-DPROXYFMU_BUILD_TESTS=ON
- name: Build
working-directory: build
run: cmake --build .
- name: Test
run: cd build/tests && ctest --output-on-failure --extra-verbose
- uses: actions/upload-artifact@v3
if: matrix.build_type == 'Release'
with:
name: proxyfmu
path: build/bin/proxyfmu*

windows:
name: Windows
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
- name: Install Conan
uses: turtlebrowser/get-conan@main
- name: Configure Conan
run: |
conan profile detect
conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
- name: Install dependencies
run: conan install --build=missing --output-folder=build -s build_type=${{ matrix.build_type }} .
- name: Generate build system
working-directory: build
shell: bash
run: >
cmake ..
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW
-DPROXYFMU_BUILD_EXAMPLES=ON
-DPROXYFMU_BUILD_TESTS=ON
- name: Build
working-directory: build
run: cmake --build . --config ${{ matrix.build_type }}
- name: Test
run: cd build/tests && ctest -C ${{ matrix.build_type }} --output-on-failure --extra-verbose
- uses: actions/upload-artifact@v3
if: matrix.build_type == 'Release'
with:
name: proxyfmu
path: build/bin/proxyfmu*
69 changes: 0 additions & 69 deletions .github/workflows/build.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload conan recipe
name: Upload Conan packages

env:
CONAN_LOGIN_USERNAME_OSP: ${{ secrets.osp_artifactory_usr }}
Expand All @@ -9,29 +9,30 @@ env:
on: [push, workflow_dispatch]

jobs:
conan-on-linux:
name: Conan
linux:
name: Linux
runs-on: ${{matrix.os}}
env:
CC: gcc-${{ matrix.compiler_version }}
CXX: g++-${{ matrix.compiler_version }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
os: [ubuntu-latest]
build_type: [Debug, Release]
compiler_version: [9]
compiler_libcxx: [libstdc++11]

steps:
- uses: actions/checkout@v2
- name: Install prerequisites
run: |
sudo apt-get install -y --no-install-recommends g++-8
sudo pip3 install --upgrade setuptools pip
sudo pip3 install conan
- uses: actions/checkout@v4
- name: Install compiler
run: sudo apt-get install -y --no-install-recommends g++-${{ matrix.compiler_version }}
- name: Install Conan
uses: turtlebrowser/get-conan@main
- name: Configure Conan
run: conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
run: |
conan profile detect
conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
- name: Conan create
run: |
REFNAME="${GITHUB_REF#refs/*/}"
Expand All @@ -42,28 +43,36 @@ jobs:
SHORT_REFNAME="${REFNAME:0:40}"
CHANNEL="testing-${SHORT_REFNAME//\//_}"
fi
conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -s compiler.libcxx=${{ matrix.compiler_libcxx }} -b missing . osp/${CHANNEL}
conan create \
-s build_type=${{ matrix.build_type }} \
-s compiler.version=${{ matrix.compiler_version }} \
-s compiler.libcxx=${{ matrix.compiler_libcxx }} \
-b missing \
--user=osp \
--channel=${CHANNEL} \
.
- name: Conan upload
run: conan upload --all --confirm --remote osp 'proxyfmu*'
run: conan upload --confirm --remote osp '*'


conan-on-windows:
name: Conan
windows:
name: Windows
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
build_type: [Debug, Release]
timeout-minutes: 120

steps:
- uses: actions/checkout@v2
- name: Install prerequisites
run: |
pip3 install --upgrade setuptools pip
pip3 install conan
- uses: actions/checkout@v4
- name: Install Conan
uses: turtlebrowser/get-conan@main
- name: Configure Conan
run: conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
run: |
conan profile detect
conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
- name: Conan create
shell: bash
run: |
Expand All @@ -75,6 +84,11 @@ jobs:
SHORT_REFNAME="${REFNAME:0:40}"
CHANNEL="testing-${SHORT_REFNAME//\//_}"
fi
conan create -s build_type=${{ matrix.build_type }} -b missing . osp/${CHANNEL}
conan create \
-s build_type=${{ matrix.build_type }} \
-b missing \
--user=osp \
--channel=${CHANNEL} \
.
- name: Conan upload
run: conan upload --all --confirm --remote osp 'proxyfmu*'
run: conan upload --confirm --remote osp '*'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
thrift.*

cmake-build-*

CMakeUserPresets.json
29 changes: 2 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

set(generatedSourcesDir "${CMAKE_BINARY_DIR}/generated")

set(Boost_USE_STATIC_LIBS ON)

if (MSVC)
add_definitions("-D_WIN32_WINNT=0x600" "-D_CRT_SECURE_NO_WARNINGS")
add_compile_options("/wd4996" "/wd4251" "/wd4244" "/wd4267")
Expand Down Expand Up @@ -57,27 +55,6 @@ set(PROXYFMU_EXPORT_TARGET "${PROJECT_NAME}-targets")
# Dependencies
# ==============================================================================

if (CONAN_EXPORTED) # in conan local cache
# standard conan installation, deps will be defined in conanfile.py
# and not necessary to call conan again, conan is already running
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else ()

include(cmake/conan.cmake)
conan_check(REQUIRED)

conan_cmake_autodetect(settings)

conan_add_remote(NAME osp URL https://osp.jfrog.io/artifactory/api/conan/conan-local)
conan_cmake_run(
CONANFILE conanfile.py
BUILD missing
SETTINGS ${settings}
BASIC_SETUP)

endif ()

set(BOOST_COMPONENTS filesystem)
if (PROXYFMU_BUILD_TESTS)
Include(FetchContent)
Expand All @@ -93,8 +70,8 @@ endif ()

find_package(Boost 1.71 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
find_package(CLI11 REQUIRED)
find_package(THRIFT REQUIRED)
find_package(FMILIB REQUIRED)
find_package(Thrift REQUIRED)
find_package(FMILIB MODULE REQUIRED)


# ==============================================================================
Expand Down Expand Up @@ -147,9 +124,7 @@ install(FILES "${versionFile}" DESTINATION "${PROXYFMU_CMAKE_INSTALL_DIR}")

# Install custom find modules
install(FILES
"${CMAKE_SOURCE_DIR}/cmake/FindCLI11.cmake"
"${CMAKE_SOURCE_DIR}/cmake/FindFMILIB.cmake"
"${CMAKE_SOURCE_DIR}/cmake/FindTHRIFT.cmake"
DESTINATION
"${PROXYFMU_CMAKE_INSTALL_DIR}"
)
19 changes: 0 additions & 19 deletions cmake/FindCLI11.cmake

This file was deleted.

39 changes: 0 additions & 39 deletions cmake/FindTHRIFT.cmake

This file was deleted.

Loading

0 comments on commit 748059f

Please sign in to comment.