Skip to content

Commit

Permalink
Migrate to Conan 2 [skip appveyor]
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeu committed Nov 26, 2024
1 parent 9590362 commit 1e6d060
Show file tree
Hide file tree
Showing 11 changed files with 757 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .ci/conan_cppcheck_profile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[options]
matio/*:shared=False
matio/*:with_cppcheck=True
matio/*:with_hdf5=static
matio/*:with_zlib=static
4 changes: 4 additions & 0 deletions .ci/conan_static_profile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[options]
matio/*:shared=False
matio/*:with_hdf5=static
matio/*:with_zlib=static
17 changes: 12 additions & 5 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,27 @@ jobs:
if [ "${{ matrix.os }}" == "macos-latest" ]; then
echo "/Users/runner/Library/Python/${{ matrix.python-version }}/bin" >> $GITHUB_PATH
fi
pip install --disable-pip-version-check --user "conan>=1.62.0,<2"
pip install --disable-pip-version-check --user "conan>=2.9.3,<3"
- name: Cache conan folder
uses: actions/cache@v4
with:
path: ~/.conan2
key: ${{ runner.os }}-conan2-${{ hashFiles('conanfile.txt', 'conanfile.py', 'conan.lock') }}
restore-keys: |
${{ runner.os }}-conan2-
- name: Configure (${{ matrix.configuration }})
run: |
if [ "${{ matrix.os }}" == "macos-latest" ]; then
echo "/Users/runner/Library/Python/${{ matrix.python-version }}/bin" >> $GITHUB_PATH
fi
if [ "${{ matrix.compiler }}" == "msvc" ]; then
cmake -S . -B build -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF
cmake -S . -B build -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider -DCONAN_HOST_PROFILE="default;auto-cmake;${{ github.workspace }}/.ci/conan_static_profile.cmake" -DMATIO_SHARED=OFF
elif [ "${{ matrix.compiler }}" == "mingw" ]; then
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DMATIO_ENABLE_CPPCHECK=ON -G "MinGW Makefiles"
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider -DCONAN_HOST_PROFILE="default;auto-cmake;${{ github.workspace }}/.ci/conan_cppcheck_profile.cmake" -DMATIO_SHARED=OFF -DMATIO_ENABLE_CPPCHECK=ON -G "MinGW Makefiles"
elif [ "${{ matrix.compiler }}" == "gcc" ]; then
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DMATIO_ENABLE_CPPCHECK=ON
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider -DCONAN_HOST_PROFILE="default;auto-cmake;${{ github.workspace }}/.ci/conan_cppcheck_profile.cmake" -DMATIO_SHARED=OFF -DMATIO_ENABLE_CPPCHECK=ON
else
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider -DCONAN_HOST_PROFILE="default;auto-cmake;${{ github.workspace }}/.ci/conan_static_profile.cmake" -DMATIO_SHARED=OFF
fi
- name: Build with ${{ matrix.compiler }}
run: |
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

project(matio
VERSION 1.5.28
LANGUAGES C CXX
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ VS_FILES = visual_studio/libmatio/libmatio.vcproj \
visual_studio/stdint_msvc.h

CMAKE_FILES = CMakeLists.txt \
conanfile.py \
cmake/compilerOptions.cmake \
cmake/conan.cmake \
cmake/conan_provider.cmake \
cmake/getopt.cmake \
cmake/options.cmake \
cmake/src.cmake \
Expand Down
10 changes: 7 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ Table of Contents
The following matio specific options for building with CMake are
available.

* 'MATIO_USE_CONAN:BOOL=OFF'
This option enables the Conan package manager to resolve the
library dependencies. Only Conan 1.x is supported.
* 'MATIO_DEFAULT_FILE_VERSION:STRING=5'
This option sets the default MAT file version (4,5,7.3) that
will be used when writing.
Expand All @@ -205,6 +202,9 @@ Table of Contents
* 'MATIO_ENABLE_CPPCHECK:BOOL=OFF'
This option enables CMake >= 3.10 to perform static analysis
with Cppcheck.
* 'MATIO_USE_CONAN:BOOL=OFF'
This deprecated option enables the Conan 1.X package manager to
resolve the library dependencies.

To help CMake find the HDF5 libraries, set environment variable
HDF5_DIR to the 'cmake/hdf5' directory (containing 'hdf5-config.cmake')
Expand All @@ -216,6 +216,10 @@ Table of Contents
using CMake's built-in 'FindHDF5', especially for static builds.
CMake 3.10 or later is recommended.

For Conan 2.X as dependency provider call CMake with
`-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider`. CMake 3.24 or
later is required.

2.2.4 Visual Studio
Visual Studio solutions are provided as visual_studio/matio_vs2008.sln
for VS2008 and as visual_studio/matio.sln for VS2010 (and newer).
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ cmake --install .
```
The following matio specific options for building with CMake are available.

* `MATIO_USE_CONAN:BOOL=OFF`
This option enables the Conan package manager to resolve the library dependencies. Only Conan 1.x is supported.
* `MATIO_DEFAULT_FILE_VERSION:STRING=5`
This option sets the default MAT file version (4,5,7.3) that will be used when writing.
* `MATIO_EXTENDED_SPARSE:BOOL=ON`
Expand All @@ -143,9 +141,13 @@ This option enables CMake to check for availability of the zlib library (see sec
This option enables the matio testsuite for CTest.
* `MATIO_ENABLE_CPPCHECK:BOOL=OFF`
This option enables CMake &GreaterEqual; 3.10 to perform static analysis with Cppcheck.
* `MATIO_USE_CONAN:BOOL=OFF`
This deprecated option enables the Conan 1.X package manager to resolve the library dependencies.

To help CMake find the HDF5 libraries, set environment variable `HDF5_DIR` to the `cmake/hdf5` directory (containing `hdf5-config.cmake`) inside the HDF5 build or installation directory, or call cmake with `-DHDF5_DIR="dir/to/hdf5/cmake/hdf5"`. Alternatively call CMake with `-DCMAKE_PREFIX_PATH="dir/to/hdf5/cmake"`. See the [HDF5 instructions](https://support.hdfgroup.org/HDF5/release/cmakebuild.html#compile) for more information. Using `hdf5-config` is recommended over using CMake's built-in `FindHDF5`, especially for static builds. CMake 3.10 or later is recommended.

For Conan 2.X as dependency provider call CMake with `-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider`. CMake 3.24 or later is required.

#### 2.2.4 Visual Studio
Visual Studio solutions are provided as [matio_vs2008.sln](visual_studio/matio_vs2008.sln) for VS2008 and as [matio.sln](visual_studio/matio.sln) for VS2010 (and newer). The Debug and Release configurations of both solutions are set up to build a DLL of the matio library (libmatio.dll) and the matdump tool and assume HDF5 is available in the directory specified by the HDF5_DIR environment variable. It is assumed that the **shared** libraries of HDF5 (and zlib) are available. If the **static** libraries of HDF5 (and zlib) are installed/built the macro `H5_BUILT_AS_STATIC_LIB` needs to be defined (instead of `H5_BUILT_AS_DYNAMIC_LIB`). Furthermore, the Release Lib configuration of the VS2010 solution is set up to build a static LIB of the matio library (libmatio.lib) and assumes that the **static** libraries of HDF5 (and zlib) are installed/built.

Expand Down
Loading

0 comments on commit 1e6d060

Please sign in to comment.