From 42d398243d306b7dfcd75b9479438ce4372a1cef Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 6 May 2013 12:31:29 +0000 Subject: [PATCH 1/2] Fix the cmake Sphinx find script. The cmake sphinx find script version parsing assumes a format of 1.2.3, but sphinx version can be 1.2b3 as well, so parse those correctly as well. --- cmake/FindSphinx.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake index 6eac499..55539d4 100644 --- a/cmake/FindSphinx.cmake +++ b/cmake/FindSphinx.cmake @@ -257,12 +257,16 @@ if (Sphinx-build_EXECUTABLE) ERROR_VARIABLE _Sphinx_VERSION ) endif () - if (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+\\.[0-9]+)") + + # The sphinx version can also contain a "b" instead of the last dot. + # For example "Sphinx v1.2b1" so we cannot just split on "." + if (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b)[0-9]+)") set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}") - string (REPLACE "." ";" _Sphinx_VERSION "${Sphinx_VERSION_STRING}") - list(GET _Sphinx_VERSION 0 Sphinx_VERSION_MAJOR) - list(GET _Sphinx_VERSION 1 Sphinx_VERSION_MINOR) - list(GET _Sphinx_VERSION 2 Sphinx_VERSION_PATCH) + string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MAJOR ${Sphinx_VERSION_STRING}) + string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MINOR ${Sphinx_VERSION_STRING}) + string(REGEX REPLACE "[0-9]+\\.[0-9]+(\\.|b)([0-9]+)" "\\1" Sphinx_VERSION_PATCH ${Sphinx_VERSION_STRING}) + + # v1.2.0 -> v1.2 if (Sphinx_VERSION_PATCH EQUAL 0) string (REGEX REPLACE "\\.0$" "" Sphinx_VERSION_STRING "${Sphinx_VERSION_STRING}") endif () From 54d86fb4a4a338341f872fdf32def0ad5a459847 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 6 May 2013 12:34:52 +0000 Subject: [PATCH 2/2] 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. --- CMakeLists.txt | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b12dad..e7f8da4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,8 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) # set (JANSSON_VERSION "2.3.1") # set (JANSSON_SOVERSION 2) +set(JANSSON_DISPLAY_VERSION "2.5-dev") + # This is what is required to match the same numbers as automake's set (JANSSON_VERSION "4.3.1") set (JANSSON_SOVERSION 4) @@ -213,6 +215,19 @@ elseif (HAVE__SNPRINTF) set (JSON_SNPRINTF _snprintf) 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_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h) @@ -252,8 +267,8 @@ endif () # LIBRARY for linux # RUNTIME for windows (when building shared) install (TARGETS jansson - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION bin ) @@ -262,13 +277,18 @@ install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h DESTINATION include) +install (FILES + ${CMAKE_CURRENT_BINARY_DIR}/jansson.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + # For building Documentation (uses Sphinx) OPTION (BUILD_DOCS "Build documentation (uses python-sphinx)." ON) if (BUILD_DOCS) find_package(Sphinx) 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() if (Sphinx_VERSION_STRING VERSION_LESS 1.0) message(WARNING "Your Sphinx version is too old!