meson: Add support for detecting ossp-uuid without pkg-config
authorAndres Freund <[email protected]>
Sat, 20 Jul 2024 20:51:08 +0000 (13:51 -0700)
committerAndres Freund <[email protected]>
Sat, 20 Jul 2024 20:51:14 +0000 (13:51 -0700)
This is necessary as ossp-uuid on windows installs neither a pkg-config nor a
cmake dependency information. Nor is there another supported uuid
implementation available on windows.

Reported-by: Dave Page <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Discussion: https://postgr.es/m/20240709065101[email protected]
Backpatch: 16-, where meson support was added

meson.build

index 78eec743aaae21854ec11868b6e7553ede6838b9..c09680f3838a15c016fc0aef3f1ba0cccce4fe04 100644 (file)
@@ -1386,9 +1386,26 @@ if uuidopt != 'none'
     uuidfunc = 'uuid_to_string'
     uuidheader = 'uuid.h'
   elif uuidopt == 'ossp'
-    uuid = dependency('ossp-uuid', required: true)
+    uuid = dependency('ossp-uuid', required: false)
     uuidfunc = 'uuid_export'
     uuidheader = 'uuid.h'
+
+    # Hardcoded lookup for ossp-uuid. This is necessary as ossp-uuid on
+    # windows installs neither a pkg-config nor a cmake dependency
+    # information. Nor is there another supported uuid implementation
+    # available on windows.
+    #
+    # Sometimes the ossp-uuid library is named 'uuid' sometimes 'ossp-uuid'
+    if not uuid.found()
+      uuid = cc.find_library('ossp-uuid',
+        required: false, dirs: test_lib_d,
+        has_headers: uuidheader, header_include_directories: postgres_inc)
+    endif
+    if not uuid.found()
+      uuid = cc.find_library('uuid',
+        required: true, dirs: test_lib_d,
+        has_headers: uuidheader, header_include_directories: postgres_inc)
+    endif
   else
     error('unknown uuid build option value: @0@'.format(uuidopt))
   endif