@@ -91,7 +91,8 @@ mark_as_advanced(BUILD_SHARED_LIBS)
9191include (CTest)
9292# automatically defines: BUILD_TESTING, default is ON
9393
94- option (BUILD_EXAMPLES "Build the examples" ON )
94+ option (BUILD_CLI_TOOLS "Build the command line tools" ON )
95+ option (BUILD_EXAMPLES "Build the examples" ON )
9596
9697
9798# Dependencies ################################################################
@@ -312,7 +313,8 @@ set(CORE_SOURCE
312313 src/backend/PatchRecord.cpp
313314 src/backend/PatchRecordComponent.cpp
314315 src/backend/Writable.cpp
315- src/benchmark/mpi/OneDimensionalBlockSlicer.cpp)
316+ src/benchmark/mpi/OneDimensionalBlockSlicer.cpp
317+ src/helper/list_series.cpp)
316318set (IO_SOURCE
317319 src/IO/AbstractIOHandlerHelper.cpp
318320 src/IO/DummyIOHandler.cpp
@@ -525,6 +527,7 @@ if(openPMD_HAVE_PYTHON)
525527 src/binding/python/Container.cpp
526528 src/binding/python/Dataset.cpp
527529 src/binding/python/Datatype.cpp
530+ src/binding/python/Helper.cpp
528531 src/binding/python/Iteration.cpp
529532 src/binding/python/IterationEncoding.cpp
530533 src/binding/python/Mesh.cpp
@@ -588,6 +591,10 @@ set(openPMD_TEST_NAMES
588591 SerialIO
589592 ParallelIO
590593)
594+ # command line tools
595+ set (openPMD_CLI_TOOL_NAMES
596+ ls
597+ )
591598# examples
592599set (openPMD_EXAMPLE_NAMES
593600 1_structure
@@ -653,6 +660,13 @@ if(BUILD_TESTING)
653660 endforeach ()
654661endif ()
655662
663+ if (BUILD_CLI_TOOLS)
664+ foreach (toolname ${openPMD_CLI_TOOL_NAMES} )
665+ add_executable (openpmd-${toolname} src/cli/${toolname} .cpp)
666+ target_link_libraries (openpmd-${toolname} PRIVATE openPMD)
667+ endforeach ()
668+ endif ()
669+
656670if (BUILD_EXAMPLES)
657671 foreach (examplename ${openPMD_EXAMPLE_NAMES} )
658672 if (${examplename} MATCHES ".+parallel$" )
@@ -761,6 +775,12 @@ if(openPMD_HAVE_ADIOS1)
761775 openPMD.ADIOS1.Serial openPMD.ADIOS1.Parallel)
762776endif ()
763777
778+ if (BUILD_CLI_TOOLS)
779+ foreach (toolname ${openPMD_CLI_TOOL_NAMES} )
780+ list (APPEND openPMD_INSTALL_TARGET_NAMES openpmd-${toolname} )
781+ endforeach ()
782+ endif ()
783+
764784install (TARGETS ${openPMD_INSTALL_TARGET_NAMES}
765785 EXPORT openPMDTargets
766786 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -919,6 +939,25 @@ if(BUILD_EXAMPLES)
919939 endif ()
920940endif ()
921941
942+ # Command Line Tools ##################################################
943+ #
944+ if (BUILD_CLI_TOOLS)
945+ # all tools must provide a "--help"
946+ foreach (toolname ${openPMD_CLI_TOOL_NAMES} )
947+ list (APPEND openPMD_INSTALL_TARGET_NAMES openpmd-${toolname} )
948+ add_test (NAME CLI.help.${toolname}
949+ COMMAND openpmd-${toolname} --help
950+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
951+ )
952+ endforeach ()
953+ if (openPMD_HAVE_HDF5 AND EXISTS "${openPMD_BINARY_DIR} /samples/git-sample/" )
954+ add_test (NAME CLI.ls
955+ COMMAND openpmd-ls ../samples/git-sample/data%08T.h5
956+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
957+ )
958+ endif ()
959+ endif ()
960+
922961# Python Examples
923962# Current examples all use HDF5, elaborate if other backends are used
924963if (openPMD_HAVE_PYTHON AND openPMD_HAVE_HDF5)
0 commit comments