Skip to content

Commit

Permalink
PROTON-2450 Generate correct relocatable pc files (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiridanek authored Nov 24, 2021
1 parent ba4a773 commit 5edfbd6
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 27 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,18 @@ set (MAN_INSTALL_DIR share/man CACHE PATH "Manpage directory")

mark_as_advanced (INCLUDE_INSTALL_DIR LIB_INSTALL_DIR SYSCONF_INSTALL_DIR SHARE_INSTALL_DIR MAN_INSTALL_DIR)

# ${PACKAGE_PREFIX_DIR} is expanded from @PACKAGE_INIT@
# by configure_package_config_file(), and available in ProtonConfig.cmake
macro (pn_relative_install_dir NAME VALUE)
# Sets variable NAME to contain relative path from ROOT to VALUE
# if VALUE is already relative, it does nothing
macro (pn_relative_install_dir NAME ROOT VALUE)
if (IS_ABSOLUTE ${VALUE})
message(WARNING "Build was given an absolute path '${VALUE}'. As a result, `make DESTDIR=... install` will not work.")
set (${NAME} "${VALUE}")
file(RELATIVE_PATH "${NAME}" "${ROOT}" "${VALUE}")
else ()
set (${NAME} "\${PACKAGE_PREFIX_DIR}/${VALUE}")
set (${NAME} "${VALUE}")
endif ()
endmacro ()

pn_relative_install_dir (INCLUDEDIR ${INCLUDE_INSTALL_DIR})
pn_relative_install_dir (INCLUDEDIR "${CMAKE_INSTALL_PREFIX}" "${INCLUDE_INSTALL_DIR}")
pn_relative_install_dir (LIBDIR "${CMAKE_INSTALL_PREFIX}" "${LIB_INSTALL_DIR}")

## LANGUAGE BINDINGS

Expand Down
1 change: 1 addition & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ include(WriteBasicConfigVersionFile)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/ProtonConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ProtonConfig.cmake
PATH_VARS INCLUDE_INSTALL_DIR
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton)
write_basic_config_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ProtonConfigVersion.cmake
Expand Down
36 changes: 36 additions & 0 deletions c/examples/Makefile.pkgconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# This Makefile demonstrates the use of pkgconfig to compile
# programs that make use of Qpid Proton C

CFLAGS=-g -Wall -Wextra $(shell pkg-config --cflags libqpid-proton-core --cflags libqpid-proton-proactor)
LDFLAGS=$(shell pkg-config --libs libqpid-proton-core --libs libqpid-proton-proactor)

SOURCES=$(wildcard *.c)
EXECUTABLES=$(patsubst %.c,%,$(SOURCES))

all: $(EXECUTABLES)

% : %.c
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) -lpthread $<

.PHONY: clean
clean:
rm -f $(EXECUTABLES)
6 changes: 3 additions & 3 deletions c/src/ProtonConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ if (Proton_USE_STATIC_LIBS)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_OLD})
endif()

set (Proton_INCLUDE_DIRS @INCLUDEDIR@)
set (Proton_INCLUDE_DIRS @PACKAGE_INCLUDE_INSTALL_DIR@)
set (Proton_LIBRARIES Proton::qpid-proton)
set (Proton_FOUND True)

set (Proton_Core_INCLUDE_DIRS @INCLUDEDIR@)
set (Proton_Core_INCLUDE_DIRS @PACKAGE_INCLUDE_INSTALL_DIR@)
set (Proton_Core_LIBRARIES Proton::core)
set (Proton_Core_FOUND True)

set (HAS_PROACTOR @HAS_PROACTOR@)
if (HAS_PROACTOR)
set (Proton_Proactor_INCLUDE_DIRS @INCLUDEDIR@)
set (Proton_Proactor_INCLUDE_DIRS @PACKAGE_INCLUDE_INSTALL_DIR@)
set (Proton_Proactor_LIBRARIES Proton::proactor)
set (Proton_Proactor_FOUND True)
endif()
Expand Down
8 changes: 4 additions & 4 deletions c/src/libqpid-proton-core.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

prefix=@PREFIX@
exec_prefix=@EXEC_PREFIX@
libdir=@LIBDIR@
includedir=@INCLUDEDIR@
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/@LIBDIR@
includedir=${prefix}/@INCLUDEDIR@

Name: Proton Core
Description: Qpid Proton C core protocol library
Expand Down
9 changes: 5 additions & 4 deletions c/src/libqpid-proton-proactor.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* under the License.
*/

prefix=@PREFIX@
exec_prefix=@EXEC_PREFIX@
libdir=@LIBDIR@
includedir=@INCLUDEDIR@
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/@LIBDIR@
includedir=${prefix}/@INCLUDEDIR@

Name: Proton Proactor
Description: Qpid Proton C proactive IO library
Version: @PN_VERSION@
URL: http://qpid.apache.org/proton/
Libs: -L${libdir} -lqpid-proton-proactor
Cflags: -I${includedir}
Requires: libqpid-proton-core
8 changes: 4 additions & 4 deletions c/src/libqpid-proton.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

prefix=@PREFIX@
exec_prefix=@EXEC_PREFIX@
libdir=@LIBDIR@
includedir=@INCLUDEDIR@
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/@LIBDIR@
includedir=${prefix}/@INCLUDEDIR@

Name: Proton
Description: Qpid Proton C library
Expand Down
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ include(WriteBasicConfigVersionFile)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/ProtonCppConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ProtonCppConfig.cmake
PATH_VARS INCLUDE_INSTALL_DIR
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/ProtonCpp)
write_basic_config_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ProtonCppConfigVersion.cmake
Expand Down
2 changes: 1 addition & 1 deletion cpp/ProtonCppConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ endif()

set (ProtonCpp_VERSION @PN_VERSION@)

set (ProtonCpp_INCLUDE_DIRS @INCLUDEDIR@)
set (ProtonCpp_INCLUDE_DIRS @PACKAGE_INCLUDE_INSTALL_DIR@)
set (ProtonCpp_LIBRARIES Proton::cpp)
set (ProtonCpp_FOUND True)

Expand Down
36 changes: 36 additions & 0 deletions cpp/examples/Makefile.pkgconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# This Makefile demonstrates the use of pkgconfig to compile
# programs that make use of Qpid Proton Cpp

CFLAGS=-g -Wall -Wextra $(shell pkg-config --cflags libqpid-proton-cpp)
LDFLAGS=$(shell pkg-config --libs libqpid-proton-cpp)

SOURCES=$(wildcard *.cpp)
EXECUTABLES=$(patsubst %.cpp,%,$(SOURCES))

all: $(EXECUTABLES)

% : %.cpp
$(CXX) -o $@ $(CFLAGS) $(LDFLAGS) -lpthread $<

.PHONY: clean
clean:
rm -f $(EXECUTABLES)
9 changes: 5 additions & 4 deletions cpp/libqpid-proton-cpp.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* under the License.
*/

prefix=@PREFIX@
exec_prefix=@EXEC_PREFIX@
libdir=@LIBDIR@
includedir=@INCLUDEDIR@
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/@LIBDIR@
includedir=${prefix}/@INCLUDEDIR@

Name: Proton C++
Description: Qpid Proton C++ library
Version: @PN_VERSION@
URL: http://qpid.apache.org/proton/
Libs: -L${libdir} -lqpid-proton-cpp
Cflags: -I${includedir}
Requires: libqpid-proton-core, libqpid-proton-proactor

0 comments on commit 5edfbd6

Please sign in to comment.