Skip to content

Commit

Permalink
Create a utility function configure_proj_pc() and use existing proj.p…
Browse files Browse the repository at this point in the history
…c.in
  • Loading branch information
mwtoews committed Feb 25, 2021
1 parent 443219d commit 291eec4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 28 deletions.
14 changes: 2 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,8 @@ install(FILES ${docfiles}
################################################################################
# pkg-config support
################################################################################
if(UNIX)
set(SQLITE3_LIBS -lsqlite3)
if(TIFF_ENABLED)
set(TIFF_LIBS -ltiff)
endif()
if(CURL_ENABLED)
set(CURL_LIBS -lcurl)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/proj.pc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/proj.pc
@ONLY)
if(UNIX OR MINGW)
configure_proj_pc()

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/proj.pc
Expand Down
1 change: 0 additions & 1 deletion cmake/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ EXTRA_DIST = CMakeLists.txt \
ProjTest.cmake \
ProjVersion.cmake \
policies.cmake \
proj_config.cmake.in \
proj.pc.cmake.in \
project-config-version.cmake.in \
project-config.cmake.in \
Expand Down
2 changes: 2 additions & 0 deletions cmake/ProjInstallPath.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ else()
set(DEFAULT_INCLUDE_SUBDIR include)
set(DEFAULT_DOC_SUBDIR share/doc/proj)
set(DEFAULT_CMAKE_SUBDIR lib/cmake)
# Used for proj.pc
set(CMAKE_INSTALL_DATAROOTDIR share)
endif()

# Locations are changeable by user to customize layout of PROJ installation
Expand Down
31 changes: 30 additions & 1 deletion cmake/ProjUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# Macros in this module:
#
# print_variable
# proj_target_output_name:
# proj_target_output_name
# configure_proj_pc
#
################################################################################

Expand Down Expand Up @@ -60,3 +61,31 @@ function(proj_target_output_name TARGET_NAME OUTPUT_NAME)

set(${OUTPUT_NAME} ${TARGET_NAME}${SUFFIX} PARENT_SCOPE)
endfunction()

#
# Configure a pkg-config file proj.pc
# See also ProjInstallPath.cmake
#

function(configure_proj_pc)
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "$\{prefix\}")
set(libdir "$\{exec_prefix\}/${PROJ_LIB_SUBDIR}")
set(includedir "$\{prefix\}/${PROJ_INCLUDE_SUBDIR}")
set(datarootdir "$\{prefix\}/${CMAKE_INSTALL_DATAROOTDIR}")
set(datadir "$\{datarootdir\}")
set(PACKAGE "proj")
set(VERSION ${PROJ_VERSION})
set(SQLITE3_LIBS -lsqlite3)
if(TIFF_ENABLED)
set(TIFF_LIBS -ltiff)
endif()
if(CURL_ENABLED)
set(CURL_LIBS -lcurl)
endif()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/proj.pc.in
${CMAKE_CURRENT_BINARY_DIR}/proj.pc
@ONLY)
endfunction()
14 changes: 0 additions & 14 deletions cmake/proj.pc.cmake.in

This file was deleted.

0 comments on commit 291eec4

Please sign in to comment.