diff --git a/CMake/flatbuffers.pc.in b/CMake/flatbuffers.pc.in new file mode 100644 index 000000000..110770aba --- /dev/null +++ b/CMake/flatbuffers.pc.in @@ -0,0 +1,9 @@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: FlatBuffers +Description: Memory Efficient Serialization Library +Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ + +Libs: -L${libdir} -lflatbuffers +Cflags: -I${includedir} diff --git a/CMakeLists.txt b/CMakeLists.txt index a7c0b0a75..f56f844f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -629,6 +629,14 @@ if(FLATBUFFERS_INSTALL) DESTINATION ${FB_CMAKE_DIR} ) endif() + + if(FLATBUFFERS_BUILD_SHAREDLIB OR FLATBUFFERS_BUILD_FLATLIB) + configure_file(CMake/flatbuffers.pc.in flatbuffers.pc @ONLY) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers.pc" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + ) + endif() endif() if(FLATBUFFERS_BUILD_TESTS)