aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/geos/fix-exported-config.patch
blob: 2e05f83b5a96be98c59bee4b2d793e0335faa424 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index a8c034fb2..a5cd14c13 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -61,11 +61,22 @@ function(configure_install_geos_pc)
     set(libdir "$\{exec_prefix\}/${CMAKE_INSTALL_LIBDIR}")
   endif()
   set(VERSION ${GEOS_VERSION})
-  set(EXTRA_LIBS "-lstdc++")
+  set(EXTRA_LIBS "")
+  foreach(lib IN LISTS CMAKE_CXX_IMPLICIT_LINK_LIBRARIES)
+    if(lib IN_LIST CMAKE_C_IMPLICIT_LINK_LIBRARIES)
+      continue()
+    elseif(EXISTS "${lib}")
+      list(APPEND EXTRA_LIBS "${lib}")
+    else()
+      list(APPEND EXTRA_LIBS "-l${lib}")
+    endif()
+  endforeach()
   if(HAVE_LIBM)
+    list(REMOVE_ITEM EXTRA_LIBS "-lm")
     list(APPEND EXTRA_LIBS "-lm")
   endif()
   list(JOIN EXTRA_LIBS " " EXTRA_LIBS)
+  set(EXTRA_LIBS "${EXTRA_LIBS}" PARENT_SCOPE) # for geos-config
 
   configure_file(
     ${CMAKE_CURRENT_SOURCE_DIR}/geos.pc.in
@@ -77,9 +88,9 @@ function(configure_install_geos_pc)
     DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 endfunction()
 
+configure_install_geos_pc()
 if(NOT MSVC)
   configure_install_geos_config()
-  configure_install_geos_pc()
 endif()
 
 option(BUILD_ASTYLE "Build astyle (Artistic Style) tool" OFF)
diff --git a/tools/geos-config.in b/tools/geos-config.in
index 6eff1eb14..8827f6ac6 100644
--- a/tools/geos-config.in
+++ b/tools/geos-config.in
@@ -1,9 +1,11 @@
 #!/bin/sh
 
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-includedir=@includedir@
-libdir=@libdir@
+DIRNAME=$(dirname $0)
+TOOLS=$(dirname $DIRNAME)
+prefix=$(CDPATH= cd -- "${DIRNAME%/tools/geos/*}" && pwd -P)
+exec_prefix=${prefix}
+includedir=${prefix}/include
+libdir=${prefix}${TOOLS##*/geos}/lib
 
 usage()
 {
@@ -47,16 +49,16 @@ while test $# -gt 0; do
       echo -L${libdir} -lgeos
       ;;
     --clibs)
-      echo -L${libdir} -lgeos_c
+      echo -L${libdir} -lgeos_c $(if test "@BUILD_SHARED_LIBS@" != "ON"; then echo "-lgeos @EXTRA_LIBS@"; fi)
       ;;
     --cclibs)
-      echo -L${libdir} -lgeos
+      echo -L${libdir} -lgeos $(if test "@BUILD_SHARED_LIBS@" != "ON"; then echo "@EXTRA_LIBS@"; fi)
       ;;
     --static-clibs)
-      echo -L${libdir} -lgeos_c -lgeos -lstdc++ -lm
+      echo -L${libdir} -lgeos_c -lgeos @EXTRA_LIBS@
       ;;
     --static-cclibs)
-      echo -L${libdir} -lgeos -lstdc++ -lm
+      echo -L${libdir} -lgeos @EXTRA_LIBS@
       ;;
     --cflags)
       echo -I${includedir}