Skip to content

Commit

Permalink
Fixes for compiling with a newer (system) jsoncpp (#4429)
Browse files Browse the repository at this point in the history
* Move included json code to jsoncpp subdirectory

This is needed to avoid having to specify the minetest src directory
as a system include when fixing the json includes.

* Fix json includes

They used "", so that the compiler searches the project's directory
first. The result was that when compiling with a system jsoncpp,
the project's own version of json.h was still included, instead of
the system version.

The includes now use <>, so a system location, or one specified with
'-Ilocation' is searched only.

* Fix for jsoncpp deprecated function warning

When compiling with a newer version of jsoncpp (and
ENABLE_SYSTEM_JSONCPP=true), jsoncpp emits a warning
about a deprecated function that minetest uses.
  • Loading branch information
Rogier-5 authored and est31 committed Aug 10, 2016
1 parent 058a869 commit 4503b50
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmake/Modules/FindJson.cmake
Expand Up @@ -20,8 +20,8 @@ endif()

if(NOT JSONCPP_FOUND)
message(STATUS "Using bundled JSONCPP library.")
set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/json)
set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/jsoncpp)
set(JSON_LIBRARY jsoncpp)
add_subdirectory(json)
add_subdirectory(jsoncpp/json)
endif()

2 changes: 1 addition & 1 deletion src/convert_json.h
Expand Up @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef __CONVERT_JSON_H__
#define __CONVERT_JSON_H__

#include "json/json.h"
#include <json/json.h>

struct ModStoreMod;
struct ModStoreModDetails;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/mods.h
Expand Up @@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <vector>
#include <string>
#include <map>
#include "json/json.h"
#include <json/json.h>
#include "config.h"

#define MODNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_"
Expand Down
7 changes: 6 additions & 1 deletion src/script/common/c_content.cpp
Expand Up @@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include "mg_schematic.h"
#include "noise.h"
#include "json/json.h"
#include <json/json.h>

struct EnumString es_TileAnimationType[] =
{
Expand Down Expand Up @@ -1250,8 +1250,13 @@ static bool push_json_value_helper(lua_State *L, const Json::Value &value,
lua_newtable(L);
for (Json::Value::const_iterator it = value.begin();
it != value.end(); ++it) {
#ifndef JSONCPP_STRING
const char *str = it.memberName();
lua_pushstring(L, str ? str : "");
#else
std::string str = it.name();
lua_pushstring(L, str.c_str());
#endif
push_json_value_helper(L, *it, nullindex);
lua_rawset(L, -3);
}
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_util.cpp
Expand Up @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_content.h"
#include "cpp_api/s_async.h"
#include "serialization.h"
#include "json/json.h"
#include <json/json.h>
#include "cpp_api/s_security.h"
#include "porting.h"
#include "debug.h"
Expand Down
2 changes: 1 addition & 1 deletion src/serverlist.cpp
Expand Up @@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include "log.h"
#include "network/networkprotocol.h"
#include "json/json.h"
#include <json/json.h>
#include "convert_json.h"
#include "httpfetch.h"
#include "util/string.h"
Expand Down
2 changes: 1 addition & 1 deletion src/serverlist.h
Expand Up @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iostream>
#include "config.h"
#include "mods.h"
#include "json/json.h"
#include <json/json.h>

#ifndef SERVERLIST_HEADER
#define SERVERLIST_HEADER
Expand Down

0 comments on commit 4503b50

Please sign in to comment.