cmake: Generate pkgconfig file
@@ -105,3 +105,17 @@ if (BUILD_TESTING)
add_subdirectory(t)
endif()
+# Generate libmaxminddb.pc file for pkg-config
+# Set the required variables as same with autotools
+set(prefix ${CMAKE_INSTALL_PREFIX})
+set(exec_prefix \${prefix})
+set(libdir \${exec_prefix}/lib)
+set(includedir \${prefix}/include)
+set(PACKAGE_VERSION ${maxminddb_VERSION})
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libmaxminddb.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
+ @ONLY)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
