Skip to content

Commit 4503b50

Browse files
Rogier-5est31
authored andcommitted
Fixes for compiling with a newer (system) jsoncpp (#4429)
* 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.
1 parent 058a869 commit 4503b50

File tree

11 files changed

+13
-8
lines changed

11 files changed

+13
-8
lines changed

cmake/Modules/FindJson.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ endif()
2020

2121
if(NOT JSONCPP_FOUND)
2222
message(STATUS "Using bundled JSONCPP library.")
23-
set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/json)
23+
set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/jsoncpp)
2424
set(JSON_LIBRARY jsoncpp)
25-
add_subdirectory(json)
25+
add_subdirectory(jsoncpp/json)
2626
endif()
2727

src/convert_json.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2020
#ifndef __CONVERT_JSON_H__
2121
#define __CONVERT_JSON_H__
2222

23-
#include "json/json.h"
23+
#include <json/json.h>
2424

2525
struct ModStoreMod;
2626
struct ModStoreModDetails;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/mods.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626
#include <vector>
2727
#include <string>
2828
#include <map>
29-
#include "json/json.h"
29+
#include <json/json.h>
3030
#include "config.h"
3131

3232
#define MODNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_"

src/script/common/c_content.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3333
#include "porting.h"
3434
#include "mg_schematic.h"
3535
#include "noise.h"
36-
#include "json/json.h"
36+
#include <json/json.h>
3737

3838
struct EnumString es_TileAnimationType[] =
3939
{
@@ -1250,8 +1250,13 @@ static bool push_json_value_helper(lua_State *L, const Json::Value &value,
12501250
lua_newtable(L);
12511251
for (Json::Value::const_iterator it = value.begin();
12521252
it != value.end(); ++it) {
1253+
#ifndef JSONCPP_STRING
12531254
const char *str = it.memberName();
12541255
lua_pushstring(L, str ? str : "");
1256+
#else
1257+
std::string str = it.name();
1258+
lua_pushstring(L, str.c_str());
1259+
#endif
12551260
push_json_value_helper(L, *it, nullindex);
12561261
lua_rawset(L, -3);
12571262
}

src/script/lua_api/l_util.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2323
#include "common/c_content.h"
2424
#include "cpp_api/s_async.h"
2525
#include "serialization.h"
26-
#include "json/json.h"
26+
#include <json/json.h>
2727
#include "cpp_api/s_security.h"
2828
#include "porting.h"
2929
#include "debug.h"

src/serverlist.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929
#include "porting.h"
3030
#include "log.h"
3131
#include "network/networkprotocol.h"
32-
#include "json/json.h"
32+
#include <json/json.h>
3333
#include "convert_json.h"
3434
#include "httpfetch.h"
3535
#include "util/string.h"

src/serverlist.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2020
#include <iostream>
2121
#include "config.h"
2222
#include "mods.h"
23-
#include "json/json.h"
23+
#include <json/json.h>
2424

2525
#ifndef SERVERLIST_HEADER
2626
#define SERVERLIST_HEADER

0 commit comments

Comments
 (0)