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

CMake does not find PostgreSQL anymore #4243

Closed
2 of 8 tasks
d-frey opened this issue Oct 8, 2021 · 14 comments
Closed
2 of 8 tasks

CMake does not find PostgreSQL anymore #4243

d-frey opened this issue Oct 8, 2021 · 14 comments
Assignees
Labels

Comments

@d-frey
Copy link

d-frey commented Oct 8, 2021

Description

About 2 days ago, CMake stopped finding PostgreSQL in the system. I have changed some source code, then reverted it back. But the build fails before even trying to compile my code, so from my perspective it has to be some change in the virtual environment.

Virtual environments affected

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11
  • Windows Server 2016
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Failing builds

Windows Server 2019

https://github.com/taocpp/taopq/runs/3842056429?check_suite_focus=true
Version: 20211003.2

Windows Server 2016

https://github.com/taocpp/taopq/runs/3842056518?check_suite_focus=true
Version: 20211003.1

Working builds, 2 days ago

Windows Server 2019

https://github.com/taocpp/taopq/runs/3820206113?check_suite_focus=true
Version: 20210928.2

Windows Server 2016

https://github.com/taocpp/taopq/runs/3820205739?check_suite_focus=true
Version: 20210927.1

Is it regression?

Yes.

Working 2 days ago: https://github.com/taocpp/taopq/actions/runs/1313629530

Expected behavior

Just like 2 days ago, PostgreSQL should be found by CMake.

Actual behavior

CMake fails to find PostgreSQL with

-- Detecting CXX compile features - done
CMake Error at C:/Program Files/CMake/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY) (found version
-- Configuring incomplete, errors occurred!
See also "D:/a/taopq/taopq/build/CMakeFiles/CMakeOutput.log".
  "11.3")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.21/Modules/FindPostgreSQL.cmake:269 (find_package_handle_standard_args)
  CMakeLists.txt:7 (find_package)

Repro steps

Run the CI jobs.

@miketimofeev
Copy link
Contributor

Hi @d-frey!
The Postgres version was updated from 13 to 14 across all the images. Most likely your issue is related to that.

@d-frey
Copy link
Author

d-frey commented Oct 8, 2021

I do not require any specific version, I just use find_package(PostgreSQL REQUIRED).

If PostgreSQL version 14 is installed correctly, it should be found just like version 13 before, right? (Again, CMake fails before it even tries to compile my code)

@miketimofeev
Copy link
Contributor

We haven't changed the installation process. Is there a possibility that find_package(PostgreSQL REQUIRED) is not adapted for Postgre14?

@d-frey
Copy link
Author

d-frey commented Oct 8, 2021

I don't know. I just use this one line find_package(PostgreSQL REQUIRED) in the main CMakeLists.txt and that is where it fails (as can be seen by the error message). The rest is coming from the image AFAICT.

@wojsmol
Copy link

wojsmol commented Oct 8, 2021

Short googling bring this documentation of find_package

@d-frey
Copy link
Author

d-frey commented Oct 8, 2021

OK, but do you expect me to do anything about it? Both PostgreSQL and CMake are part of the image. Previously, CMake was able to find the installed PostgreSQL libraries, now it is not. Whoever is building the image needs to fix that.

Note that I am not a Windows user myself, so I can't really test/debug anything when it comes to the Windows images. I need CMake to "just work", otherwise I won't be able to support Windows for my open-source libraries.

@d-frey
Copy link
Author

d-frey commented Oct 8, 2021

BTW: What looks really weird to me is the part of the error message where it seems to find an older version of PostgreSQL:

  Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY) (found version
-- Configuring incomplete, errors occurred!
See also "D:/a/taopq/taopq/build/CMakeFiles/CMakeOutput.log".
  "11.3")

It looks like the first and the last line belong together, so it is effectively trying to say

  Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY) (found version "11.3")

Which is a bit self-contradictory. If it found version "11.3", then why does it say it could NOT find PostgreSQL? Maybe that might help someone to debug the issue.

@wojsmol
Copy link

wojsmol commented Oct 8, 2021

@d-frey I'm not CMake expert - maybe this will help virtual environments people to help you.

@wojsmol
Copy link

wojsmol commented Oct 8, 2021

D:/a/taopq/taopq/build/CMakeFiles/CMakeOutput.log - personalty I will try use actions/upload-artifact to get that log.

@dibir-magomedsaygitov dibir-magomedsaygitov added OS: Windows investigate Collect additional information, like space on disk, other tool incompatibilities etc. Area: C/C++ and removed needs triage labels Oct 9, 2021
@mikhailkoliada
Copy link
Contributor

There is a bug in the FindPostgreSQL of cmake that I suggest reporting upstream. Downgrading to postgresql13 helps

The workaround would be the following workflow:

name: PostgreSQL cmake test
on: [push]

jobs:
    Workaround-PostgreSQL:
        runs-on: windows-latest
        steps:
            - name: remove currently installed version
              run: choco uninstall postgresql
            - name: install Postgresql 13
              run: choco install postgresql13 -y
            - name: checkout repo
              uses: actions/checkout@v2
            - name: run cmake configure
              run: cmake .
            - name: setup environment and show env variables
              run: |
                  $env:PGROOT='C:\Program Files\PostgreSQL\13'
                  $env:PGBIN='C:\Program Files\PostgreSQL\13\bin'
                  $env:PGDATA='C:\Program Files\PostgreSQL\13\data'
                  echo $env:PGROOT
                  echo $env:PGBIN
                  echo $env:PGDATA
              shell: powershell

I've tested it on a pretty primitive CMakeLists.txt file and it works just fine:

cmake_minimum_required(VERSION 3.0)
project(pgtest)
find_package(PostgreSQL REQUIRED)

d-frey added a commit to taocpp/taopq that referenced this issue Oct 12, 2021
@d-frey
Copy link
Author

d-frey commented Oct 12, 2021

Thank you for investigating! You mentioned that you have found a bug. What is the bug and did you report it upstream?

I tried the workaround, but it does not seem to be compatible with the old installation, as now some other error comes up. I would appreciate any hint.

@d-frey
Copy link
Author

d-frey commented Oct 13, 2021

For the record: This commit taocpp/taopq@ae5171f from @uilianries is a much easier workaround that allows to use PostgreSQL 14 with CMake.

@mikhailkoliada
Copy link
Contributor

I've reported this upstream anyway. As the entire situation looks weird to me

@miketimofeev miketimofeev added bug Something isn't working external and removed investigate Collect additional information, like space on disk, other tool incompatibilities etc. labels Oct 14, 2021
@mikhailkoliada
Copy link
Contributor

As the bug has been reported I am going to close the issue right now (as we have no idea by which time the cmake developers are going to fix the problem). Feel free to file a new issue if you have additional questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants