aports/testing/valhalla/0002-libvalhalla-configuring.patch
2021-03-13 12:05:33 +00:00

74 lines
3.3 KiB
Diff

From 471e1373608392a32aee072b5a9041466765499d Mon Sep 17 00:00:00 2001
From: Bart Ribbers <bribbers@disroot.org>
Date: Sun, 28 Feb 2021 10:42:14 +0100
Subject: [PATCH] CMake: modernize configuring libvalhalla.pc
This also fixes the build on at least Alpine Linux
---
CHANGELOG.md | 1 +
libvalhalla.pc.in | 10 +++++-----
src/CMakeLists.txt | 20 ++++++--------------
3 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66a7f694d..5a298c701 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -43,6 +43,7 @@
* CHANGED: Service roads are not penalized for `pedestrian` costing by default. [#2898](https://github.com/valhalla/valhalla/pull/2898)
* ADDED: Add complex mandatory restrictions support [#2766](https://github.com/valhalla/valhalla/pull/2766)
* ADDED: Status endpoint for future status info and health checking of running service [#2907](https://github.com/valhalla/valhalla/pull/2907)
+ * CHANGED: CMake: Modernize configuring libvalhalla.pc [#2906](https://github.com/valhalla/valhalla/pull/2906)
## Release Date: 2021-01-25 Valhalla 3.1.0
* **Removed**
diff --git a/libvalhalla.pc.in b/libvalhalla.pc.in
index 45391b831..a448c8863 100644
--- a/libvalhalla.pc.in
+++ b/libvalhalla.pc.in
@@ -1,10 +1,10 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=${exec_prefix}/@libdir@
-includedir=${prefix}/@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: libvalhalla
Description: valhalla c++ library
Version: @VERSION@
-Libs: -L${libdir} -lvalhalla @deplibs@
+Libs: -L${libdir} -lvalhalla -lprotobuf-lite -pthread -lcurl -lz
Cflags: -I${includedir}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0ef57e872..27ab3c3b3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -262,18 +262,10 @@ install(FILES ${valhalla_hdrs}
COMPONENT development)
if(PKG_CONFIG_FOUND)
- ## Configure libvalhalla.pc file with valhalla target linking options via PkgConfig linker
- set(CMAKE_PkgConfig_LINK_EXECUTABLE "<CMAKE_COMMAND> -DINPUT=${VALHALLA_SOURCE_DIR}/libvalhalla.pc.in -DOUTPUT=<TARGET> -DVERSION=${VERSION} -Dprefix=${CMAKE_INSTALL_PREFIX} -Dexec_prefix=${CMAKE_INSTALL_PREFIX} -Dlibdir=${CMAKE_INSTALL_LIBDIR} -Dincludedir=${CMAKE_INSTALL_INCLUDEDIR} -Ddeplibs=\"<FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>\" -P ${CMAKE_SOURCE_DIR}/cmake/PkgConfig.cmake")
-
- add_executable(libvalhalla.pc EXCLUDE_FROM_ALL ../libvalhalla.pc.in)
- target_link_libraries(libvalhalla.pc valhalla)
- set_target_properties(libvalhalla.pc PROPERTIES LINKER_LANGUAGE PkgConfig)
- set_target_properties(libvalhalla.pc PROPERTIES FOLDER "Library")
- install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build . --target libvalhalla.pc OUTPUT_QUIET ERROR_VARIABLE _err RESULT_VARIABLE _res)
- if(NOT \${_res} EQUAL 0)
- message(FATAL_ERROR \"Configuring libvalhalla.pc failed: \${_err}\")
- endif()")
- install(FILES ${VALHALLA_BINARY_DIR}/libvalhalla.pc
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
- COMPONENT development)
+ configure_file(
+ "../libvalhalla.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/libvalhalla.pc"
+ @ONLY)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libvalhalla.pc
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()