aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2022-02-07 23:45:02 +0100
committerGitHub <noreply@github.com>2022-02-07 23:45:02 +0100
commitca1ec7b147087f18bec0b3cf0b0548f3f034c675 (patch)
tree630b9bee287c52fd4a119bbf401c61c2d37cbb86 /cmake
parent7f0ac75ac58794bb92b88f928d16c5053c0ce3e0 (diff)
parent2b0ecb6f19b1be906a39eac5143d4c40252f0a5a (diff)
downloadPROJ-ca1ec7b147087f18bec0b3cf0b0548f3f034c675.tar.gz
PROJ-ca1ec7b147087f18bec0b3cf0b0548f3f034c675.zip
Merge pull request #2988 from dg0yt/pkgconfig
Use `Requires.Private` in proj.pc, and install it also for Windows
Diffstat (limited to 'cmake')
-rw-r--r--cmake/ProjUtilities.cmake37
1 files changed, 26 insertions, 11 deletions
diff --git a/cmake/ProjUtilities.cmake b/cmake/ProjUtilities.cmake
index 333b01f0..690336b2 100644
--- a/cmake/ProjUtilities.cmake
+++ b/cmake/ProjUtilities.cmake
@@ -76,27 +76,42 @@ function(configure_proj_pc)
set(datadir "$\{datarootdir\}")
set(PACKAGE "proj")
set(VERSION ${PROJ_VERSION})
- # Build list for Libs.private
- set(EXTRA_LIBS
- -lstdc++
- -lsqlite3
- ${CMAKE_THREAD_LIBS_INIT}
- )
+ # Build strings of dependencies (Libs.private, Requires.private)
+ set(EXTRA_LIBS "${CMAKE_THREAD_LIBS_INIT}")
+ set(EXTRA_REQUIRES "")
+ option(USE_PKGCONFIG_REQUIRES "Use 'Requires' instead 'Libs' in proj.pc" ON)
+ macro(add_module_or_libs MODULE)
+ if(USE_PKGCONFIG_REQUIRES)
+ list(APPEND EXTRA_REQUIRES "${MODULE}")
+ else()
+ list(APPEND EXTRA_LIBS "${ARGN}")
+ endif()
+ endmacro()
+ add_module_or_libs(sqlite3 -lsqlite3)
if(TIFF_ENABLED)
- list(APPEND EXTRA_LIBS -ltiff)
+ add_module_or_libs(libtiff-4 -ltiff)
endif()
if(CURL_ENABLED)
- list(APPEND EXTRA_LIBS -lcurl)
+ add_module_or_libs(libcurl -lcurl)
+ endif()
+ if(WIN32 AND NOT MINGW)
+ list(APPEND EXTRA_LIBS -lole32 -lshell32)
+ else()
+ set(cxx_libs "${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}")
+ list(REMOVE_ITEM cxx_libs ${CMAKE_C_IMPLICIT_LINK_LIBRARIES})
+ foreach(lib IN LISTS cxx_libs)
+ list(APPEND EXTRA_LIBS "-l${lib}")
+ endforeach()
endif()
- if(HAVE_LIBM)
+ if(HAVE_LIBM AND NOT "-lm" IN_LIST EXTRA_LIBS)
list(APPEND EXTRA_LIBS -lm)
endif()
if(HAVE_LIBDL)
list(APPEND EXTRA_LIBS -ldl)
endif()
# Join list with a space; list(JOIN) added CMake 3.12
- string(REPLACE ";" " " _tmp_str "${EXTRA_LIBS}")
- set(EXTRA_LIBS "${_tmp_str}")
+ string(REPLACE ";" " " EXTRA_LIBS "${EXTRA_LIBS}")
+ string(REPLACE ";" " " EXTRA_REQUIRES "${EXTRA_REQUIRES}")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/proj.pc.in