add_custom_target(profiling_planning)

function(tyr_add_profiler name source)
    add_executable(${name} ${source})
    target_link_libraries(${name} PRIVATE tyr::core benchmark::benchmark Boost::json)
    add_dependencies(profiling_planning ${name})
endfunction()

foreach(backend ground lifted)
    if(backend STREQUAL "ground")
        set(task_kind GroundTag)
    else()
        set(task_kind LiftedTag)
    endif()

    tyr_add_profiler(astar_blind_${backend} search/astar_blind.cpp)
    target_compile_definitions(astar_blind_${backend} PRIVATE TYR_PROFILE_TASK_KIND=${task_kind})

    tyr_add_profiler(successors_${backend} successor_generation/all_actions.cpp)
    tyr_add_profiler(schema_selection_${backend} successor_generation/${backend}/schema_selection.cpp)

    foreach(heuristic rpg_add rpg_ff lmcut)
        if(heuristic STREQUAL "rpg_add")
            set(heuristic_type AddRPGHeuristic)
        elseif(heuristic STREQUAL "rpg_ff")
            set(heuristic_type FFRPGHeuristic)
        else()
            set(heuristic_type LMCutHeuristic)
        endif()
        tyr_add_profiler(gbfs_${heuristic}_${backend} search/gbfs.cpp)
        target_compile_definitions(gbfs_${heuristic}_${backend} PRIVATE TYR_PROFILE_HEURISTIC=${heuristic_type})
        if(backend STREQUAL "ground")
            target_compile_definitions(gbfs_${heuristic}_${backend} PRIVATE TYR_PROFILE_GROUND)
        endif()
    endforeach()
    if(backend STREQUAL "ground")
        target_compile_definitions(successors_${backend} PRIVATE TYR_PROFILE_GROUND)
    endif()
endforeach()
