# Generate a static library target named "bitmaps"
# (with filename libbitmaps.a on Linux)

# Copy the *.xpm files to ${XPM_CPP_PATH}/*.cpp, on change only.
# Compile those *.cpp files and put them into the library, then done.

# bitmap file names should be all lowercase and basename thereof should also
# be a valid C++ identifier name.  This means no leading number, or embedded - or +

set(BITMAP_SRCS
    add_arc.xpm
    add_bus2bus.xpm
    add_bus.xpm
    add_circle.xpm
    add_component.xpm
    add_corner.xpm
    add_dashed_line.xpm
    add_dimension.xpm
    add_entry.xpm
    add_glabel.xpm
    add_hierarchical_label.xpm
    add_hierar_pin.xpm
    add_hierar_subsheet.xpm
    add_junction.xpm
    add_line2bus.xpm
    add_line_label.xpm
    add_line.xpm
    add_mires.xpm
    add_polygon.xpm
    add_power.xpm
    add_rectangle.xpm
    add_text.xpm
    add_tracks.xpm
    add_zone_cutout.xpm
    add_zone.xpm
    anchor.xpm
    annotate_down_right.xpm
    annotate_right_down.xpm
    annotate.xpm
    apply.xpm
    auto_associe.xpm
    auto_delete_track.xpm
    auto_track_width.xpm
    axis3d_back.xpm
    axis3d_bottom.xpm
    axis3d_front.xpm
    axis3d_left.xpm
    axis3d_right.xpm
    axis3d_top.xpm
    axis3d.xpm
    bom.xpm
    book.xpm
    break_bus.xpm
    break_line.xpm
    browse_files.xpm
    cancel_tool.xpm
    cancel.xpm
    create_cmp_file.xpm
    checked_ok.xpm
    component_select_unit.xpm
    component_select_alternate_shape.xpm
    config.xpm
    copyblock.xpm
    copycomponent.xmp
    copy_button.xpm
    copper_layers_setup.cpp
    cursor_shape.xpm
    cursor.xpm
    cut_button.xpm
    cvpcb.xpm
    dashline.xpm
    datasheet.xpm
    delete_body.xpm
    delete_arc.xpm
    delete_association.xpm
    delete_bus.xpm
    delete_circle.xpm
    delete_connection.xpm
    delete_cotation.xpm
    delete_field.xpm
    delete_glabel.xpm
    delete_line.xpm
    delete_module.xpm
    delete_net.xpm
    delete_node.xpm
    delete_pad.xpm
    delete_pinsheet.xpm
    delete_pin.xpm
    delete_polygon.xpm
    delete_rectangle.xpm
    delete_segment.xpm
    delete_sheet.xpm
    delete_text.xpm
    delete_track.xpm
    delete.xpm
    directory.xpm
    display_options.xpm
    down.xpm
    drag_module.xpm
    drag_outline_segment.xpm
    drag_pad.xpm
    drag_segment_withslope.xpm
    drag_track_segment.xpm
    drc_off.xpm
    drc.xpm
    edges_sketch.xpm
    edit_comp_footprint.xpm
    edit_component.xpm
    edit_comp_ref.xpm
    edit_comp_value.xpm
    edit_module.xpm
    editor.xpm
    edit_part.xpm
    edit_sheet.xpm
    edit_text.xpm
    edit.xpm
    eeschema.xpm
    enter_sheet.xpm
    ercerr.xpm
    erc_green.xpm
    ercwarn.xpm
    erc.xpm
    exit.xpm
    export_footprint_names.xpm
    export_module.xpm
    export_options_pad.xpm
    export.xpm
    fabrication.xpm
    file_footprint.xpm
    fill_zone.xpm
    find_xpm.xpm
    flag.xpm
    fonts.xpmr
    footprint_text.xpm
    gbr_select_mode0.xpm
    gbr_select_mode1.xpm
    gbr_select_mode2.xpm
    gerber_file.xpm
    gerber_recent_files.xpm
    gerbview_drill_file.xpm
    gerbview_clear_layers.xpm
    gerber_open_dcode_file.xpm
    general_deletions.xpm
    general_ratsnet.xpm
    glabel2label.xpm
    glabel2text.xpm
    gl_change.xpm
    global_options_pad.xpm
    green.xpm
    grid_select.xpm
    grid_select_axis.xpm
    grid.xpm
    hammer.xpm
    help.xpm
    hidden_pin.xpm
    hierarchy_cursor.xpm
    hierarchy_nav.xpm
    hotkeys.xpm
    icon_3d.xpm
    icon_cvpcb_small.xpm
    icon_cvpcb.xpm
    icon_eeschema.xpm
    icon_gerbview_small.xpm
    icon_gerbview.xpm
    icon_kicad.xpm
    icon_modedit.xpm
    icon_pcbnew.xpm
    icon_pcbcalculator.xpm
    icon_bitmap2component.xpm
    icon_txt.xpm
    import3d.xpm
    image.xpm
    import_cmp_from_lib.xpm
    import_footprint_names.xpm
    import_hierarchical_label.xpm
    import_module.xpm
    import.xpm
    info.xpm
    insert_module_board.xpm
    invert_module.xpm
    invisible_text.xpm
    jigsaw.xpm
    kicad_icon_small.xpm
    label2glabel.xpm
    label2text.xpm
    label.xpm
    lang_catalan.xpm
    lang_chinese.xpm
    lang_cs.xpm
    lang_default.xpm
    lang_de.xpm
    lang_en.xpm
    lang_es.xpm
    lang_fr.xpm
    lang_fi.xpm
    lang_gr.xpm
    lang_hu.xpm
    lang_it.xpm
    lang_jp.xpm
    lang_ko.xpm
    lang_nl.xpm
    lang_pl.xpm
    lang_pt.xpm
    lang_ru.xpm
    lang_sl.xpm
    language.xpm
    layers_manager.xpm
    leave_sheet.xpm
    left.xpm
    libedit_icon.xpm
    libedit.xpm
    libedprt.xpm
    lib_next.xpm
    lib_previous.xpm
    library_browse.xpm
    library_update.xpm
    library.xpm
    libsavem.xpm
    libview.xpm
    lines90.xpm
    load_module_board.xpm
    load_module_lib.xpm
    local_ratsnest.xpm
    locked.xpm
    mirepcb.xpm
    mirror_h.xpm
    mirror_v.xpm
    modedit.xpm
    mode_module.xpm
    mode_track.xpm
    modratsnest.xpm
    module_check.xpm
    modul_edit.xpm
    module_filtered_list.xpm
    module_full_list.xpm
    module_options.xpm
#    module_ratsnest.xpm
    module.xpm
    morgan1.xpm
    morgan2.xpm
    move_arc.xpm
    move_circle.xpm
    move_field.xpm
    move_glabel.xpm
    move_line.xpm
    move_module.xpm
    move_pad.xpm
    move_pinsheet.xpm
    move_pin.xpm
    move_polygon.xpm
    move_rectangle.xpm
    move_sheet.xpm
    move_text.xpm
    move_track_segment.xpm
    move_track.xpm
    move.xpm
    mw_add_gap.xpm
    mw_add_line.xpm
    mw_add_shape.xpm
    mw_add_stub_arc.xpm
    mw_add_stub.xpm
    mw_toolbar.xpm
    net_highlight.xpm
    netlist.xpm
    net_locked.xpm
    net_unlocked.xpm
    new_component.xpm
    new_cvpcb.xpm
    new_footprint.xpm
    new_library.xpm
    new_module.xpm
    new_pcb.xpm
    new_project.xpm
    new_sch.xpm
    new_txt.xpm
    new.xpm
    noconn.xpm
    normal.xpm
    online_help.xpm
    open_library.xpm
    open_project.xpm
    open_document.xpm
    options_all_tracks_and_vias.xpm
    options_all_tracks.xpm
    options_all_vias.xpm
    options_arc.xpm
    options_circle.xpm
    options_module.xpm
    options_new_pad.xpm
    options_pad.xpm
    options_pinsheet.xpm
    options_pin.xpm
    options_rectangle.xpm
    options_segment.xpm
    options_text.xpm
    options_tracks.xpm
    options_track.xpm
    options_vias.xpm
    opt_show_polygon.xpm
    orient.xpm
    ortho.xpm
    pad_sketch.xpm
    pad.xpm
    pads_mask_layers.xpm
    palette.xpm
    part_properties.xpm
    paste.xpm
    pcbnew.xpm
    pcboffset.xpm
    pin2pin.xpm
    pin_name_to.xpm
    pin_number_to.xpm
    pin_size_to.xpm
    pinorient_right.xpm
    pinorient_left.xpm
    pinorient_up.xpm
    pinorient_down.xpm
    pinshape_normal.xpm
    pinshape_invert.xpm
    pinshape_clock_normal.xpm
    pinshape_clock_invert.xpm
    pinshape_active_low_input.xpm
    pinshape_clock_active_low.xpm
    pinshape_active_low_output.xpm
    pinshape_clock_fall.xpm
    pinshape_nonlogic.xpm
    pintype_input.xpm
    pintype_output.xpm
    pintype_bidi.xpm
    pintype_3states.xpm
    pintype_passive.xpm
    pintype_notspecif.xpm
    pintype_powerinput.xpm
    pintype_poweroutput.xpm
    pintype_opencoll.xpm
    pintype_openemit.xpm
    pintype_noconnect.xpm
    pin_to.xpm
    pin.xpm
    plot_hpg.xpm
    plot_ps.xpm
    plot_xpm.xpm
    polar.xpm
    post_compo.xpm
    post_drill.xpm
    post_module.xpm
    preference.xpm
    print_button.xpm
    ratsnest.xpm
    read_setup.xpm
    redo.xpm
    red.xpm
    reload2.xpm
    reload.xpm
    reset_text.xpm
    resize_sheet.xpm
    right.xpm
    rotate_field.xpm
    rotate_glabel.xpm
    rotate_module_neg.xpm
    rotate_module_pos.xpm
    rotate_pin.xpm
    rotate_ccw.xpm
    rotate_cw.xpm
    rotate_neg_x.xpm
    rotate_pos_x.xpm
    rotate_neg_y.xpm
    rotate_pos_y.xpm
    rotate_neg_z.xpm
    rotate_pos_z.xpm
    save_as.xpm
    save_library.xpm
    save_netlist.xpm
    save_project.xpm
    save_setup.xpm
    save.xpm
    schematic.xpm
    select_grid.xpm
    select_layer_pair.xpm
    select_w_layer.xpm
    shape_3d.xpm
    sheetset.xpm
    showdcode.xpm
    show_footprint.xpm
    showmodedge.xpm
    showtrack.xpm
    show_zone.xpm
    show_zone_disable.xpm
    show_zone_outline_only.xpm
    swap_layer.xpm
    text_sketch.xpm
    three_d.xpm
    tool_ratsnest.xpm
    tools.xpm
    track_locked.xpm
    track_sketch.xpm
    track_unlocked.xpm
    transistor.xpm
    treensel.xpm
    treesel.xpm
    undelete.xpm
    undo.xpm
    unit_inch.xpm
    unit_mm.xpm
    unknown.xpm
    unlocked.xpm
    unzip.xpm
    update_module_board.xpm
    up.xpm
    via_sketch.xpm
    viewlibs_icon.xpm
    web_support.xpm
    width_net.xpm
    width_segment.xpm
    width_track_via.xpm
    width_track.xpm
    width_vias.xpm
    window_close.xpm
    zip_tool.xpm
    zip.xpm
    zoom.xpm
    zoom_area.xpm
    zoom_fit_in_page.xpm
    zoom_center_on_screen.xpm
    zoom_in.xpm
    zoom_out.xpm
    zoom_redraw.xpm
    zoom_selection.xpm
)


# Get the path of the *.xpm files into "PATH"
set(PATH ${CMAKE_CURRENT_SOURCE_DIR})
#message("PATH = ${PATH}")

# The name of the directory to put the copied and renamed *.xpm files into.
# As files are copied they are renamed to *.cpp.
set(XPM_CPP_PATH "${CMAKE_BINARY_DIR}/bitmaps/auto_renamed_to_cpp"
    CACHE PATH "path to store renamed .xpm files for compilation")

foreach(LOOP_VAR ${BITMAP_SRCS})
    get_filename_component(BASENAME ${LOOP_VAR} NAME_WE)
    set(CPP_BITMAP "${XPM_CPP_PATH}/${BASENAME}.cpp")
    add_custom_command(
        OUTPUT ${CPP_BITMAP}
        COMMAND "${CMAKE_COMMAND}" -E copy "${PATH}/${BASENAME}.xpm" "${CPP_BITMAP}"
        DEPENDS ${BASENAME}.xpm)
    list(APPEND CPP_BITMAPS ${CPP_BITMAP})
    set_source_files_properties(${CPP_BITMAP} PROPERTIES COMPILE_FLAGS -DXPMMAIN)
endforeach(LOOP_VAR)

add_library(bitmaps ${CPP_BITMAPS})
