Skip to content
Open
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
43 changes: 41 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,49 @@ jobs:
run: >-
ctest
--test-dir ${{ env.BUILD_DIR }}
--parallel
--parallel
--output-on-failure
--no-tests=error

- name: Install project
if: ${{ contains(matrix.build, 'cmake') }}
run: cmake --install ${{ env.BUILD_DIR }}
run: cmake --install ${{ env.BUILD_DIR }}

- name: Validate generated pkg-config file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @srinjoy933 . It is a nice improvment, and the paths are now checked.

In the past, we got some issues with the pkg-config files (e..g, issues with the order of the libs, ...; see e.g. #1102).
I wonder if it would be approriate to add a specific CI yml file for testing pkg-config files (even for compilation).

Copy link
Copy Markdown
Contributor Author

@srinjoy933 srinjoy933 Mar 25, 2026

Choose a reason for hiding this comment

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

Thank you @jvdp1 ! I completely agree. Setting up a dedicated .yml workflow that actually compiles a dummy Fortran program using the generated pkg-config flags is the best way to catch those linking order bugs like #1102.
Since this current PR is stable and successfully catches the basic path/double-prefixing errors, would you prefer to merge this ? I would be more than happy to open a fresh issue and a follow-up PR dedicated specifically to building out that standalone pkg-config compilation CI workflow.

if: ${{ matrix.build == 'cmake' }}
shell: bash
run: |
# 1. Dynamically find the directory containing the .pc file (handles lib vs lib64)
PC_FILE=$(find $PWD/_dist -name "fortran_stdlib.pc" | head -n 1)

if [ -z "$PC_FILE" ]; then
echo "Error: fortran_stdlib.pc was not found in the installation directory!"
exit 1
fi

PC_DIR=$(dirname "$PC_FILE")
export PKG_CONFIG_PATH="$PC_DIR:$PKG_CONFIG_PATH"
echo "Found pkg-config file in: $PC_DIR"

# 2. Check if the module can be found and the syntax is valid
pkg-config --validate fortran_stdlib

# 3. Extract the paths that pkg-config generated
LIB_DIR=$(pkg-config --variable=libdir fortran_stdlib)
INC_DIR=$(pkg-config --variable=includedir fortran_stdlib)

# 4. Verify the paths actually exist to catch double-prefixing
if [ ! -d "$LIB_DIR" ]; then
echo "Error: Library directory '$LIB_DIR' does not exist."
exit 1
fi

if [ ! -d "$INC_DIR" ]; then
echo "Error: Include directory '$INC_DIR' does not exist."
exit 1
fi

# 5. Print flags for debugging CI logs
echo "Resolved CFLAGS: $(pkg-config --cflags fortran_stdlib)"
echo "Resolved LIBS: $(pkg-config --libs fortran_stdlib)"
run: cmake --install ${{ env.BUILD_DIR }}
Loading