Windows meson build

Started by Kohei Harikae (Fujitsu)about 1 year ago15 messages
#1Kohei Harikae (Fujitsu)
harikae.kohei@fujitsu.com
7 attachment(s)

Hi,

I do not use pkgconf in my Windows environment.
In my Windows environment, I could not build the following OSS with meson.
- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd

[1]: /messages/by-id/CA+OCxowQhMHFNRLTsXNuJpC96KRtSPHYKJuOS=b-Zrwmy-P4-g@mail.gmail.com
Would you like to be able to build OSS with Windows meson without using pkgconf?

[1]: /messages/by-id/CA+OCxowQhMHFNRLTsXNuJpC96KRtSPHYKJuOS=b-Zrwmy-P4-g@mail.gmail.com

Regards,
Kohei Harikae

Attachments:

0003-messon-libxslt.patchapplication/octet-stream; name=0003-messon-libxslt.patchDownload
diff --git a/meson.build b/meson.build
index 9a98f0c86a0..f7ddd75e9ce 100644
--- a/meson.build
+++ b/meson.build
@@ -876,10 +876,17 @@ endif
 
 libxsltopt = get_option('libxslt')
 if not libxsltopt.disabled()
-  libxslt = dependency('libxslt', required: false)
-  # Unfortunately the dependency is named differently with cmake
-  if not libxslt.found() # combine with above once meson 0.60.0 is required
-    libxslt = dependency('LibXslt', required: libxsltopt, method: 'cmake')
+  if host_system != 'windows'
+    libxslt = dependency('libxslt', required: false)
+    # Unfortunately the dependency is named differently with cmake
+    if not libxslt.found() # combine with above once meson 0.60.0 is required
+      libxslt = dependency('LibXslt', required: libxsltopt, method: 'cmake')
+    endif
+  else
+    libxslt = dependency('libxslt', required: false)
+    if not libxslt.found()
+      libxslt = cc.find_library('libxslt', required: libxsltopt, dirs: postgres_lib_d)
+    endif
   endif
 
   if libxslt.found()
0004-messon-lz4.patchapplication/octet-stream; name=0004-messon-lz4.patchDownload
diff --git a/meson.build b/meson.build
index 9a98f0c86a0..e40f95e79d8 100644
--- a/meson.build
+++ b/meson.build
@@ -897,12 +897,19 @@ endif
 
 lz4opt = get_option('lz4')
 if not lz4opt.disabled()
-  lz4 = dependency('liblz4', required: false)
-  # Unfortunately the dependency is named differently with cmake
-  if not lz4.found() # combine with above once meson 0.60.0 is required
-    lz4 = dependency('lz4', required: lz4opt,
-                     method: 'cmake', modules: ['LZ4::lz4_shared'],
-                    )
+  if host_system != 'windows'
+    lz4 = dependency('liblz4', required: false)
+    # Unfortunately the dependency is named differently with cmake
+    if not lz4.found() # combine with above once meson 0.60.0 is required
+      lz4 = dependency('lz4', required: lz4opt,
+                       method: 'cmake', modules: ['LZ4::lz4_shared'],
+                      )
+    endif
+  else
+    lz4 = dependency('liblz4', required: false)
+    if not lz4.found()
+      lz4 = cc.find_library('liblz4', required: lz4opt, dirs: postgres_lib_d)
+    endif
   endif
 
   if lz4.found()
0005-messon-tcl.patchapplication/octet-stream; name=0005-messon-tcl.patchDownload
diff --git a/meson.build b/meson.build
index 9a98f0c86a0..ff51fab280c 100644
--- a/meson.build
+++ b/meson.build
@@ -930,17 +930,24 @@ tcl_version = get_option('tcl_version')
 tcl_dep = not_found_dep
 if not tclopt.disabled()
 
-  # via pkg-config
-  tcl_dep = dependency(tcl_version, required: false)
+  if host_system != 'windows'
+    # via pkg-config
+    tcl_dep = dependency(tcl_version, required: false)
 
-  if not tcl_dep.found()
-    tcl_dep = cc.find_library(tcl_version,
-      required: tclopt,
-      dirs: test_lib_d)
-  endif
+    if not tcl_dep.found()
+      tcl_dep = cc.find_library(tcl_version,
+        required: tclopt,
+        dirs: test_lib_d)
+    endif
 
-  if not cc.has_header('tcl.h', dependencies: tcl_dep, required: tclopt)
-    tcl_dep = not_found_dep
+    if not cc.has_header('tcl.h', dependencies: tcl_dep, required: tclopt)
+      tcl_dep = not_found_dep
+    endif
+  else
+    tcl_dep = dependency(tcl_version, required: false)
+    if not tcl_dep.found()
+      tcl_dep = cc.find_library(tcl_version, required: tclopt, dirs: postgres_lib_d)
+    endif
   endif
 endif
 
0006-messon-zlib.patchapplication/octet-stream; name=0006-messon-zlib.patchDownload
diff --git a/meson.build b/meson.build
index 9a98f0c86a0..b9f907e808b 100644
--- a/meson.build
+++ b/meson.build
@@ -1470,7 +1470,14 @@ endif
 zlibopt = get_option('zlib')
 zlib = not_found_dep
 if not zlibopt.disabled()
-  zlib_t = dependency('zlib', required: zlibopt)
+  if host_system != 'windows'
+    zlib_t = dependency('zlib', required: zlibopt)
+  else
+    zlib_t = dependency('zlib', required: false)
+    if not zlib_t.found()
+      zlib_t = cc.find_library('zlib', required: zlibopt, dirs: postgres_lib_d)
+    endif
+  endif
 
   if zlib_t.type_name() == 'internal'
     # if fallback was used, we don't need to test if headers are present (they
0007-messon-zstd.patchapplication/octet-stream; name=0007-messon-zstd.patchDownload
diff --git a/meson.build b/meson.build
index 9a98f0c86a0..d302c67a861 100644
--- a/meson.build
+++ b/meson.build
@@ -1523,11 +1523,18 @@ endif
 
 zstdopt = get_option('zstd')
 if not zstdopt.disabled()
-  zstd = dependency('libzstd', required: false, version: '>=1.4.0')
-  # Unfortunately the dependency is named differently with cmake
-  if not zstd.found() # combine with above once meson 0.60.0 is required
-    zstd = dependency('zstd', required: zstdopt, version: '>=1.4.0',
-                      method: 'cmake', modules: ['zstd::libzstd_shared'])
+  if host_system != 'windows'
+    zstd = dependency('libzstd', required: false, version: '>=1.4.0')
+    # Unfortunately the dependency is named differently with cmake
+    if not zstd.found() # combine with above once meson 0.60.0 is required
+      zstd = dependency('zstd', required: zstdopt, version: '>=1.4.0',
+                        method: 'cmake', modules: ['zstd::libzstd_shared'])
+    endif
+  else
+    zstd = dependency('libzstd', required: false, version: '>=1.4.0')
+    if not zstd.found()
+      zstd = cc.find_library('libzstd', required: zstdopt, dirs: postgres_lib_d)
+    endif
   endif
 
   if zstd.found()
0002-meson-libxml.patchapplication/octet-stream; name=0002-meson-libxml.patchDownload
diff --git a/meson.build b/meson.build
index 9a98f0c86a0..9f4ab748023 100644
--- a/meson.build
+++ b/meson.build
@@ -854,13 +854,20 @@ endif
 
 libxmlopt = get_option('libxml')
 if not libxmlopt.disabled()
-  libxml = dependency('libxml-2.0', required: false, version: '>= 2.6.23')
-  # Unfortunately the dependency is named differently with cmake
-  if not libxml.found() # combine with above once meson 0.60.0 is required
-    libxml = dependency('LibXml2', required: libxmlopt, version: '>= 2.6.23',
-      method: 'cmake')
+  if host_system != 'windows'
+    libxml = dependency('libxml-2.0', required: false, version: '>= 2.6.23')
+    # Unfortunately the dependency is named differently with cmake
+    if not libxml.found() # combine with above once meson 0.60.0 is required
+      libxml = dependency('LibXml2', required: libxmlopt, version: '>= 2.6.23',
+        method: 'cmake')
+    endif
+  else
+    libxml = dependency('libxml2', required: false, version: '>= 2.6.23')
+    if not libxml.found()
+       libxml = cc.find_library('libxml2', required: libxmlopt, dirs: postgres_lib_d)
+    endif
   endif
-
+  
   if libxml.found()
     cdata.set('USE_LIBXML', 1)
   endif
0001-messon-icu.patchapplication/octet-stream; name=0001-messon-icu.patchDownload
diff --git a/meson.build b/meson.build
index 9a98f0c86a0..490932ce35b 100644
--- a/meson.build
+++ b/meson.build
@@ -819,19 +819,31 @@ endif
 ###############################################################
 
 icuopt = get_option('icu')
+icu_i18n = not_found_dep
 if not icuopt.disabled()
-  icu = dependency('icu-uc', required: false)
-  if icu.found()
-    icu_i18n = dependency('icu-i18n', required: true)
-  endif
-
-  # Unfortunately the dependency is named differently with cmake
-  if not icu.found() # combine with above once meson 0.60.0 is required
-    icu = dependency('ICU', required: icuopt,
-                     components: ['uc'], modules: ['ICU::uc'], method: 'cmake')
+  if host_system != 'windows'
+    icu = dependency('icu-uc', required: false)
     if icu.found()
-      icu_i18n = dependency('ICU', required: true,
-                            components: ['i18n'], modules: ['ICU::i18n'])
+      icu_i18n = dependency('icu-i18n', required: true)
+    endif
+
+    # Unfortunately the dependency is named differently with cmake
+    if not icu.found() # combine with above once meson 0.60.0 is required
+      icu = dependency('ICU', required: icuopt,
+                       components: ['uc'], modules: ['ICU::uc'], method: 'cmake')
+      if icu.found()
+        icu_i18n = dependency('ICU', required: true,
+                              components: ['i18n'], modules: ['ICU::i18n'])
+      endif
+    endif
+  else
+    icu = dependency('icuuc', required: false)
+    if not icu.found()
+       icu = cc.find_library('icuuc', required: icuopt, dirs: postgres_lib_d)
+    endif
+    icuin = dependency('icuin', required: false)
+    if not icuin.found()
+       icuin = cc.find_library('icuin', required: icuopt, dirs: postgres_lib_d)
     endif
   endif
 
@@ -844,6 +856,7 @@ if not icuopt.disabled()
 else
   icu = not_found_dep
   icu_i18n = not_found_dep
+  icuin = not_found_dep
 endif
 
 
@@ -3070,6 +3083,12 @@ backend_both_deps += [
   zstd,
 ]
 
+if host_system == 'windows'
+  backend_both_deps += [
+    icuin,
+  ]
+endif
+
 backend_mod_deps = backend_both_deps + os_deps
 
 backend_code = declare_dependency(
#2Peter Eisentraut
peter@eisentraut.org
In reply to: Kohei Harikae (Fujitsu) (#1)
Re: Windows meson build

On 05.11.24 07:32, Kohei Harikae (Fujitsu) wrote:

I do not use pkgconf in my Windows environment.
In my Windows environment, I could not build the following OSS with meson.
- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd

[1]thread, I created a patch like the one in the attached file, and now I can build.
Would you like to be able to build OSS with Windows meson without using pkgconf?

The problem I see with these patches is that they create a separate code
path for Windows. Right now, all platforms use the same code path for
discovering the dependencies, which is nice for maintainability.

So I suggest the solution here is for you to install pkgconf and use it.

#3Andres Freund
andres@anarazel.de
In reply to: Kohei Harikae (Fujitsu) (#1)
Re: Windows meson build

Hi,

On 2024-11-05 06:32:51 +0000, Kohei Harikae (Fujitsu) wrote:

I do not use pkgconf in my Windows environment.
In my Windows environment, I could not build the following OSS with meson.
- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd

[1]thread, I created a patch like the one in the attached file, and now I can build.
Would you like to be able to build OSS with Windows meson without using pkgconf?

You can use pkgconf or cmake for the dependencies. I don't want to add "raw"
dependency handling for every dependency, they each build in too many variants
for that to be a sensible investment of time.

Greetings,

Andres Freund

#4Kohei Harikae (Fujitsu)
harikae.kohei@fujitsu.com
In reply to: Andres Freund (#3)
RE: Windows meson build

Hi,

I apologize for this late reply.

As you advised, I was able to create the ".pc" file manually and set the dependencies using pkgconf.
Thank you.

However, I have read the PostgreSQL Documentation and did not realize that pkgconf is required.

17.4.3.2. PostgreSQL Features
-Dgssapi
On many systems, the GSSAPI system (a part of the MIT Kerberos installation) is not installed in a location that is searched by default (e.g., /usr/include, /usr/lib).
In those cases, PostgreSQL will query pkg-config to detect the required compiler and linker options.
-Dlibxml
To use a libxml2 installation that is in an unusual location, you can set pkg-config-related environment variables (see its documentation).

Only a few options have a pkg-config description.
It would be easier to understand pkg-config in the "17.4.3. meson setup Options" section.
Below is my proposal for the document description.
How do you think about this?

17.4.3. meson setup Options
PostgreSQL will query pkg-config to detect the required compiler and linker options.
To use module installed in an unusual location for each feature (e.g. -Dgssapi, -Dlibxml), set pkg-config-related environment variables (see its documentation).

Regards,
Kohei Harikae

-----Original Message-----
From: Andres Freund <andres@anarazel.de>
Sent: Thursday, November 7, 2024 4:05 AM
To: Harikae, Kohei/張替 浩平 <harikae.kohei@fujitsu.com>
Cc: 'pgsql-hackers@lists.postgresql.org' <pgsql-hackers@lists.postgresql.org>
Subject: Re: Windows meson build

Hi,

On 2024-11-05 06:32:51 +0000, Kohei Harikae (Fujitsu) wrote:

I do not use pkgconf in my Windows environment.
In my Windows environment, I could not build the following OSS with meson.
- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd

[1]thread, I created a patch like the one in the attached file, and now I can build.
Would you like to be able to build OSS with Windows meson without using pkgconf?

You can use pkgconf or cmake for the dependencies. I don't want to add "raw"
dependency handling for every dependency, they each build in too many variants for that to be a sensible investment of time.

Greetings,

Andres Freund

#5Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Kohei Harikae (Fujitsu) (#4)
Re: Windows meson build

Kohei Harikae (Fujitsu) писал(а) 2024-12-18 05:05:
Hi!

Hi,

I apologize for this late reply.

As you advised, I was able to create the ".pc" file manually and set
the dependencies using pkgconf.
Thank you.

However, I have read the PostgreSQL Documentation and did not realize
that pkgconf is required.

17.4.3.2. PostgreSQL Features
-Dgssapi
On many systems, the GSSAPI system (a part of the MIT Kerberos
installation) is not installed in a location that is searched by
default (e.g., /usr/include, /usr/lib).
In those cases, PostgreSQL will query pkg-config to detect the
required compiler and linker options.
-Dlibxml
To use a libxml2 installation that is in an unusual location, you can
set pkg-config-related environment variables (see its documentation).

Only a few options have a pkg-config description.
It would be easier to understand pkg-config in the "17.4.3. meson setup
Options" section.
Below is my proposal for the document description.
How do you think about this?

17.4.3. meson setup Options
PostgreSQL will query pkg-config to detect the required compiler and
linker options.
To use module installed in an unusual location for each feature (e.g.
-Dgssapi, -Dlibxml), set pkg-config-related environment variables (see
its documentation).

Meson has more straighforward solution. It uses environment variable
PKG_CONFIG_PATH, that can store the list of directories with all .pc
files. Meson uses this list and in this specific order to build project.
As wrote in meson documentation (in the source of open source project):
# Instead of relying on pkg-config or pkgconf to provide -L flags in a
# specific order, we reorder library paths ourselves, according to th
# order specified in PKG_CONFIG_PATH. See:
# https://github.com/mesonbuild/meson/issues/4271
#
It would be more clear information in PostgreSQL documentation, that all
directories with pc files are listed in one variable.

By the way, if you need to add , f.e. libxml library to postgreSQL
build, you can
1) build and install it using , f.e. vcpkg:
vcpkg install libxml2:windows-x64 --x-install-root=c:\pbuild\libxml2
2) add path to pc directory to PKG_CONFIG_PATH
SET
PKG_CONFIG_PATH=c:\pbuild\libxml2\winsows-x64\lib\pkgconfig;%PKG_CONFIG_PATH%
3) make steps with build
meson setup c:\builddir\... --prefix=c:\postgresdir\...

It is just one install and one manipulation with environment variable.
No indeterminate behaviour with other variables used by specific
packages and a libraries order.

Regards,
Kohei Harikae

-----Original Message-----
From: Andres Freund <andres@anarazel.de>
Sent: Thursday, November 7, 2024 4:05 AM
To: Harikae, Kohei/張替 浩平 <harikae.kohei@fujitsu.com>
Cc: 'pgsql-hackers@lists.postgresql.org'
<pgsql-hackers@lists.postgresql.org>
Subject: Re: Windows meson build

Hi,

On 2024-11-05 06:32:51 +0000, Kohei Harikae (Fujitsu) wrote:

I do not use pkgconf in my Windows environment.
In my Windows environment, I could not build the following OSS with
meson.
- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd

[1]thread, I created a patch like the one in the attached file, and
now I can build.
Would you like to be able to build OSS with Windows meson without
using pkgconf?

You can use pkgconf or cmake for the dependencies. I don't want to add
"raw"
dependency handling for every dependency, they each build in too many
variants for that to be a sensible investment of time.

Greetings,

Andres Freund

--
Best regards,

Vladlen Popolitov.

#6Kohei Harikae (Fujitsu)
harikae.kohei@fujitsu.com
In reply to: Vladlen Popolitov (#5)
1 attachment(s)
RE: Windows meson build

Hi,

Thank you for your advice.
I added a sample setting PKG_CONFIG_PATH based on your advice.

How do you think about this?

Regards,
Kohei Harikae

-----Original Message-----
From: Vladlen Popolitov <v.popolitov@postgrespro.ru>
Sent: Wednesday, December 25, 2024 7:28 PM
To: Harikae, Kohei/張替 浩平 <harikae.kohei@fujitsu.com>
Cc: 'Andres Freund' <andres@anarazel.de>; 'pgsql-hackers@lists.postgresql.org' <pgsql-hackers@lists.postgresql.org>
Subject: Re: Windows meson build

Kohei Harikae (Fujitsu) писал(а) 2024-12-18 05:05:
Hi!

Hi,

I apologize for this late reply.

As you advised, I was able to create the ".pc" file manually and set
the dependencies using pkgconf.
Thank you.

However, I have read the PostgreSQL Documentation and did not realize
that pkgconf is required.

17.4.3.2. PostgreSQL Features
-Dgssapi
On many systems, the GSSAPI system (a part of the MIT Kerberos
installation) is not installed in a location that is searched by
default (e.g., /usr/include, /usr/lib).
In those cases, PostgreSQL will query pkg-config to detect the
required compiler and linker options.
-Dlibxml
To use a libxml2 installation that is in an unusual location, you
can set pkg-config-related environment variables (see its documentation).

Only a few options have a pkg-config description.
It would be easier to understand pkg-config in the "17.4.3. meson
setup Options" section.
Below is my proposal for the document description.
How do you think about this?

17.4.3. meson setup Options
PostgreSQL will query pkg-config to detect the required compiler and
linker options.
To use module installed in an unusual location for each feature (e.g.
-Dgssapi, -Dlibxml), set pkg-config-related environment variables (see
its documentation).

Meson has more straighforward solution. It uses environment variable PKG_CONFIG_PATH, that can store the list of directories with all .pc files. Meson uses this list and in this specific order to build project.
As wrote in meson documentation (in the source of open source project):
# Instead of relying on pkg-config or pkgconf to provide -L flags in a # specific order, we reorder library paths ourselves, according to th # order specified in PKG_CONFIG_PATH. See:
# https://github.com/mesonbuild/meson/issues/4271
#
It would be more clear information in PostgreSQL documentation, that all directories with pc files are listed in one variable.

By the way, if you need to add , f.e. libxml library to postgreSQL build, you can
1) build and install it using , f.e. vcpkg:
vcpkg install libxml2:windows-x64 --x-install-root=c:\pbuild\libxml2
2) add path to pc directory to PKG_CONFIG_PATH
SET
PKG_CONFIG_PATH=c:\pbuild\libxml2\winsows-x64\lib\pkgconfig;%PKG_CONFIG_PATH%
3) make steps with build
meson setup c:\builddir\... --prefix=c:\postgresdir\...

It is just one install and one manipulation with environment variable.
No indeterminate behaviour with other variables used by specific packages and a libraries order.

Regards,
Kohei Harikae

-----Original Message-----
From: Andres Freund <andres@anarazel.de>
Sent: Thursday, November 7, 2024 4:05 AM
To: Harikae, Kohei/張替 浩平 <harikae.kohei@fujitsu.com>
Cc: 'pgsql-hackers@lists.postgresql.org'
<pgsql-hackers@lists.postgresql.org>
Subject: Re: Windows meson build

Hi,

On 2024-11-05 06:32:51 +0000, Kohei Harikae (Fujitsu) wrote:

I do not use pkgconf in my Windows environment.
In my Windows environment, I could not build the following OSS with
meson.
- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd

[1]thread, I created a patch like the one in the attached file, and
now I can build.
Would you like to be able to build OSS with Windows meson without
using pkgconf?

You can use pkgconf or cmake for the dependencies. I don't want to
add "raw"
dependency handling for every dependency, they each build in too many
variants for that to be a sensible investment of time.

Greetings,

Andres Freund

--
Best regards,

Vladlen Popolitov.

Attachments:

installation-meson.patchapplication/octet-stream; name=installation-meson.patchDownload
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index ebdb5b3bc2d..c583c256858 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -2463,12 +2463,7 @@ ninja install
       <listitem>
        <para>
         Build with support for GSSAPI authentication. MIT Kerberos is required
-        to be installed for GSSAPI.  On many systems, the GSSAPI system (a part
-        of the MIT Kerberos installation) is not installed in a location
-        that is searched by default (e.g., <filename>/usr/include</filename>,
-        <filename>/usr/lib</filename>).  In
-        those cases, PostgreSQL will query <command>pkg-config</command> to
-        detect the required compiler and linker options.  Defaults to auto.
+        to be installed for GSSAPI.  Defaults to auto.
         <filename>meson configure</filename> will check for the required
         header files and libraries to make sure that your GSSAPI installation
         is sufficient before proceeding.
@@ -2589,12 +2584,6 @@ ninja install
         Build with libxml2, enabling SQL/XML support.  Defaults to
         auto. Libxml2 version 2.6.23 or later is required for this feature.
        </para>
-
-       <para>
-        To use a libxml2 installation that is in an unusual location, you
-        can set <command>pkg-config</command>-related environment
-        variables (see its documentation).
-       </para>
       </listitem>
      </varlistentry>
 
@@ -3174,6 +3163,43 @@ ninja install
    &targets-meson;
   </sect2>
 
+  <sect2 id="use-unusual-location-libraries-meson">
+   <title>Steps to use libraries installed in an unusual location</title>
+
+   <para>
+    PostgreSQL will query pkg-config to detect the required compiler and linker options.
+    To use modules installed in an unusual location, set pkg-config-related
+    environment variables (see its documentation). For example, if you want to add
+    the library to the PostgreSQL build, add the directory where the .pc file resides
+    to PKG_CONFIG_PATH.
+
+    Sample procedures to include libraries for PostgreSQL build are as follows:
+   </para>
+   
+    <procedure>
+    <step id="sample-build-library">
+     <title>Building and Installation library</title>
+     <para>
+      Check the path where the .pc file (e.g.libxml-2.0.pc) is created.
+     </para>
+    </step>
+    <step id="sample-add-PKG_CONFIG_PATH">
+     <title>Add path to .pc directory to PKG_CONFIG_PATH</title>
+     <para>
+     </para>
+    </step>
+    <step id="sample-build-meson">
+     <title>Building and Installation PostgreSQL with Meson</title>
+     <para>
+<screen>
+<userinput>meson setup build</userinput>
+</screen>
+     </para>
+    </step>
+    </procedure>
+   
+  </sect2>
+
  </sect1>
 
  <sect1 id="install-post">
#7Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Kohei Harikae (Fujitsu) (#6)
Re: Windows meson build

Kohei Harikae (Fujitsu) писал(а) 2024-12-27 04:31:

Hi,

Thank you for your advice.
I added a sample setting PKG_CONFIG_PATH based on your advice.

How do you think about this?

Regards,
Kohei Harikae

Hi,
From my point of view it looks good. Actual information is added,
excessive information is removed.
I think in the phrase:
"add the directory where the .pc file resides to PKG_CONFIG_PATH."
better to add wording, that PKG_CONFIG_PATH is the list of directories
separated
by PATH separator ( ; in Windows, : in POSIX). Otherwise the reader has
to
search additional information about this variable in meson
documentation.

--
Best regards,

Vladlen Popolitov.

#8Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Vladlen Popolitov (#7)
Re: Windows meson build

Vladlen Popolitov писал(а) 2024-12-27 09:57:

Kohei Harikae (Fujitsu) писал(а) 2024-12-27 04:31:

Hi,

Thank you for your advice.
I added a sample setting PKG_CONFIG_PATH based on your advice.

How do you think about this?

Regards,
Kohei Harikae

Hi,
From my point of view it looks good. Actual information is added,
excessive information is removed.
I think in the phrase:
"add the directory where the .pc file resides to PKG_CONFIG_PATH."
better to add wording, that PKG_CONFIG_PATH is the list of directories
separated
by PATH separator ( ; in Windows, : in POSIX). Otherwise the reader has
to
search additional information about this variable in meson
documentation.

Hi

I think, it is better to add the other options how to configure external
libraries, if they do not have .pc file:
add meson options defined by PostgreSQL for its configuration (gettext
library example)

-Dextra_include_dirs=c:\postgres\gettext\x64-windows\include,c:\otherlibs\include
-Dextra_lib_dirs=c:\postgres\gettext\x64-windows\lib,c:\otherlibs\lib

extra_include_dirs and extra_lib_dirs are options defined by PostgreSQL.
This options are
comma separated lists of directories, if every value does not contain
comma itself.

--
Best regards,

Vladlen Popolitov.

#9Kohei Harikae (Fujitsu)
harikae.kohei@fujitsu.com
In reply to: Vladlen Popolitov (#8)
1 attachment(s)
RE: Windows meson build

Hi,

I think in the phrase:
"add the directory where the .pc file resides to PKG_CONFIG_PATH."
better to add wording, that PKG_CONFIG_PATH is the list of directories
separated by PATH separator ( ; in Windows, : in POSIX). Otherwise the
reader has to search additional information about this variable in
meson documentation.

Thank you for your advice.
I added the description of PATH separator based on your advice.

I think, it is better to add the other options how to configure external
libraries, if they do not have .pc file:
add meson options defined by PostgreSQL for its configuration (gettext
library example)

-Dextra_include_dirs=c:\postgres\gettext\x64-windows\include,c:\otherlibs\include
-Dextra_lib_dirs=c:\postgres\gettext\x64-windows\lib,c:\otherlibs\lib

extra_include_dirs and extra_lib_dirs are options defined by PostgreSQL.
This options are
comma separated lists of directories, if every value does not contain
comma itself.

- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd
These libraries could not be built by setting extra_include_dirs and extra_lib_dirs.
These libraries may not have .pc file created.
For example, if I use msc (Visual Studio) to build zLib, zlib.pc is not created.
Could you tell me which libraries can use this option?

Regards,
Kohei Harikae

Attachments:

installation-meson.patchapplication/octet-stream; name=installation-meson.patchDownload
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index ebdb5b3bc2d..cecf02fa5e5 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -2463,12 +2463,7 @@ ninja install
       <listitem>
        <para>
         Build with support for GSSAPI authentication. MIT Kerberos is required
-        to be installed for GSSAPI.  On many systems, the GSSAPI system (a part
-        of the MIT Kerberos installation) is not installed in a location
-        that is searched by default (e.g., <filename>/usr/include</filename>,
-        <filename>/usr/lib</filename>).  In
-        those cases, PostgreSQL will query <command>pkg-config</command> to
-        detect the required compiler and linker options.  Defaults to auto.
+        to be installed for GSSAPI.  Defaults to auto.
         <filename>meson configure</filename> will check for the required
         header files and libraries to make sure that your GSSAPI installation
         is sufficient before proceeding.
@@ -2589,12 +2584,6 @@ ninja install
         Build with libxml2, enabling SQL/XML support.  Defaults to
         auto. Libxml2 version 2.6.23 or later is required for this feature.
        </para>
-
-       <para>
-        To use a libxml2 installation that is in an unusual location, you
-        can set <command>pkg-config</command>-related environment
-        variables (see its documentation).
-       </para>
       </listitem>
      </varlistentry>
 
@@ -3174,6 +3163,45 @@ ninja install
    &targets-meson;
   </sect2>
 
+  <sect2 id="use-unusual-location-libraries-meson">
+   <title>Steps to use libraries installed in an unusual location</title>
+
+   <para>
+    PostgreSQL will query pkg-config to detect the required compiler and linker options.
+    To use modules installed in an unusual location, set pkg-config-related
+    environment variables (see its documentation). For example, if you want to add
+    the library to the PostgreSQL build, add the directory where the .pc file resides
+    to PKG_CONFIG_PATH.
+
+    Sample procedures to include libraries for PostgreSQL build are as follows:
+   </para>
+   
+    <procedure>
+    <step id="sample-build-library">
+     <title>Building and Installation library</title>
+     <para>
+      Check the path where the .pc file (e.g.libxml-2.0.pc) is created.
+     </para>
+    </step>
+    <step id="sample-add-PKG_CONFIG_PATH">
+     <title>Add path to .pc directory to PKG_CONFIG_PATH</title>
+     <para>
+      PKG_CONFIG_PATH is the list of directories separated by PATH separator
+       ( ; in Windows, : in Unix). 
+     </para>
+    </step>
+    <step id="sample-build-meson">
+     <title>Building and Installation PostgreSQL with Meson</title>
+     <para>
+<screen>
+<userinput>meson setup build</userinput>
+</screen>
+     </para>
+    </step>
+    </procedure>
+   
+  </sect2>
+
  </sect1>
 
  <sect1 id="install-post">
#10Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Kohei Harikae (Fujitsu) (#9)
Re: Windows meson build

Kohei Harikae (Fujitsu) писал(а) 2025-01-06 16:57:

Hi,

- 0001 icu
- 0002 libxml
- 0003 libxslt
- 0004 lz4
- 0005 tcl
- 0006 zlib
- 0007 zstd
These libraries could not be built by setting extra_include_dirs and
extra_lib_dirs.
These libraries may not have .pc file created.
For example, if I use msc (Visual Studio) to build zLib, zlib.pc is not
created.
Could you tell me which libraries can use this option?

Regards,
Kohei Harikae

Hi!

I don't have my Windows PC near me just now, I take information from my
memory regarding these
libraries.

I use Windows package manager vcpkg to build these libraries, and vcpkg
uses msvc (Visual Studio).
As I remember, icu, libxml2, libxslt build by vcpkg have .pc file.
Really pc file is easy to
create by hands the text file with
a) product name and version
b) relative (from .pc file location) path to libs
c) relative path to includes
Libraries with .pc file can be listed in environment variable
PKG_CONFIG_PATH.

gettext does not have pc file, and lib and include location must be
included in extra_include_dirs
and extra_lib_dirs options, that are PostgreSQL options in meson (not
meson itself options) added
for libraries without .pc file.

Steps to build PostgreSQL under Windsows using meson and vcpkg
1) create build.cmd for all commands
2) install vcpkg to any location (except network drive, it has problems
with it. Hard drive C: is OK)
3) install all libraries:
vcpkg install libxml2
etc...
4) look for all libraries lib/pkgconf library and find .pc file. All pc
file paths add to
SET PKG_CONFIG_PATH=... in build.cmd
5) all libraries without pc file - add to -Dextra_include_dirs= and
-Dextra_lib_dirs for meson command,
that prepares the build directory - add it to build.cmd
6) add in the beginning build.cmd this or correct path for your system
call "C:\Program Files\Microsoft Visual
Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
7) run build.cmd

This library configuration should work. I recommend install libraries to
special location for every
build version to control exact location and library version. vcpkg has
options for library version
and install directory.

--
Best regards,

Vladlen Popolitov.

#11Kohei Harikae (Fujitsu)
harikae.kohei@fujitsu.com
In reply to: Vladlen Popolitov (#10)
1 attachment(s)
RE: Windows meson build

Hi,

Thank you for your advice.
Based on your advice, I have added a description of the vcpkg and -Dextra_include_dirs options.
How do you think about this?

Regards,
Kohei Harikae

Attachments:

installation-meson.patchapplication/octet-stream; name=installation-meson.patchDownload
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index ebdb5b3bc2d..523dba03b5b 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -2463,12 +2463,7 @@ ninja install
       <listitem>
        <para>
         Build with support for GSSAPI authentication. MIT Kerberos is required
-        to be installed for GSSAPI.  On many systems, the GSSAPI system (a part
-        of the MIT Kerberos installation) is not installed in a location
-        that is searched by default (e.g., <filename>/usr/include</filename>,
-        <filename>/usr/lib</filename>).  In
-        those cases, PostgreSQL will query <command>pkg-config</command> to
-        detect the required compiler and linker options.  Defaults to auto.
+        to be installed for GSSAPI.  Defaults to auto.
         <filename>meson configure</filename> will check for the required
         header files and libraries to make sure that your GSSAPI installation
         is sufficient before proceeding.
@@ -2589,12 +2584,6 @@ ninja install
         Build with libxml2, enabling SQL/XML support.  Defaults to
         auto. Libxml2 version 2.6.23 or later is required for this feature.
        </para>
-
-       <para>
-        To use a libxml2 installation that is in an unusual location, you
-        can set <command>pkg-config</command>-related environment
-        variables (see its documentation).
-       </para>
       </listitem>
      </varlistentry>
 
@@ -3174,6 +3163,50 @@ ninja install
    &targets-meson;
   </sect2>
 
+  <sect2 id="use-unusual-location-libraries-meson">
+   <title>Steps to use libraries installed in an unusual location</title>
+
+   <para>
+    PostgreSQL will query pkg-config to detect the required compiler and linker options.
+    To use modules installed in an unusual location, set pkg-config-related
+    environment variables (see its documentation). For example, if you want to add
+    the library to the PostgreSQL build, add the directory where the .pc file resides
+    to PKG_CONFIG_PATH.
+
+    Sample procedures to include libraries for PostgreSQL build are as follows:
+   </para>
+   
+    <procedure>
+    <step id="sample-build-library">
+     <title>Building and Installation library</title>
+     <para>
+      Check the path where the .pc file (e.g.libxml-2.0.pc) is created.
+      Many libraries create the .pc files when built using vcpkg.
+      You might want to create the .pc file manually.
+     </para>
+    </step>
+    <step id="sample-add-PKG_CONFIG_PATH">
+     <title>Add path to .pc directory to PKG_CONFIG_PATH</title>
+     <para>
+      PKG_CONFIG_PATH is the list of directories separated by PATH separator
+       ( ; in Windows, : in Unix). 
+     </para>
+    </step>
+    <step id="sample-build-meson">
+     <title>Building and Installation PostgreSQL with Meson</title>
+     <para>
+<screen>
+<userinput>meson setup build</userinput>
+</screen>
+      For some libraries (e.g. .pc file not created gettext), 
+      the path can be specified with the 
+      -Dextra_include_dirs, -Dextra_lib_dirs option.
+     </para>
+    </step>
+    </procedure>
+   
+  </sect2>
+
  </sect1>
 
  <sect1 id="install-post">
#12Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Kohei Harikae (Fujitsu) (#11)
Re: Windows meson build

Kohei Harikae (Fujitsu) писал(а) 2025-01-10 16:43:

Hi,

Thank you for your advice.
Based on your advice, I have added a description of the vcpkg and
-Dextra_include_dirs options.
How do you think about this?

Regards,
Kohei Harikae

Hi,

Looks good! If you create commitfest entry, I would make review.

--
Best regards,

Vladlen Popolitov.

#13Kohei Harikae (Fujitsu)
harikae.kohei@fujitsu.com
In reply to: Vladlen Popolitov (#12)
1 attachment(s)
RE: Windows meson build

Hi,

My previous patch had whitespace issues.
I recreated the patch.
I will create a commitfest with this patch.

Regards,
Kohei Harikae

Attachments:

installation-meson.patchapplication/octet-stream; name=installation-meson.patchDownload
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 271615e4a65..46ad83a7dae 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -2463,12 +2463,7 @@ ninja install
       <listitem>
        <para>
         Build with support for GSSAPI authentication. MIT Kerberos is required
-        to be installed for GSSAPI.  On many systems, the GSSAPI system (a part
-        of the MIT Kerberos installation) is not installed in a location
-        that is searched by default (e.g., <filename>/usr/include</filename>,
-        <filename>/usr/lib</filename>).  In
-        those cases, PostgreSQL will query <command>pkg-config</command> to
-        detect the required compiler and linker options.  Defaults to auto.
+        to be installed for GSSAPI.  Defaults to auto.
         <filename>meson configure</filename> will check for the required
         header files and libraries to make sure that your GSSAPI installation
         is sufficient before proceeding.
@@ -2589,12 +2584,6 @@ ninja install
         Build with libxml2, enabling SQL/XML support.  Defaults to
         auto. Libxml2 version 2.6.23 or later is required for this feature.
        </para>
-
-       <para>
-        To use a libxml2 installation that is in an unusual location, you
-        can set <command>pkg-config</command>-related environment
-        variables (see its documentation).
-       </para>
       </listitem>
      </varlistentry>
 
@@ -3174,6 +3163,50 @@ ninja install
    &targets-meson;
   </sect2>
 
+  <sect2 id="use-unusual-location-libraries-meson">
+   <title>Steps to use libraries installed in an unusual location</title>
+
+   <para>
+    PostgreSQL will query pkg-config to detect the required compiler and linker options.
+    To use modules installed in an unusual location, set pkg-config-related
+    environment variables (see its documentation). For example, if you want to add
+    the library to the PostgreSQL build, add the directory where the .pc file resides
+    to PKG_CONFIG_PATH.
+
+    Sample procedures to include libraries for PostgreSQL build are as follows:
+   </para>
+
+    <procedure>
+    <step id="sample-build-library">
+     <title>Building and Installation library</title>
+     <para>
+      Check the path where the .pc file (e.g.libxml-2.0.pc) is created.
+      Many libraries create the .pc files when built using vcpkg.
+      You might want to create the .pc file manually.
+     </para>
+    </step>
+    <step id="sample-add-PKG_CONFIG_PATH">
+     <title>Add path to .pc directory to PKG_CONFIG_PATH</title>
+     <para>
+      PKG_CONFIG_PATH is the list of directories separated by PATH separator
+       ( ; in Windows, : in Unix).
+     </para>
+    </step>
+    <step id="sample-build-meson">
+     <title>Building and Installation PostgreSQL with Meson</title>
+     <para>
+<screen>
+<userinput>meson setup build</userinput>
+</screen>
+      For some libraries (e.g. .pc file not created gettext),
+      the path can be specified with the
+      -Dextra_include_dirs, -Dextra_lib_dirs option.
+     </para>
+    </step>
+    </procedure>
+
+  </sect2>
+
  </sect1>
 
  <sect1 id="install-post">
#14Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Kohei Harikae (Fujitsu) (#13)
Re: Windows meson build

The following review has been posted through the commitfest application:
make installcheck-world: tested, failed
Implements feature: tested, failed
Spec compliant: tested, failed
Documentation: tested, failed

Hi!

This patch clarify the options used by meson to build PostgreSQL, how
to included libraries and include files from dependencies:
1) environment variable PKG_CONFIG_PATH
2) options -Dextra_include_dirs= and -Dextra_lib_dirs
This information useful for Windows builds and any other system,
where meson build is used.

+1 for commit

The new status of this patch is: Ready for Committer

#15Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Vladlen Popolitov (#14)
Re: Windows meson build

Vladlen Popolitov писал(а) 2025-02-13 17:58:

The following review has been posted through the commitfest
application:
make installcheck-world: tested, failed
Implements feature: tested, failed
Spec compliant: tested, failed
Documentation: tested, failed

Hi!

Previous email has text "failed". It is generated by "send review"
function,
I do not know, how to change it (tried in other browsers).

Nothing failed in this patch.

--
Best regards,

Vladlen Popolitov.