Create and install the pkg-config file jansson.pc for CMake.

Use the same jansson.pc.in file as the ./configure script does to generate the jansson.pc file for pkg-config. Also make an install rule for this.
This commit is contained in:
Joakim Soderberg 2013-05-06 12:34:52 +00:00
parent 42d398243d
commit 54d86fb4a4

View File

@ -62,6 +62,8 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
# set (JANSSON_VERSION "2.3.1") # set (JANSSON_VERSION "2.3.1")
# set (JANSSON_SOVERSION 2) # set (JANSSON_SOVERSION 2)
set(JANSSON_DISPLAY_VERSION "2.5-dev")
# This is what is required to match the same numbers as automake's # This is what is required to match the same numbers as automake's
set (JANSSON_VERSION "4.3.1") set (JANSSON_VERSION "4.3.1")
set (JANSSON_SOVERSION 4) set (JANSSON_SOVERSION 4)
@ -213,6 +215,19 @@ elseif (HAVE__SNPRINTF)
set (JSON_SNPRINTF _snprintf) set (JSON_SNPRINTF _snprintf)
endif () endif ()
# Create pkg-conf file.
# (We use the same files as ./configure does, so we
# have to defined the same variables used there).
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(VERSION ${JANSSON_DISPLAY_VERSION})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jansson.pc.in
${CMAKE_CURRENT_BINARY_DIR}/jansson.pc @ONLY)
# configure the public config file # configure the public config file
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h) ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h)
@ -252,8 +267,8 @@ endif ()
# LIBRARY for linux # LIBRARY for linux
# RUNTIME for windows (when building shared) # RUNTIME for windows (when building shared)
install (TARGETS jansson install (TARGETS jansson
ARCHIVE DESTINATION lib ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION lib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
) )
@ -262,13 +277,18 @@ install (FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
DESTINATION include) DESTINATION include)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/jansson.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# For building Documentation (uses Sphinx) # For building Documentation (uses Sphinx)
OPTION (BUILD_DOCS "Build documentation (uses python-sphinx)." ON) OPTION (BUILD_DOCS "Build documentation (uses python-sphinx)." ON)
if (BUILD_DOCS) if (BUILD_DOCS)
find_package(Sphinx) find_package(Sphinx)
if (NOT SPHINX_FOUND) if (NOT SPHINX_FOUND)
message(WARNING "Sphinx not found. Cannot generate documentation!") message(WARNING "Sphinx not found. Cannot generate documentation!
Set -DBUILD_DOCS=0 to get rid of this message.")
else() else()
if (Sphinx_VERSION_STRING VERSION_LESS 1.0) if (Sphinx_VERSION_STRING VERSION_LESS 1.0)
message(WARNING "Your Sphinx version is too old! message(WARNING "Your Sphinx version is too old!