Skip to content

Commit bce2132

Browse files
Upgrade to Conan 2 (#747)
* Upgrade to Conan 2 This fixes issue #718 (and incidentally fixes #702 too). The modified `<gsl/util>` imports and various changes from `int` to `std::size_t` are a consequence of using a newer version of MS GSL. I changed the dependency version so we can use an upstream CMake package configuration file which is compatible with the one generated by Conan 2's `CMakeDeps` generator. This should enable us to use the same `find_package()` commands and target names regardless of whether the build is running under Conan or not. This also removes the ability to run Conan from within CMake, because upstream hasn't released a version of the cmake-conan helper script with full support for all Conan 2 features yet. (Notably, support for the `CMakeToolchain` generator is missing.) * Update GH Actions workflows for Conan 2 * Use a conanio Docker image that has Conan 2 * Run pure-CMake CI build in Docker, drop Windows * Fix minor mistake in workflow file * Fix more small mistakes in CI * More legible build matrix elements in non-Conan CI * Ensure that libdl is listed as a dependency of fmilib::shared * Also import proxyfmu executable to the build directory * Update version numbers in README * Clean up GitHub Actions workflows a bit * Set the cpp_info property `cmake_target_name` as `libcosim::cosim` in the `package_info` method. This is because otherwise CMakeDeps incorrectly generates the dependency in the target cmake file as `libcosim::libcosim`. (i.e. <consumer>-Target-release.cmake, see https://docs.conan.io/2/reference/tools/cmake/cmakedeps.html#generated-files). This would not be found via `find_package(libcosim REQUIRED)`. * Uploading artifacts to jfrog (#751) gcc9 builds are not available from conancenter. Built libraries are uploaded to osp jfrog. * Updated proxyfmu * Updated version.txt to 0.10.3 --------- Co-authored-by: David Heejong Park <hee.jong.park@dnv.com> Co-authored-by: David Heejong Park <88651540+davidhjp01@users.noreply.github.com>
1 parent 9dff0ad commit bce2132

20 files changed

Lines changed: 223 additions & 443 deletions

.github/workflows/ci-cmake.yml

Lines changed: 41 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,56 @@
1-
name: libcosim CI CMake
1+
name: CI without Conan
22

33
# This workflow is triggered on pushes to the repository.
44
on: [push]
55

6-
env:
7-
CONAN_LOGIN_USERNAME_OSP: ${{ secrets.osp_artifactory_usr }}
8-
CONAN_PASSWORD_OSP: ${{ secrets.osp_artifactory_pwd }}
9-
CONAN_REVISIONS_ENABLED: 1
10-
CONAN_NON_INTERACTIVE: 1
11-
126
jobs:
13-
cmake-on-linux:
14-
name: CMake
15-
runs-on: ${{ matrix.os }}
16-
env:
17-
CC: gcc-${{ matrix.compiler_version }}
18-
CXX: g++-${{ matrix.compiler_version }}
7+
linux:
8+
name: Linux
9+
runs-on: ubuntu-latest
1910
strategy:
2011
fail-fast: false
2112
matrix:
22-
os: [ubuntu-20.04]
2313
build_type: [Debug, Release]
24-
compiler_version: [9]
25-
shared_libs: [ON, OFF]
14+
shared_libs: [SHARED_LIBS=ON, SHARED_LIBS=OFF]
2615
timeout-minutes: 35
2716

2817
steps:
29-
- uses: actions/checkout@v3
30-
- name: Install prerequisites
31-
run: |
32-
sudo apt-get install -y --no-install-recommends \
33-
doxygen \
34-
libboost-all-dev \
35-
libmsgsl-dev \
36-
libyaml-cpp-dev \
37-
libxerces-c-dev \
38-
libzip-dev
39-
wget \
18+
- uses: actions/checkout@v4
19+
- name: Generate Dockerfile
20+
run: |
21+
mkdir /tmp/osp-builder-docker
22+
cat <<EOF >/tmp/osp-builder-docker/Dockerfile
23+
FROM debian:bookworm
24+
RUN apt-get update && apt-get install -y --no-install-recommends \
25+
cmake \
26+
build-essential \
27+
doxygen \
28+
wget \
29+
libboost-all-dev \
30+
libmsgsl-dev \
31+
libyaml-cpp-dev \
32+
libxerces-c-dev \
33+
libzip-dev zipcmp zipmerge ziptool
34+
RUN wget \
35+
--no-check-certificate \
4036
"https://github.com/viproma/debian-fmilib/releases/download/debian%2F2.0.3-1/libfmilib2_2.0.3-1_amd64.deb" \
4137
"https://github.com/viproma/debian-fmilib/releases/download/debian%2F2.0.3-1/libfmilib2-dev_2.0.3-1_amd64.deb"
42-
sudo dpkg -i libfmilib2_2.0.3-1_amd64.deb libfmilib2-dev_2.0.3-1_amd64.deb
43-
- name: CMake - configure
44-
run: |
45-
cmake \
46-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
47-
-DCMAKE_PREFIX_PATH=fmilibrary \
48-
-DCMAKE_INSTALL_PREFIX=install \
49-
-DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} \
50-
-B build
51-
- name: CMake - build
52-
run: cmake --build build
53-
- name: CMake - build doc
54-
run: cmake --build build --target doc
55-
- name: CMake - test
56-
run: |
38+
RUN dpkg -i libfmilib2_2.0.3-1_amd64.deb libfmilib2-dev_2.0.3-1_amd64.deb
39+
COPY entrypoint.sh /
40+
ENTRYPOINT /entrypoint.sh
41+
EOF
42+
- name: Generate entrypoint.sh
43+
run: |
44+
cat <<'EOF' >/tmp/osp-builder-docker/entrypoint.sh
45+
#!/bin/bash
46+
mkdir build
5747
cd build
58-
ctest
59-
- name: CMake - install
60-
run: |
61-
cmake --build build --target install
62-
cmake --build build --target install-doc
63-
- name: Upload artifact
64-
uses: actions/upload-artifact@v3
65-
with:
66-
name: libcosim-${{ runner.os }}-${{ matrix.build_type }}-gcc${{ matrix.compiler_version }}
67-
path: install
68-
69-
70-
cmake-on-windows:
71-
name: CMake
72-
runs-on: ${{ matrix.os }}
73-
strategy:
74-
fail-fast: false
75-
matrix:
76-
os: [windows-2019]
77-
build_type: [Debug, Release]
78-
shared: ["True", "False"]
79-
timeout-minutes: 35
80-
81-
steps:
82-
- uses: actions/checkout@v3
83-
- name: Install prerequisites
84-
run: |
85-
pip3 install --upgrade setuptools pip
86-
pip3 install conan==1.59
87-
choco install doxygen.install
88-
conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
89-
conan install . -s build_type=${{ matrix.build_type }} -o shared=${{ matrix.shared }} -g deploy
90-
- name: CMake - configure
91-
shell: bash
92-
run: |
93-
cmake . \
94-
-A x64 \
95-
-DCMAKE_PREFIX_PATH="ms-gsl;boost;fmilibrary;libzip;xerces-c;yaml-cpp;bzip2;zlib;xz_utils" \
96-
-DCMAKE_INSTALL_PREFIX=install \
97-
-DBUILD_SHARED_LIBS=${{ matrix.shared }} \
98-
-B build
99-
- name: CMake - build
100-
run: cmake --build build --config ${{ matrix.build_type }}
101-
- name: CMake - build doc
102-
run: cmake --build build --config ${{ matrix.build_type }} --target doc
103-
- name: CMake - test
104-
run: |
105-
.\activate_run.ps1
106-
cd build
107-
ctest -C ${{ matrix.build_type }}
108-
- name: CMake - install
109-
run: |
110-
cmake --build build --config ${{ matrix.build_type }} --target install
111-
cmake --build build --config ${{ matrix.build_type }} --target install-doc
112-
- name: Upload artifact
113-
uses: actions/upload-artifact@v3
114-
with:
115-
name: libcosim-${{ runner.os }}-${{ matrix.build_type }}
116-
path: install
48+
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_${{ matrix.shared_libs }} /mnt/source
49+
cmake --build .
50+
ctest --output-on-failure
51+
EOF
52+
chmod 0755 /tmp/osp-builder-docker/entrypoint.sh
53+
- name: Build Docker image
54+
run: docker build -t osp-builder /tmp/osp-builder-docker/
55+
- name: Build cosim
56+
run: docker run --rm -v $(pwd):/mnt/source:ro osp-builder

.github/workflows/ci-conan.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
name: libcosim CI Conan
1+
name: CI with Conan
22

33
# This workflow is triggered on pushes to the repository.
44
on: [push, workflow_dispatch]
55

66
jobs:
7-
conan-on-linux:
8-
name: Conan
7+
linux:
8+
name: Linux
99
runs-on: ubuntu-latest
1010
strategy:
1111
fail-fast: false
1212
matrix:
1313
build_type: [Debug, Release]
1414
compiler_version: [9]
15-
compiler_libcxx: [libstdc++11]
1615
option_proxyfmu: ['proxyfmu=True', 'proxyfmu=False']
1716
option_shared: ['shared=True', 'shared=False']
1817
timeout-minutes: 35
1918

2019
steps:
21-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2221
- name: Generate Dockerfile
2322
run: |
2423
mkdir /tmp/osp-builder-docker
2524
cat <<'EOF' >/tmp/osp-builder-docker/Dockerfile
26-
FROM conanio/gcc${{ matrix.compiler_version }}
25+
FROM conanio/gcc${{ matrix.compiler_version }}-ubuntu16.04
2726
ENV CONAN_LOGIN_USERNAME_OSP=${{ secrets.osp_artifactory_usr }}
2827
ENV CONAN_PASSWORD_OSP=${{ secrets.osp_artifactory_pwd }}
29-
ENV CONAN_REVISIONS_ENABLED=1
30-
ENV CONAN_NON_INTERACTIVE=1
31-
ENV CONAN_USE_ALWAYS_SHORT_PATHS=1
3228
ENV LIBCOSIM_RUN_TESTS_ON_CONAN_BUILD=1
3329
COPY entrypoint.sh /
3430
ENTRYPOINT /entrypoint.sh
@@ -48,28 +44,30 @@ jobs:
4844
SHORT_REFNAME="${REFNAME:0:40}"
4945
CHANNEL="testing-${SHORT_REFNAME//\//_}"
5046
fi
51-
conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -s compiler.libcxx=${{ matrix.compiler_libcxx }} -o ${{ matrix.option_proxyfmu }} -o ${{ matrix.option_shared }} -b missing . osp/${CHANNEL}
52-
conan upload --all -c -r osp '*'
47+
conan create \
48+
--settings="build_type=${{ matrix.build_type }}" \
49+
--options="${{ matrix.option_proxyfmu }}" \
50+
--options="${{ matrix.option_shared }}" \
51+
--build=missing \
52+
--user=osp \
53+
--channel="${CHANNEL}" \
54+
.
55+
conan upload --confirm --remote=osp '*'
5356
EOF
5457
chmod 0755 /tmp/osp-builder-docker/entrypoint.sh
5558
- name: Build Docker image
56-
run: |
57-
docker build -t osp-builder /tmp/osp-builder-docker/
59+
run: docker build -t osp-builder /tmp/osp-builder-docker/
5860
- name: Build cosim
5961
run: |
6062
docker run --rm --env GITHUB_REF="$GITHUB_REF" -v $(pwd):/mnt/source:ro osp-builder
6163
6264
63-
conan-on-windows:
64-
name: Conan
65+
windows:
66+
name: Windows
6567
runs-on: ${{ matrix.os }}
6668
env:
6769
CONAN_LOGIN_USERNAME_OSP: ${{ secrets.osp_artifactory_usr }}
6870
CONAN_PASSWORD_OSP: ${{ secrets.osp_artifactory_pwd }}
69-
CONAN_REVISIONS_ENABLED: 1
70-
CONAN_NON_INTERACTIVE: 1
71-
CONAN_USE_ALWAYS_SHORT_PATHS: 1
72-
CONAN_USER_HOME_SHORT: C:\c
7371
LIBCOSIM_RUN_TESTS_ON_CONAN_BUILD: 1
7472
strategy:
7573
fail-fast: false
@@ -78,16 +76,18 @@ jobs:
7876
build_type: [Debug, Release]
7977
option_proxyfmu: ['proxyfmu=True', 'proxyfmu=False']
8078
option_shared: ['shared=True', 'shared=False']
81-
timeout-minutes: 35
79+
timeout-minutes: 120
8280

8381
steps:
84-
- uses: actions/checkout@v3
82+
- uses: actions/checkout@v4
8583
- name: Install prerequisites
8684
run: |
8785
pip3 install --upgrade setuptools pip
88-
pip3 install conan==1.59
86+
pip3 install conan
8987
- name: Configure Conan
90-
run: conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
88+
run: |
89+
conan profile detect
90+
conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
9191
- name: Conan create
9292
shell: bash
9393
run: |
@@ -99,6 +99,13 @@ jobs:
9999
SHORT_REFNAME="${REFNAME:0:40}"
100100
CHANNEL="testing-${SHORT_REFNAME//\//_}"
101101
fi
102-
conan create -s build_type=${{ matrix.build_type }} -o ${{ matrix.option_proxyfmu }} -o ${{ matrix.option_shared }} -b missing . osp/${CHANNEL}
102+
conan create \
103+
--settings="build_type=${{ matrix.build_type }}" \
104+
--options="${{ matrix.option_proxyfmu }}" \
105+
--options="${{ matrix.option_shared }}" \
106+
--build=missing \
107+
--user=osp \
108+
--channel="${CHANNEL}" \
109+
.
103110
- name: Conan upload
104-
run: conan upload --all -c -r osp '*'
111+
run: conan upload --confirm --remote=osp '*'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ cmake-build-*/
99

1010
# Visual Studio Code
1111
.vscode/
12+
13+
CMakeUserPresets.json

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to libcosim will be documented in this file. This includes n
33

44
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
55

6+
### [v0.10.3] - 2024-02-19
7+
##### Fixed
8+
* parseURI null check and error handling implemented.
9+
##### Changed
10+
* Upgraded Conan to v2
11+
612
### [v0.10.2] - 2023-02-08
713
##### Fixed
814
* Update to proxyfmu 0.3.1 due to a disconnection issue related to Thrift.
@@ -217,3 +223,4 @@ First OSP JIP partner release
217223
[v0.10.0]: https://github.com/open-simulation-platform/cse-core/compare/v0.9.0...v0.10.0
218224
[v0.10.1]: https://github.com/open-simulation-platform/cse-core/compare/v0.10.0...v0.10.1
219225
[v0.10.2]: https://github.com/open-simulation-platform/cse-core/compare/v0.10.1...v0.10.2
226+
[v0.10.3]: https://github.com/open-simulation-platform/cse-core/compare/v0.10.2...v0.10.3

CMakeLists.txt

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.9)
1+
cmake_minimum_required(VERSION 3.19)
22
file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" projectVersion)
33
project("libcosim" VERSION ${projectVersion})
44
message("Current libcosim version: ${CMAKE_PROJECT_VERSION}\n")
@@ -13,8 +13,6 @@ option(LIBCOSIM_BUILD_TESTS "Build test suite" ON)
1313
option(LIBCOSIM_BUILD_APIDOC "Build API documentation (requires Doxygen)" ON)
1414
option(LIBCOSIM_BUILD_PRIVATE_APIDOC "Build private API documentation (only used if LIBCOSIM_BUILD_APIDOC=ON)" OFF)
1515
option(LIBCOSIM_STANDALONE_INSTALLATION "Whether to build for a standalone installation (Linux only; sets a relative RPATH)" OFF)
16-
option(LIBCOSIM_USING_CONAN "Whether Conan is used for package management" OFF)
17-
option(LIBCOSIM_USING_CONAN_AUTO_CONFIG "Whether Conan should be configured automatically by CMake" OFF)
1816
option(LIBCOSIM_WITH_PROXYFMU "Whether or not to build with proxy-fmu integration" OFF)
1917
option(LIBCOSIM_NO_FMI_LOGGING "Disable FMI logging during simulation" OFF)
2018

@@ -98,44 +96,6 @@ set(LIBCOSIM_EXPORT_TARGET "${PROJECT_NAME}-targets")
9896
# Dependencies
9997
# ==============================================================================
10098

101-
if(LIBCOSIM_USING_CONAN)
102-
if(NOT LIBCOSIM_USING_CONAN_AUTO_CONFIG OR CONAN_EXPORTED)
103-
# Opting for manual invocation of conan install prior to loading CMake
104-
# or conan create has been invoked, setting CONAN_EXPORTED.
105-
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
106-
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
107-
conan_basic_setup(NO_OUTPUT_DIRS)
108-
else()
109-
message(FATAL_ERROR "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
110-
endif()
111-
else()
112-
# Auto config specified and conan create is not running.
113-
# We'll let CMake run the conan commands for us.
114-
115-
# This is where the magic happens.
116-
# The file has been modified to search for the conan executable on linux systems.
117-
include(cmake/conan.cmake)
118-
conan_cmake_autodetect(settings)
119-
120-
set(proxyfmu_option False)
121-
if(LIBCOSIM_WITH_PROXYFMU)
122-
set(proxyfmu_option True)
123-
endif()
124-
125-
# Force add osp remote
126-
conan_add_remote(NAME osp URL https://osp.jfrog.io/artifactory/api/conan/conan-local)
127-
128-
# Run conan install with auto-detected settings and -b missing flag
129-
# and -o proxyfmu=True if LIBCOSIM_WITH_PROXYFMU=ON
130-
conan_cmake_run(
131-
CONANFILE conanfile.py
132-
OPTIONS proxyfmu=${proxyfmu_option}
133-
BUILD missing
134-
SETTINGS ${settings}
135-
BASIC_SETUP NO_OUTPUT_DIRS)
136-
endif()
137-
endif()
138-
13999
set(Boost_components date_time log)
140100
if (LIBCOSIM_BUILD_TESTS)
141101
list(APPEND Boost_components timer unit_test_framework)
@@ -148,11 +108,11 @@ find_package(Boost REQUIRED COMPONENTS ${Boost_components})
148108
if(BUILD_SHARED_LIBS AND NOT DEFINED FMILibrary_USE_SHARED_LIB)
149109
set(FMILibrary_USE_SHARED_LIB TRUE)
150110
endif()
151-
find_package(FMILibrary REQUIRED)
152-
find_package(LIBZIP REQUIRED)
153-
find_package(MS_GSL REQUIRED)
154-
find_package(YAML_CPP REQUIRED)
155-
find_package(XercesC REQUIRED)
111+
find_package(FMILibrary MODULE REQUIRED)
112+
find_package(libzip REQUIRED)
113+
find_package(Microsoft.GSL REQUIRED)
114+
find_package(yaml-cpp REQUIRED)
115+
find_package(XercesC MODULE REQUIRED)
156116
if(LIBCOSIM_WITH_PROXYFMU)
157117
find_package(PROXYFMU CONFIG REQUIRED)
158118
endif()
@@ -244,9 +204,6 @@ install(FILES "${versionFile}" DESTINATION "${LIBCOSIM_CMAKE_INSTALL_DIR}")
244204
# Install custom find modules
245205
install(FILES
246206
"${CMAKE_SOURCE_DIR}/cmake/FindFMILibrary.cmake"
247-
"${CMAKE_SOURCE_DIR}/cmake/FindLIBZIP.cmake"
248-
"${CMAKE_SOURCE_DIR}/cmake/FindMS_GSL.cmake"
249-
"${CMAKE_SOURCE_DIR}/cmake/FindYAML_CPP.cmake"
250207
DESTINATION
251208
"${LIBCOSIM_CMAKE_INSTALL_DIR}"
252209
)

0 commit comments

Comments
 (0)