Skip to main content
U.S. Department of Energy
Office of Scientific and Technical Information

A JSON to CMake tool

Technical Report ·
DOI:https://doi.org/10.2172/1493023· OSTI ID:1493023
 [1];  [1];  [1]
  1. Los Alamos National Lab. (LANL), Los Alamos, NM (United States)

As part of the conversion of the MCNP®testing system to CTest, a tool was needed to generate CMake variables from JSON formatted data structure. The system was first implemented using the JSON to CMake parser which with some slight modifications provided data useful for the MCNP CTest testing system. Upon further evaluation, we found it to be slow when setting up the 1600 tests during the CMake configuration step. Not only was it slow, it did not validate the JSON files during configuration allowing for unexpected behavior. Upon some web searching we came across a simple recursive python example that would provide the same capability needed by our testing system. This python example was effectively wrapped into a single python script that was used to convert the JSON data into CMake variables. This tool is attached as json_to_cmake.py and is listed in the appendix. In essence, the tool provides single variables for each value defined within the JSON file. The name for the variable is constructed by using the associated object names and array indicies needed to deference the variable itself. In the following sections, examples are provided to better describe how this is done.

Research Organization:
Los Alamos National Laboratory (LANL), Los Alamos, NM (United States)
Sponsoring Organization:
USDOE
DOE Contract Number:
89233218CNA000001
OSTI ID:
1493023
Report Number(s):
LA-UR--19-20675
Country of Publication:
United States
Language:
English

Similar Records

TriBITS (Tribal Build, Integrate, and Test System)
Software · Thu May 16 00:00:00 EDT 2013 · OSTI ID:1256079

TriBITS (Tribal Build, Integrate, and Test System)
Software · Tue May 14 20:00:00 EDT 2013 · OSTI ID:code-2523

CMinx: A CMake Documentation Generator
Journal Article · Tue Sep 27 00:00:00 EDT 2022 · Journal of Open Source Software · OSTI ID:1890187

Related Subjects