diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0b1422066..d1f9b3aa4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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 }} \ No newline at end of file + run: cmake --install ${{ env.BUILD_DIR }} + + - name: Validate generated pkg-config file + 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 }}