aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rw-r--r--cmake/ProjUtilities.cmake37
-rw-r--r--proj.pc.in1
3 files changed, 31 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ac6d0cc..6bdc7cab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -338,13 +338,11 @@ install(FILES ${docfiles}
################################################################################
# pkg-config support
################################################################################
-if(UNIX OR MINGW)
- configure_proj_pc()
+configure_proj_pc()
- install(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/proj.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-endif()
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/proj.pc
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
################################################################################
# "make dist" workalike
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
diff --git a/proj.pc.in b/proj.pc.in
index 54c5bfcc..9855aadc 100644
--- a/proj.pc.in
+++ b/proj.pc.in
@@ -11,4 +11,5 @@ Requires:
Version: @VERSION@
Libs: -L${libdir} -lproj
Libs.private: @EXTRA_LIBS@
+Requires.private: @EXTRA_REQUIRES@
Cflags: -I${includedir}