soci icon indicating copy to clipboard operation
soci copied to clipboard

Cmake policy CMP0074 and FindPostGreSQL.cmake

Open SylvainCorlay opened this issue 4 years ago • 5 comments

As of cmake 3.12, FindPackage cmake files should avoid making use of *_ROOT variables which are reserved.

CMake Warning (dev) at cmake/dependencies/PostgreSQL.cmake:3 (find_package):
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Environment variable PostgreSQL_ROOT is set to:

    C:\Miniconda\conda-bld\soci_1608410878219\_h_env\Library

  For compatibility, CMake is ignoring the variable.

SylvainCorlay avatar Dec 19 '20 21:12 SylvainCorlay

This is probably trivial to fix, but I avoid touching CMake as much as possible, so if anybody could provide a PR doing this, it would be welcome -- and I'd be glad to merge it. TIA!

vadz avatar Dec 23 '20 21:12 vadz

It turns out that the findPostgreSQL used by SOCI appears to be a slightly modified (or outdated) version of the one that is already included in core cmake. I wonder if there is a reason for not relying on the one maintained by Kitware in cmake.

SylvainCorlay avatar Dec 23 '20 21:12 SylvainCorlay

No idea. Maybe git log can find some answers...

vadz avatar Dec 23 '20 22:12 vadz

What about find_package(PostgreSQL)? https://cmake.org/cmake/help/v3.9/module/FindPostgreSQL.html It's what I'm using in xeus-sql and didn't have to create a find file for it.

marimeireles avatar Dec 29 '20 11:12 marimeireles

FWIW I've just tried updating the module used in SOCI to the latest version from CMake Git and it didn't work because it used select_library_configurations() which is not available in the CMake versions used. So I have no idea what can be done about it, nor why do we need to use our own version of this module at all instead of just using whichever one CMake provides.

It also seems completely broken to me, doing all kinds of complicated things instead of just using pg_config --includedir and --libdir to get the values it needs directly (and this still applies to the latest version as well). But I just can't bring myself to do anything about it, as it would take me days if not weeks to rewrite all this mess and life is too short to spend it on fighting with CMake.

vadz avatar Sep 14 '22 15:09 vadz