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

Add pkg-config file #53

Merged
merged 6 commits into from
Mar 13, 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
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
create-args: >-
make
cmake
pkg-config
fortran-compiler

- name: Make cmake build directory
Expand All @@ -42,14 +43,15 @@ jobs:
run: |
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_BUILD_TYPE=Release

- name: Build
- name: Build and install
working-directory: ${{ github.workspace }}/build
run: cmake --build . --target install --config Release

- name: Test
run: |
test -f $CONDA_PREFIX/include/bmif_$BMI_VERSION.mod
test -s $CONDA_PREFIX/lib/libbmif.a
pkg-config --exists --print-errors bmif

- name: Test (Linux)
if: matrix.os == 'ubuntu-latest'
Expand Down Expand Up @@ -78,6 +80,7 @@ jobs:
environment-name: testing
create-args: >-
cmake
pkg-config
cxx-compiler
init-shell: >-
powershell
Expand All @@ -98,6 +101,7 @@ jobs:
Test-Path -Path ${{ env.LIBRARY_PREFIX }}\lib\libbmif_win.dll.a
Test-Path -Path ${{ env.LIBRARY_PREFIX }}\bin\libbmif_win.dll
Test-Path -Path ${{ env.LIBRARY_PREFIX }}\include\bmif_${{ env.BMI_VERSION }}.mod
pkg-config --exists --print-errors bmif

- name: Test (for machines)
working-directory: ${{ github.workspace }}/build
Expand All @@ -106,3 +110,4 @@ jobs:
if ( -not ( Test-Path -Path ${{ env.LIBRARY_PREFIX }}\lib\libbmif_win.dll.a ) ){ exit 1 }
if ( -not ( Test-Path -Path ${{ env.LIBRARY_PREFIX }}\bin\libbmif_win.dll ) ){ exit 1 }
if ( -not ( Test-Path -Path ${{ env.LIBRARY_PREFIX }}\include\bmif_${{ env.BMI_VERSION }}.mod ) ){ exit 1 }
if ( -not ( Test-Path -Path ${{ env.LIBRARY_PREFIX }}\lib\pkgconfig\bmif.pc ) ){ exit 1 }
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ include(GNUInstallDirs)
set(mod_name "${CMAKE_PROJECT_NAME}_\
${CMAKE_PROJECT_VERSION_MAJOR}_${CMAKE_PROJECT_VERSION_MINOR}")

configure_file(
${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc.cmake
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc
@ONLY
)

# Create static and shared libraries.
set(static_lib ${CMAKE_PROJECT_NAME}_static)
set(shared_lib ${CMAKE_PROJECT_NAME}_shared)
Expand Down Expand Up @@ -49,3 +55,7 @@ install(
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Instructions are given below.
**Prerequisites:**
* A Fortran compiler
* CMake or [Fortran Package Manager](https://fpm.fortran-lang.org/)
* pkg-config

Alternately,
[conda binaries](https://anaconda.org/conda-forge/bmi-fortran)
Expand Down Expand Up @@ -52,7 +53,9 @@ The installation will look (on Linux) like:
| `-- bmif_2_0.mod
`-- lib
|-- libbmif.so -> libbmif.so.2.0
`-- libbmif.so.2.0
|-- libbmif.so.2.0
`-- pkgconfig
`-- bmif.pc
```

### CMake - Windows
Expand Down
11 changes: 11 additions & 0 deletions bmif.pc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: bmi-fortran
Description: The Basic Model Interface for Fortran
URL: https://bmi.readthedocs.io
Version: @CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@
Libs: -L${libdir} -l@CMAKE_PROJECT_NAME@
Cflags: -I${includedir}
Loading