message(STATUS "Disabling model BMF because Eigen3 was not found. If it's installed, use EIGEN3_HINT to hint cmake about the location of Eigen3Config.cmake")
endif()
+# Check for our JSON dependency
+set(SIMGRID_HAVE_JSON 0)
+find_package(nlohmann_json 3.11.2
+ HINTS ${nlohmann_json_HINT})
+if (nlohmann_json_FOUND)
+ set(SIMGRID_HAVE_JSON 1)
+ message(STATUS "Found nlohmann_json: ${NLOHMANN_JSON_INCLUDE_DIR}")
+ include_directories(${NLOHMANN_JSON_INCLUDE_DIR})
+endif()
+
set(HAVE_PAPI 0)
if(enable_smpi_papi)
include(FindPAPI)
- On CentOS / Fedora: ``dnf install eigen3-devel``
- On macOS with homebrew: ``brew install eigen``
- Use EIGEN3_HINT to specify where it's installed if cmake doesn't find it automatically.
+JSON (optional, for the DAG wfcommons loader)
+ - On Debian / Ubuntu: ``apt install nlohmann-json3-dev``
+ - Use nlohmann_json_HINT to specify where it's installed if cmake doesn't find it automatically.
For platform-specific details, please see below.
#cmakedefine NS3_MINOR_VERSION @NS3_MINOR_VERSION@
/* Was the Eigen3 support compiled in? */
#cmakedefine01 SIMGRID_HAVE_EIGEN3
+/* Was the JSON support compiled in? */
+#cmakedefine01 SIMGRID_HAVE_JSON
#endif /* SIMGRID_PUBLIC_CONFIG_H */
-/* Copyright (c) 2009-2023. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "dax_dtd.h"
#include "dax_dtd.c"
+#if SIMGRID_HAVE_JSON
#include <nlohmann/json.hpp>
+#endif
#if HAVE_GRAPHVIZ
#include <graphviz/cgraph.h>
*/
std::vector<ActivityPtr> create_DAG_from_json(const std::string& filename)
{
+#if SIMGRID_HAVE_JSON
std::ifstream f(filename);
auto data = nlohmann::json::parse(f);
std::vector<ActivityPtr> dag = {};
activity->start();
}
return dag;
+#else
+ xbt_die("JSON support was not compiled in, probably because nlohmann/json was not found. Please install "
+ "nlohmann-json3-dev and recompile SimGrid to use this feature.");
+#endif
}
-
/** @brief loads a DAX file describing a DAG
*
* See https://confluence.pegasus.isi.edu/display/pegasus/WorkflowGenerator for more details.
endif()
endif()
+if(SIMGRID_HAVE_JSON)
+ target_link_libraries(simgrid nlohmann_json::nlohmann_json)
+endif()
+
if(NOT ${DL_LIBRARY} STREQUAL "")
SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
endif()
--- /dev/null
+include(FindPackageHandleStandardArgs)
+set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE})
+find_package_handle_standard_args(nlohmann_json CONFIG_MODE)
+
+if(NOT TARGET nlohmann_json::nlohmann_json)
+ include("${CMAKE_CURRENT_LIST_DIR}/nlohmann_jsonTargets.cmake")
+ if((NOT TARGET nlohmann_json) AND
+ (NOT nlohmann_json_FIND_VERSION OR
+ nlohmann_json_FIND_VERSION VERSION_LESS 3.2.0))
+ add_library(nlohmann_json INTERFACE IMPORTED)
+ set_target_properties(nlohmann_json PROPERTIES
+ INTERFACE_LINK_LIBRARIES nlohmann_json::nlohmann_json
+ )
+ endif()
+endif()