1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

cmake: adhere to WITH_CONFIG option

This commit is contained in:
Steffen Vogel 2019-04-05 11:01:49 +02:00
parent 6f37b17953
commit 8678f236a7
10 changed files with 21 additions and 18 deletions

View file

@ -117,7 +117,7 @@ endif()
option(WITH_HOOKS "Build with support for processing hook plugins" ON)
option(WITH_WEB "Build with internal webserver" ON)
option(WITH_API "Build with remote control API" ON)
option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON)
option(WITH_CONFIG "Build with support for libconfig configuration syntax" ${LIBCONFIG_FOUND})
option(WITH_SRC "Build villas-* executables" ${TOPLEVEL_PROJECT})
option(WITH_TOOLS "Build auxilary tools" ${TOPLEVEL_PROJECT})
option(WITH_TESTS "Run tests" ${TOPLEVEL_PROJECT})

View file

@ -50,10 +50,10 @@ protected:
/** Decode configuration file. */
void decode();
#ifdef LIBCONFIG_FOUND
#ifdef WITH_CONFIG
/** Convert libconfig .conf file to libjansson .json file. */
void libconfigDecode();
#endif /* LIBCONFIG_FOUND */
#endif /* WITH_CONFIG */
/** Load configuration from standard input (stdim). */
void loadFromStdio();

View file

@ -24,19 +24,19 @@
#include <jansson.h>
#ifdef LIBCONFIG_FOUND
#include <libconfig.h>
#endif /* LIBCONFIG_FOUND */
#ifdef WITH_CONFIG
#include <libconfig.h>
#endif /* WITH_CONFIG */
#include <villas/sample.h>
#ifdef LIBCONFIG_FOUND
#ifdef WITH_CONFIG
/** Convert a libconfig object to a jansson object */
json_t *config_to_json(config_setting_t *cfg);
/** Convert a jansson object into a libconfig object. */
int json_to_config(json_t *json, config_setting_t *parent);
#endif /* LIBCONFIG_FOUND */
#endif /* WITH_CONFIG */
int json_object_extend_str(json_t *orig, const char *str);

View file

@ -51,6 +51,7 @@
#cmakedefine WITH_WEB
#cmakedefine WITH_API
#cmakedefine WITH_HOOKS
#cmakedefine WITH_CONFIG
/* OS Headers */
#cmakedefine HAS_EVENTFD

View file

@ -46,7 +46,7 @@ public:
{ }
};
#ifdef LIBCONFIG_FOUND
#ifdef WITH_CONFIG
class LibconfigParseError : public ParseError {
protected:
@ -62,7 +62,7 @@ public:
config(c)
{ }
};
#endif /* LIBCONFIG_FOUND */
#endif /* WITH_CONFIG */
class JanssonParseError : public ParseError {

View file

@ -78,7 +78,7 @@ list(APPEND WHOLE_ARCHIVES nodes)
add_subdirectory(formats)
list(APPEND WHOLE_ARCHIVES formats)
if(LIBCONFIG_FOUND)
if(WITH_CONFIG)
list(APPEND INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS})
list(APPEND LIBRARIES PkgConfig::LIBCONFIG)
endif()

View file

@ -113,15 +113,16 @@ void Config::decode()
root = json_loadf(local_file, 0, &err);
if (root == nullptr) {
#ifdef LIBCONFIG_FOUND
#ifdef WITH_CONFIG
/* We try again to parse the config in the legacy format */
libconfigDecode();
#else
throw JanssonParseError(err);
#endif /* LIBCONFIG_FOUND */
#endif /* WITH_CONFIG */
}
}
#ifdef WITH_CONFIG
void Config::libconfigDecode()
{
int ret;
@ -158,6 +159,7 @@ void Config::libconfigDecode()
config_destroy(&cfg);
}
#endif /* WITH_CONFIG */
void Config::prettyPrintError(json_error_t err)
{

View file

@ -29,7 +29,7 @@
#include <villas/config_helper.hpp>
#include <villas/utils.h>
#ifdef LIBCONFIG_FOUND
#ifdef WITH_CONFIG
static int json_to_config_type(int type)
{
@ -166,7 +166,7 @@ int json_to_config(json_t *json, config_setting_t *parent)
return 0;
}
#endif /* LIBCONFIG_FOUND */
#endif /* WITH_CONFIG */
void json_object_extend_key_value_token(json_t *obj, const char *key, const char *value)
{

View file

@ -22,7 +22,7 @@
#include <criterion/criterion.h>
#ifdef LIBCONFIG_FOUND
#ifdef WITH_CONFIG
#include <jansson.h>
#include <libconfig.h>
@ -117,4 +117,4 @@ Test(utils, json_to_config)
json_decref(json);
}
#endif /* LIBCONFIG_FOUND */
#endif /* WITH_CONFIG */

View file

@ -20,7 +20,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###################################################################################
if(LIBCONFIG_FOUND)
if(WITH_CONFIG)
add_executable(conf2json conf2json.cpp)
target_link_libraries(conf2json PUBLIC villas)