Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Conan 2 #92

Merged
merged 18 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputs are not copied to bin directory. This is because we do not call conan_output_dirs_setup in conan2.

We need to either copy the following (from conanv1) to our cmake or --target install all the artifacts to bin before upload. I have not fixed this issue yet.

macro(conan_output_dirs_setup)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})

    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endmacro()


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
Loading