Build and install libtommath.pc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d74e866..474ae69 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -171,6 +171,19 @@ install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
+# Install libtommath.pc for pkg-config if we build a shared library
+if(BUILD_SHARED_LIBS)
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lib${PROJECT_NAME}.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.pc
+ @ONLY
+ )
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.pc
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig
+ )
+endif()
+
# generate package version file
write_basic_package_version_file(
${PROJECT_VERSION_FILE}
diff --git a/libtommath.pc.in b/libtommath.pc.in
index 099b1cd..ad8f5c3 100644
--- a/libtommath.pc.in
+++ b/libtommath.pc.in
@@ -1,10 +1,9 @@
-prefix=@to-be-replaced@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@
Name: LibTomMath
Description: public domain library for manipulating large integer numbers
-Version: @to-be-replaced@
+Version: @PROJECT_VERSION@
Libs: -L${libdir} -ltommath
Cflags: -I${includedir}