aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorKai Pastor <dg0yt@darc.de>2021-12-19 11:07:12 +0100
committerKai Pastor <dg0yt@darc.de>2022-02-05 18:06:45 +0100
commit845d679d9801f5dd177b20630fbf8ec581600e52 (patch)
tree2f95936f0d2917c338d3f42e2603465ec7483d49 /cmake
parent0139d8c59f7ed135b03855f549d44a3801c42aa1 (diff)
downloadPROJ-845d679d9801f5dd177b20630fbf8ec581600e52.tar.gz
PROJ-845d679d9801f5dd177b20630fbf8ec581600e52.zip
Revise pc file construction
Use sqlite3, libtiff-4 and libcurl modules instead of plain libs Allow opt out by setting 'USE_PKGCONFIG_MODULES' off. Link native system libs on Windows, and implicit C++ libraries on other systems (e.g. libstc++/libc++).
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