Skip to content

Commit e867865

Browse files
authored
saga: Fix compiling on Darwin (NixOS#384655)
2 parents db54ea8 + 6e27715 commit e867865

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
commit 3bbd15676dfc077d7836e9d51810c1d6731f5789
2+
Author: Palmer Cox <p@lmercox.com>
3+
Date: Sun Feb 23 16:41:18 2025 -0500
4+
5+
Fix copy/paste error in FindPostgres.cmake
6+
7+
In f51c6b1513e312002c108fe87d26e33c48671406, EXEC_PROGRAM was changed to
8+
execute_process. As part of that, it looks like the second and third
9+
invocations were accidentally changed.
10+
11+
diff --git a/saga-gis/cmake/modules/FindPostgres.cmake b/saga-gis/cmake/modules/FindPostgres.cmake
12+
index f22806fd9..a4b6ec9ac 100644
13+
--- a/cmake/modules/FindPostgres.cmake
14+
+++ b/cmake/modules/FindPostgres.cmake
15+
@@ -77,13 +77,13 @@ ELSE(WIN32)
16+
SET(POSTGRES_INCLUDE_DIR ${PG_TMP} CACHE STRING INTERNAL)
17+
18+
# set LIBRARY_DIR
19+
- execute_process(COMMAND ${POSTGRES_CONFIG} --includedir
20+
+ execute_process(COMMAND ${POSTGRES_CONFIG} --libdir
21+
OUTPUT_VARIABLE PG_TMP
22+
OUTPUT_STRIP_TRAILING_WHITESPACE)
23+
IF (APPLE)
24+
SET(POSTGRES_LIBRARY ${PG_TMP}/libpq.dylib CACHE STRING INTERNAL)
25+
ELSEIF (CYGWIN)
26+
- execute_process(COMMAND ${POSTGRES_CONFIG} --includedir
27+
+ execute_process(COMMAND ${POSTGRES_CONFIG} --libs
28+
OUTPUT_VARIABLE PG_TMP
29+
OUTPUT_STRIP_TRAILING_WHITESPACE)
30+
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
commit eb69f594ec439309432e87834bead5276b7dbc9b
2+
Author: Palmer Cox <p@lmercox.com>
3+
Date: Sun Feb 23 16:45:34 2025 -0500
4+
5+
On Apple, use FIND_LIBRARY to locate libpq
6+
7+
I think FIND_LIBRARY() is better than just relying on what pg_config
8+
said its libdir was, since, depending on how libpq was installed, it may
9+
or may not be in that directory. If its not, FIND_LIBRARY() is able to
10+
find it in other locations.
11+
12+
diff --git a/saga-gis/cmake/modules/FindPostgres.cmake b/saga-gis/cmake/modules/FindPostgres.cmake
13+
index a4b6ec9ac..65e7ac69b 100644
14+
--- a/cmake/modules/FindPostgres.cmake
15+
+++ b/cmake/modules/FindPostgres.cmake
16+
@@ -81,7 +81,7 @@ ELSE(WIN32)
17+
OUTPUT_VARIABLE PG_TMP
18+
OUTPUT_STRIP_TRAILING_WHITESPACE)
19+
IF (APPLE)
20+
- SET(POSTGRES_LIBRARY ${PG_TMP}/libpq.dylib CACHE STRING INTERNAL)
21+
+ FIND_LIBRARY(POSTGRES_LIBRARY NAMES pq libpq PATHS ${PG_TMP})
22+
ELSEIF (CYGWIN)
23+
execute_process(COMMAND ${POSTGRES_CONFIG} --libs
24+
OUTPUT_VARIABLE PG_TMP

pkgs/by-name/sa/saga/package.nix

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ stdenv.mkDerivation rec {
4343

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

46+
patches = [
47+
# Patches from https://sourceforge.net/p/saga-gis/code/merge-requests/38/.
48+
# These are needed to fix building on Darwin (technically the first is not
49+
# required, but the second doesn't apply without it).
50+
./darwin-patch-1.patch
51+
./darwin-patch-2.patch
52+
];
53+
4654
nativeBuildInputs = [
4755
cmake
4856
wrapGAppsHook3

0 commit comments

Comments
 (0)