Skip to content

Commit

Permalink
Merge pull request #2988 from dg0yt/pkgconfig
Browse files Browse the repository at this point in the history
Use `Requires.Private` in proj.pc, and install it also for Windows
  • Loading branch information
rouault authored Feb 7, 2022
2 parents 7f0ac75 + 2b0ecb6 commit ca1ec7b
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 37 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/clang_linux/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ set -e

apt-get update -y
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
sudo autoconf automake libtool clang++-10 python3-clang-10 make cmake ccache pkg-config tar zip \
sqlite3 libsqlite3-dev libtiff-dev libcurl4-openssl-dev jq python3-pip nlohmann-json3-dev libgtest-dev
autoconf automake libtool make cmake ccache pkg-config python3-pip sqlite3 tar zip \
clang++-10 jq python3-clang-10 \
libsqlite3-dev \
libtiff-dev libwebp-dev libzstd-dev \
libcurl4-openssl-dev libnghttp2-dev libidn2-dev librtmp-dev libssh-dev \
libpsl-dev libssl-dev libkrb5-dev comerr-dev libldap2-dev libbrotli-dev \
nlohmann-json3-dev libgtest-dev

python3 -m pip install --user jsonschema
export PATH=$HOME/.local/bin:$PATH
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/linux_gcc_32bit/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ export TRAVIS_BUILD_DIR="$WORK_DIR"
ARCH=i386

dpkg --add-architecture i386
apt update -y
apt-get update -y

DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -o APT::Immediate-Configure=0 \
autoconf automake libtool gcc-multilib g++-multilib g++ sqlite3 \
python3-pip \
make cmake ccache pkg-config tar zip \
libsqlite3-dev:$ARCH libtiff-dev:$ARCH libcurl4-openssl-dev:$ARCH \
jq
autoconf automake libtool make cmake ccache pkg-config python3-pip sqlite3 tar zip \
gcc-multilib g++-multilib g++ jq dpkg-dev \
libsqlite3-dev:$ARCH \
libtiff-dev:$ARCH libwebp-dev:$ARCH libzstd-dev:$ARCH \
libcurl4-openssl-dev:$ARCH libnghttp2-dev:$ARCH libidn2-dev:$ARCH librtmp-dev:$ARCH libssh-dev:$ARCH \
libpsl-dev:$ARCH libssl-dev:$ARCH libkrb5-dev:$ARCH comerr-dev:$ARCH libldap2-dev:$ARCH libbrotli-dev:$ARCH

python3 -m pip install --user jsonschema
export PATH=$HOME/.local/bin:$PATH
Expand All @@ -28,6 +29,8 @@ export TIFF_LIBS="-L/usr/lib/i386-linux-gnu -ltiff"
export SQLITE3_CFLAGS=-I/usr/include/i386-linux-gnu
export SQLITE3_LIBS="-L/usr/lib/i386-linux-gnu -lsqlite3"

export PKG_CONFIG=i686-linux-gnu-pkg-config

cd "$WORK_DIR"

if test -f "$WORK_DIR/ccache.tar.gz"; then
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/linux_gcc_5_4/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export TRAVIS_OS_NAME=linux
export BUILD_NAME=linux_gcc
export TRAVIS_BUILD_DIR="$WORK_DIR"

apt update -y
apt-get update -y

DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
autoconf automake libtool g++ sqlite3 \
python3-pip python3-setuptools \
make cmake ccache pkg-config tar zip \
libsqlite3-dev libtiff-dev libcurl4-openssl-dev \
jq lcov
autoconf automake libtool make cmake ccache pkg-config python3-pip sqlite3 tar zip \
g++ jq lcov python3-setuptools \
libsqlite3-dev \
libtiff-dev \
libcurl4-openssl-dev libidn11-dev librtmp-dev libssl-dev libkrb5-dev comerr-dev libldap2-dev

python3 -m pip install --user --upgrade "pip < 21.0"
echo `python3 -m pip --version`
Expand Down
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 26 additions & 11 deletions cmake/ProjUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions proj.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Requires:
Version: @VERSION@
Libs: -L${libdir} -lproj
Libs.private: @EXTRA_LIBS@
Requires.private: @EXTRA_REQUIRES@
Cflags: -I${includedir}
6 changes: 3 additions & 3 deletions test/postinstall/c_app/makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ TESTS = \
test_searchpath.sh \
test_version.sh

override CFLAGS += -g -Wall -Werror $(shell pkg-config proj --cflags)
override CFLAGS += -g -Wall -Werror $(shell ${PKG_CONFIG} proj --cflags)

ifeq ($(BUILD_MODE),static)
UNAME_S := $(shell uname -s)
_ldflags := $(shell pkg-config proj --libs --static)
_ldflags := $(shell ${PKG_CONFIG} proj --libs --static)
ifeq ($(UNAME_S),Linux)
# force static linking to libproj
_ldflags := $(shell echo $(_ldflags) | sed 's/-lproj/-Wl,-Bstatic -lproj -Wl,-Bdynamic/')
endif
override LDFLAGS += $(_ldflags)
else # default is shared
override LDFLAGS += $(shell pkg-config proj --libs)
override LDFLAGS += $(shell ${PKG_CONFIG} proj --libs)
endif

all: $(PROGRAM)
Expand Down
5 changes: 3 additions & 2 deletions test/postinstall/test_autotools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ main_setup $1 $2
echo "Running post-install tests with autotools/pkg-config (${BUILD_MODE})"

if [ ${BUILD_MODE} = shared ]; then
export PKG_CONFIG="pkg-config"
export PKG_CONFIG="${PKG_CONFIG:-pkg-config}"
ENABLE_STATIC_PROJ=no
else
export PKG_CONFIG="pkg-config --static"
export PKG_CONFIG="${PKG_CONFIG:-pkg-config} --static"
ENABLE_STATIC_PROJ=yes
fi
echo ,${PKG_CONFIG},

export PKG_CONFIG_PATH=${prefix}/lib/pkgconfig

Expand Down
1 change: 1 addition & 0 deletions test/postinstall/test_pkg-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ main_setup $1 $2

echo "Running post-install tests with pkg-config (${BUILD_MODE})"

export PKG_CONFIG="${PKG_CONFIG:-pkg-config}"
export PKG_CONFIG_PATH=${prefix}/lib/pkgconfig

if [ ${BUILD_MODE} = shared ]; then
Expand Down
7 changes: 6 additions & 1 deletion travis/linux_generic/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ set -e
./travis/before_install_apt.sh
./travis/before_install_pip.sh

sudo apt-get install -qq sqlite3 libsqlite3-dev libtiff-dev libcurl4-openssl-dev zip
sudo apt-get install -qq \
sqlite3 zip \
libsqlite3-dev \
libtiff-dev \
libcurl4-openssl-dev libnghttp2-dev libidn2-dev librtmp-dev libssh-dev \
libpsl-dev libssl-dev libkrb5-dev comerr-dev libldap2-dev libbrotli-dev

0 comments on commit ca1ec7b

Please sign in to comment.