Skip to content

Commit dd5b57a

Browse files
committed
Merge pull request open-source-parsers#42 from jonessen96/master
Add pkg-config support
2 parents d9ced92 + 6270858 commit dd5b57a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ENABLE_TESTING()
55
OPTION(JSONCPP_WITH_TESTS "Compile and run JsonCpp test executables" ON)
66
OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
77
OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
8+
OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
89

910
# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
1011
IF(NOT WIN32)
@@ -51,6 +52,15 @@ IF(JSONCPP_WITH_WARNING_AS_ERROR)
5152
UseCompilationWarningAsError()
5253
ENDIF(JSONCPP_WITH_WARNING_AS_ERROR)
5354

55+
IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
56+
CONFIGURE_FILE(
57+
"pkg-config/jsoncpp.pc.in"
58+
"pkg-config/jsoncpp.pc"
59+
@ONLY)
60+
INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc"
61+
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
62+
ENDIF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
63+
5464
# Build the different applications
5565
ADD_SUBDIRECTORY( src )
5666

pkg-config/jsoncpp.pc.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=${exec_prefix}/lib
4+
includedir=${prefix}/include
5+
6+
Name: jsoncpp
7+
Description: A C++ library for interacting with JSON
8+
URL: https://github.com/open-source-parsers/jsoncpp
9+
Libs: -L${libdir} -ljsoncpp
10+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)