Renamed config.h -> jansson_private_config.h

This is because it's really easy to get a name collission if compiling
Jansson as a subproject in a larger CMake project. If one project includes
several subprojects each having their own config.h, this will cause the
wrong file to be loaded.
This commit is contained in:
Joakim Soderberg 2014-01-13 17:13:44 +01:00
parent 913937c98d
commit 3fe8f74e7f
10 changed files with 22 additions and 18 deletions

View File

@ -246,13 +246,11 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/) DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
add_definitions(-DJANSSON_USING_CMAKE)
# configure the private config file # configure the private config file
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_private_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/private_include/config.h) ${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h)
# and tell the source code to include it
add_definitions (-DHAVE_CONFIG_H)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/include) include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/private_include) include_directories (${CMAKE_CURRENT_BINARY_DIR}/private_include)
@ -299,7 +297,7 @@ if (JANSSON_BUILD_DOCS)
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 -DJSON_BUILD_DOCS=0 to get rid of this message.") Set -DJANSSON_BUILD_DOCS=OFF 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!
@ -501,6 +499,7 @@ export(PACKAGE jansson)
set(JANSSON__INCLUDE_DIRS set(JANSSON__INCLUDE_DIRS
"${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_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 configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in
${PROJECT_BINARY_DIR}/JanssonConfig.cmake ${PROJECT_BINARY_DIR}/JanssonConfig.cmake
@ONLY) @ONLY)
@ -565,3 +564,5 @@ install(FILES
install(EXPORT JanssonTargets install(EXPORT JanssonTargets
DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev) 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")

View File

@ -1,7 +1,7 @@
# - Config file for the Libevent package # - Config file for the jansson package
# It defines the following variables # It defines the following variables
# LIBEVENT_INCLUDE_DIRS - include directories for FooBar # JANSSON_INCLUDE_DIRS - include directories for FooBar
# LIBEVENT_LIBRARIES - libraries to link against # JANSSON_LIBRARIES - libraries to link against
# Get the path of the current file. # Get the path of the current file.
get_filename_component(JANSSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 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 the project Targets file, this contains definitions for IMPORTED targets.
include(${JANSSON_CMAKE_DIR}/JanssonTargets.cmake) include(${JANSSON_CMAKE_DIR}/JanssonTargets.cmake)
# IMPORTED targets from LibeventTargets.cmake # IMPORTED targets from JanssonTargets.cmake
set(JANSSON_LIBRARIES event event_core event_extras) set(JANSSON_LIBRARIES jansson)

View File

@ -17,7 +17,9 @@
#define JANSSON_CONFIG_H #define JANSSON_CONFIG_H
/* Define this so that we can disable scattered automake configuration in source files */ /* Define this so that we can disable scattered automake configuration in source files */
#ifndef JANSSON_USING_CMAKE
#define JANSSON_USING_CMAKE #define JANSSON_USING_CMAKE
#endif
/* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, /* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used,
* as we will also check for __int64 etc types. * as we will also check for __int64 etc types.

View File

@ -4,7 +4,7 @@ AC_INIT([jansson], [2.5], [petri@digip.org])
AM_INIT_AUTOMAKE([1.10 foreign]) AM_INIT_AUTOMAKE([1.10 foreign])
AC_CONFIG_SRCDIR([src/value.c]) AC_CONFIG_SRCDIR([src/value.c])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([jansson_private_config.h])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC

View File

@ -5,9 +5,9 @@
#include "jansson_private.h" #include "jansson_private.h"
#include "strbuffer.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 #ifdef HAVE_CONFIG_H
#include <config.h> #include <jansson_private_config.h>
#endif #endif
#if JSON_HAVE_LOCALECONV #if JSON_HAVE_LOCALECONV

View File

@ -9,7 +9,8 @@
#define UTF_H #define UTF_H
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#ifdef HAVE_INTTYPES_H #ifdef HAVE_INTTYPES_H
/* inttypes.h includes stdint.h in a standard environment, so there's /* inttypes.h includes stdint.h in a standard environment, so there's

View File

@ -6,7 +6,7 @@
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <jansson_private_config.h>
#endif #endif
#include <stdio.h> #include <stdio.h>

View File

@ -7,7 +7,7 @@
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <jansson_private_config.h>
#endif #endif
#include <jansson_config.h> #include <jansson_config.h>

View File

@ -9,7 +9,7 @@
#define UTIL_H #define UTIL_H
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <jansson_private_config.h>
#endif #endif
#include <stdio.h> #include <stdio.h>