Chapter 3.2 : The runPythonExample function
We will need also a function to call our python example and get the performances automatically.The runPythonExample is built the same way than the runExample function :
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function(runPythonExample scriptName installModuleDependency) get_filename_component(targetName ${scriptName} NAME_WE) add_custom_command(OUTPUT ${OUTPUT_PERF_DIR}/${targetName}.txt COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/${scriptName} 2> ${OUTPUT_PERF_DIR}/${targetName}.txt WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" COMMENT "Run python3 ${scriptName} program with target ${targetName}" DEPENDS ${scriptName} ) add_custom_target("run_${targetName}" DEPENDS ${OUTPUT_PERF_DIR}/${targetName}.txt) add_dependencies("run_${targetName}" ${installModuleDependency}) add_dependencies(run_all "run_${targetName}") endfunction(runPythonExample) |