DOE OSTI · 1493023
A JSON to CMake tool
Abstract
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.
Explore related subjects
Keep this discovery
Explore connections, maps & timelines
Zukaitis, Anthony J., Dixon, David A., McCartney, Austin Paul. 2019-01-29. A JSON to CMake tool. https://doi.org/10.2172/1493023
Cite the original work for its findings. Save a collection to share your selection of sources.