Unverified Commit e8678650 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

saga: Fix compiling on Darwin (#384655)

parents db54ea84 6e27715c
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
commit 3bbd15676dfc077d7836e9d51810c1d6731f5789
Author: Palmer Cox <p@lmercox.com>
Date:   Sun Feb 23 16:41:18 2025 -0500

    Fix copy/paste error in FindPostgres.cmake
    
    In f51c6b1513e312002c108fe87d26e33c48671406, EXEC_PROGRAM was changed to
    execute_process. As part of that, it looks like the second and third
    invocations were accidentally changed.

diff --git a/saga-gis/cmake/modules/FindPostgres.cmake b/saga-gis/cmake/modules/FindPostgres.cmake
index f22806fd9..a4b6ec9ac 100644
--- a/cmake/modules/FindPostgres.cmake
+++ b/cmake/modules/FindPostgres.cmake
@@ -77,13 +77,13 @@ ELSE(WIN32)
       SET(POSTGRES_INCLUDE_DIR ${PG_TMP} CACHE STRING INTERNAL)
 
       # set LIBRARY_DIR
-      execute_process(COMMAND ${POSTGRES_CONFIG} --includedir
+      execute_process(COMMAND ${POSTGRES_CONFIG} --libdir
         OUTPUT_VARIABLE PG_TMP
         OUTPUT_STRIP_TRAILING_WHITESPACE)
       IF (APPLE)
         SET(POSTGRES_LIBRARY ${PG_TMP}/libpq.dylib CACHE STRING INTERNAL)
       ELSEIF (CYGWIN)
-        execute_process(COMMAND ${POSTGRES_CONFIG} --includedir
+        execute_process(COMMAND ${POSTGRES_CONFIG} --libs
           OUTPUT_VARIABLE PG_TMP
           OUTPUT_STRIP_TRAILING_WHITESPACE)
 
+24 −0
Original line number Diff line number Diff line
commit eb69f594ec439309432e87834bead5276b7dbc9b
Author: Palmer Cox <p@lmercox.com>
Date:   Sun Feb 23 16:45:34 2025 -0500

    On Apple, use FIND_LIBRARY to locate libpq
    
    I think FIND_LIBRARY() is better than just relying on what pg_config
    said its libdir was, since, depending on how libpq was installed, it may
    or may not be in that directory. If its not, FIND_LIBRARY() is able to
    find it in other locations.

diff --git a/saga-gis/cmake/modules/FindPostgres.cmake b/saga-gis/cmake/modules/FindPostgres.cmake
index a4b6ec9ac..65e7ac69b 100644
--- a/cmake/modules/FindPostgres.cmake
+++ b/cmake/modules/FindPostgres.cmake
@@ -81,7 +81,7 @@ ELSE(WIN32)
         OUTPUT_VARIABLE PG_TMP
         OUTPUT_STRIP_TRAILING_WHITESPACE)
       IF (APPLE)
-        SET(POSTGRES_LIBRARY ${PG_TMP}/libpq.dylib CACHE STRING INTERNAL)
+        FIND_LIBRARY(POSTGRES_LIBRARY NAMES pq libpq PATHS ${PG_TMP})
       ELSEIF (CYGWIN)
         execute_process(COMMAND ${POSTGRES_CONFIG} --libs
           OUTPUT_VARIABLE PG_TMP
+8 −0
Original line number Diff line number Diff line
@@ -43,6 +43,14 @@ stdenv.mkDerivation rec {

  sourceRoot = "saga-${version}/saga-gis";

  patches = [
    # Patches from https://sourceforge.net/p/saga-gis/code/merge-requests/38/.
    # These are needed to fix building on Darwin (technically the first is not
    # required, but the second doesn't apply without it).
    ./darwin-patch-1.patch
    ./darwin-patch-2.patch
  ];

  nativeBuildInputs = [
    cmake
    wrapGAppsHook3