diff --git a/CMakeLists.txt b/CMakeLists.txt index 75c0523..1463f9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,13 +246,11 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/) +add_definitions(-DJANSSON_USING_CMAKE) # configure the private config file -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/private_include/config.h) - -# and tell the source code to include it -add_definitions (-DHAVE_CONFIG_H) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_private_config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h) include_directories (${CMAKE_CURRENT_BINARY_DIR}/include) include_directories (${CMAKE_CURRENT_BINARY_DIR}/private_include) @@ -299,7 +297,7 @@ if (JANSSON_BUILD_DOCS) if (NOT SPHINX_FOUND) message(WARNING "Sphinx not found. Cannot generate documentation! - Set -DJSON_BUILD_DOCS=0 to get rid of this message.") + Set -DJANSSON_BUILD_DOCS=OFF to get rid of this message.") else() if (Sphinx_VERSION_STRING VERSION_LESS 1.0) message(WARNING "Your Sphinx version is too old! @@ -501,6 +499,7 @@ export(PACKAGE jansson) set(JANSSON__INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") +set(JANSSON_INCLUDE_DIRS ${JANSSON__INCLUDE_DIRS} CACHE PATH "Jansson include directories") configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in ${PROJECT_BINARY_DIR}/JanssonConfig.cmake @ONLY) @@ -565,3 +564,5 @@ install(FILES install(EXPORT JanssonTargets DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev) +# For use when simply using add_library from a parent project to build jansson. +set(JANSSON_LIBRARIES jansson CACHE STRING "Jansson libraries") diff --git a/cmake/JanssonConfig.cmake.in b/cmake/JanssonConfig.cmake.in index 21af0ff..d00b3c4 100644 --- a/cmake/JanssonConfig.cmake.in +++ b/cmake/JanssonConfig.cmake.in @@ -1,7 +1,7 @@ -# - Config file for the Libevent package +# - Config file for the jansson package # It defines the following variables -# LIBEVENT_INCLUDE_DIRS - include directories for FooBar -# LIBEVENT_LIBRARIES - libraries to link against +# JANSSON_INCLUDE_DIRS - include directories for FooBar +# JANSSON_LIBRARIES - libraries to link against # Get the path of the current file. get_filename_component(JANSSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) @@ -12,6 +12,6 @@ set(JANSSON_INCLUDE_DIRS "@JANSSON__INCLUDE_DIRS@") # Include the project Targets file, this contains definitions for IMPORTED targets. include(${JANSSON_CMAKE_DIR}/JanssonTargets.cmake) -# IMPORTED targets from LibeventTargets.cmake -set(JANSSON_LIBRARIES event event_core event_extras) +# IMPORTED targets from JanssonTargets.cmake +set(JANSSON_LIBRARIES jansson) diff --git a/cmake/jansson_config.h.cmake b/cmake/jansson_config.h.cmake index 8c500b5..9917b56 100644 --- a/cmake/jansson_config.h.cmake +++ b/cmake/jansson_config.h.cmake @@ -17,7 +17,9 @@ #define JANSSON_CONFIG_H /* Define this so that we can disable scattered automake configuration in source files */ +#ifndef JANSSON_USING_CMAKE #define JANSSON_USING_CMAKE +#endif /* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, * as we will also check for __int64 etc types. diff --git a/cmake/config.h.cmake b/cmake/jansson_private_config.h.cmake similarity index 100% rename from cmake/config.h.cmake rename to cmake/jansson_private_config.h.cmake diff --git a/configure.ac b/configure.ac index 24ba37d..2f26149 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT([jansson], [2.5], [petri@digip.org]) AM_INIT_AUTOMAKE([1.10 foreign]) AC_CONFIG_SRCDIR([src/value.c]) -AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([jansson_private_config.h]) # Checks for programs. AC_PROG_CC diff --git a/src/strconv.c b/src/strconv.c index 3e2cb7c..3a70c6f 100644 --- a/src/strconv.c +++ b/src/strconv.c @@ -5,9 +5,9 @@ #include "jansson_private.h" #include "strbuffer.h" -/* need config.h to get the correct snprintf */ +/* need jansson_private_config.h to get the correct snprintf */ #ifdef HAVE_CONFIG_H -#include +#include #endif #if JSON_HAVE_LOCALECONV diff --git a/src/utf.h b/src/utf.h index 81f85ab..331e57f 100644 --- a/src/utf.h +++ b/src/utf.h @@ -9,7 +9,8 @@ #define UTF_H #ifdef HAVE_CONFIG_H -#include + +#include #ifdef HAVE_INTTYPES_H /* inttypes.h includes stdint.h in a standard environment, so there's diff --git a/test/bin/json_process.c b/test/bin/json_process.c index 23afefe..8ca3fe3 100644 --- a/test/bin/json_process.c +++ b/test/bin/json_process.c @@ -6,7 +6,7 @@ */ #ifdef HAVE_CONFIG_H -#include +#include #endif #include diff --git a/test/suites/api/test_pack.c b/test/suites/api/test_pack.c index 348d8b2..487137c 100644 --- a/test/suites/api/test_pack.c +++ b/test/suites/api/test_pack.c @@ -7,7 +7,7 @@ */ #ifdef HAVE_CONFIG_H -#include +#include #endif #include diff --git a/test/suites/api/util.h b/test/suites/api/util.h index b86a546..e4019de 100644 --- a/test/suites/api/util.h +++ b/test/suites/api/util.h @@ -9,7 +9,7 @@ #define UTIL_H #ifdef HAVE_CONFIG_H -#include +#include #endif #include