You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

922 lines
22 KiB

5 years ago
3 years ago
  1. # This program source code file is part of KICAD, a free EDA CAD application.
  2. #
  3. # Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  4. # Copyright (C) 2011-2022 Kicad Developers, see AUTHORS.txt for contributors.
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, you may find one here:
  18. # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. # or you may search the http://www.gnu.org website for the version 2 license,
  20. # or you may write to the Free Software Foundation, Inc.,
  21. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. #
  23. # In this directory, a number of different processes are managed:
  24. #
  25. # 1) PNG files are created from SVG files for each icon theme and needed bitmap resolution
  26. # 2) An images.tar.gz file is created from all the PNG files
  27. # Step 2) is universal and is done for any builder, whereas step 1) is
  28. # optional and depend on MAINTAIN_PNGS being defined in CMake. The reason we
  29. # can skip 1) is that the *.PNG files are part of the source tree so
  30. # do not need to rebuilt by a typical builder. However, because the *.PNG files
  31. # are part of the source tree, and subject to version control, they should be built
  32. # only when needed, otherwise this results in a diff for the version control system.
  33. # Therefore step 1) is driven by CMake (if MAINTAIN_PNGS) which gives
  34. # us conditional *.PNG building based on an edit to the respective *.SVG file.
  35. # If MAINTAIN_PNGS is not defined, then you are a normal builder and no special
  36. # tools are required. If MAINTAIN_PNGS is defined, then you are a PNG maintainer
  37. # and will need the following tools findable in your PATH:
  38. #
  39. # 1) inkscape - command line mode is used, must be on your PATH
  40. # 2) pngcrush - this program must be on your PATH
  41. #
  42. # lower case is used for local variables, uppercase for global variables
  43. option( MAINTAIN_PNGS
  44. "Set to true if you are a PNG maintainer and have the required tools given in the resources/bitmaps_png/CMakeLists.txt file (default OFF)."
  45. OFF)
  46. # Used Only to maintain PNG files (and therefore to recreate .cpp files)
  47. # The png2cpp creates files with native End of Line format.
  48. # List of themes - each corresponds to a folder of SVGS in ./resources/bitmaps_png/sources/
  49. set( THEMES
  50. light
  51. dark )
  52. # Plan for three sizes of bitmaps:
  53. # SMALL - for menus - 16 x 16
  54. # MID - for toolbars - 24 x 24
  55. # BIG - for program icons - 48 x 48
  56. # which are given on three basename lists: BMAPS_SMALL, BMAPS_MID,and BMAPS_BIG
  57. # respectively. The basename is without file extension and without path.
  58. # A corresponding ${basename}.svg file must exist in 'sources' dir below here.
  59. # small icons (16x16) needed in listboxes and dialog buttons
  60. set( BMAPS_SMALL
  61. e_24
  62. e_48
  63. e_96
  64. e_192
  65. icon_bitmap2component_16
  66. icon_eeschema_16
  67. icon_gerbview_16
  68. icon_kicad_16
  69. icon_kicad_nightly_16
  70. icon_libedit_16
  71. icon_modedit_16
  72. icon_pagelayout_editor_16
  73. icon_pcbcalculator_16
  74. icon_pcbnew_16
  75. label_align_left
  76. label_align_right
  77. label_align_top
  78. label_align_bottom
  79. list_nets_16
  80. options_generic_16
  81. pinorient_right
  82. pinorient_left
  83. pinorient_up
  84. pinorient_down
  85. pinshape_normal
  86. pinshape_invert
  87. pinshape_clock_normal
  88. pinshape_clock_invert
  89. pinshape_active_low_input
  90. pinshape_clock_active_low
  91. pinshape_active_low_output
  92. pinshape_clock_fall
  93. pinshape_nonlogic
  94. pintype_input
  95. pintype_output
  96. pintype_bidi
  97. pintype_3states
  98. pintype_passive
  99. pintype_notspecif
  100. pintype_powerinput
  101. pintype_poweroutput
  102. pintype_opencoll
  103. pintype_openemit
  104. pintype_nic
  105. pintype_noconnect
  106. small_down
  107. small_edit
  108. small_folder
  109. small_library
  110. small_plus
  111. small_refresh
  112. small_sort_desc
  113. small_trash
  114. small_up
  115. small_warning
  116. text_horizontal
  117. text_vertical
  118. text_align_left
  119. text_align_center
  120. text_align_right
  121. text_align_bottom
  122. text_align_middle
  123. text_align_top
  124. text_valign_top
  125. text_valign_center
  126. text_valign_bottom
  127. text_bold
  128. text_italic
  129. text_mirrored
  130. tree_nosel
  131. tree_sel
  132. visibility
  133. visibility_off
  134. www
  135. )
  136. # image basenames that go into the toolbar sized destinations, i.e. 24x24
  137. set( BMAPS_MID
  138. about
  139. add_aligned_dimension
  140. add_arc
  141. add_board
  142. add_bus2bus
  143. add_bus
  144. add_center_dimension
  145. add_class_flag
  146. add_circle
  147. add_component
  148. add_corner
  149. add_dashed_line
  150. add_document
  151. add_glabel
  152. add_graphical_segments
  153. add_graphical_polygon
  154. add_hierarchical_label
  155. add_hierar_pin
  156. add_hierarchical_subsheet
  157. add_junction
  158. add_keepout_area
  159. add_label
  160. add_leader
  161. add_library
  162. add_line2bus
  163. add_line_label
  164. add_line
  165. add_orthogonal_dimension
  166. add_pcb_target
  167. add_power
  168. add_radial_dimension
  169. add_rectangle
  170. add_symbol_to_schematic
  171. add_textbox
  172. add_tracks
  173. add_via
  174. add_zone_cutout
  175. add_zone
  176. align_items
  177. align_items_left
  178. align_items_right
  179. align_items_top
  180. align_items_bottom
  181. align_items_center
  182. align_items_middle
  183. anchor
  184. annotate_down_right
  185. annotate_right_down
  186. annotate
  187. apply_pad_settings
  188. array
  189. auto_associate
  190. auto_track_width
  191. autoplace_fields
  192. axis3d_back
  193. axis3d_bottom
  194. axis3d_front
  195. axis3d_left
  196. axis3d_right
  197. axis3d_top
  198. axis3d
  199. break_line
  200. bug
  201. bus_definition_tool
  202. cancel
  203. change_entry_orient
  204. contrast_mode
  205. curved_ratsnest
  206. checked_ok
  207. color_materials
  208. component_select_unit
  209. config
  210. convert
  211. copy
  212. copy_pad_settings
  213. cursor_shape
  214. cursor
  215. custom_pad_to_primitives
  216. cut
  217. datasheet
  218. delete_association
  219. delete_cursor
  220. delete_gerber
  221. delete_sheet
  222. directory
  223. directory_browser
  224. directory_open
  225. distribute_horizontal
  226. distribute_vertical
  227. down
  228. drag
  229. drag_segment_withslope
  230. drc
  231. duplicate
  232. edit_comp_footprint
  233. edit_comp_ref
  234. edit_comp_value
  235. editor
  236. edit_cmp_symb_links
  237. edit
  238. edge_to_copper_clearance
  239. enter_sheet
  240. ercerr
  241. erc_green
  242. ercwarn
  243. erc
  244. exit
  245. exchange
  246. export3d
  247. export_cmp
  248. export_dsn
  249. export_idf
  250. export_file
  251. export_footprint_names
  252. export_module
  253. export_part
  254. export_png
  255. export_step
  256. export_svg
  257. export_to_pcbnew
  258. fabrication
  259. file_bom
  260. file_drl
  261. file_dsn
  262. file_gbr
  263. file_gerber_job
  264. file_html
  265. file_idf
  266. file_pdf
  267. file_pos
  268. file_svg
  269. fill_zone
  270. filter
  271. find
  272. find_replace
  273. flag
  274. flip_board
  275. gbr_select_mode1
  276. gbr_select_mode2
  277. gerbview_show_negative_objects
  278. general_deletions
  279. general_ratsnest
  280. grid_select
  281. grid_select_axis
  282. grid
  283. group
  284. group_enter
  285. group_leave
  286. group_remove
  287. group_ungroup
  288. help
  289. help_online
  290. hidden_pin
  291. hide_ratsnest
  292. hierarchy_nav
  293. hotkeys
  294. hole_to_hole_clearance
  295. hole_to_copper_clearance
  296. hv45mode
  297. icon_cvpcb_24
  298. icon_footprint_browser
  299. icon_gerbview_24
  300. icon_pcm_24
  301. import3d
  302. image
  303. import_brd_file
  304. import_document
  305. import_footprint_names
  306. import_hierarchical_label
  307. import_module
  308. import_part
  309. import_project
  310. import_vector
  311. import
  312. info
  313. insert_module_board
  314. language
  315. layers_manager
  316. leave_sheet
  317. left
  318. libedit
  319. lib_next
  320. lib_previous
  321. library_browser
  322. library_archive
  323. library_archive_as
  324. library
  325. library_table
  326. lines_any
  327. lines90
  328. list_nets
  329. load_drill
  330. load_gerber
  331. load_module_board
  332. lock_unlock
  333. locked
  334. marker_exclude
  335. marker_next
  336. marker_previous
  337. measurement
  338. pcb_target
  339. mirror_h
  340. mirror_v
  341. mode_module
  342. module_editor
  343. module_wizard
  344. module_filtered_list
  345. module_options
  346. module_pin_filtered_list
  347. module_library_list
  348. module
  349. morgan1
  350. morgan2
  351. move_exactly
  352. move
  353. move_relative
  354. mw_add_gap
  355. mw_add_line
  356. mw_add_shape
  357. mw_add_stub_arc
  358. mw_add_stub
  359. net_highlight
  360. net_highlight_schematic
  361. netlist
  362. new_component
  363. new_footprint
  364. new_generic
  365. new_library
  366. new_project
  367. new_project_from_template
  368. noconn
  369. normal
  370. open_project
  371. open_project_demo
  372. options_3drender
  373. options_board
  374. options_generic
  375. options_pad
  376. options_schematic
  377. opt_show_polygon
  378. ortho
  379. pack_footprints
  380. pad_sketch
  381. pad
  382. pad_enumerate
  383. pad_number
  384. pads_mask_layers
  385. pads_remove
  386. path
  387. pagelayout_normal_view_mode
  388. pagelayout_special_view_mode
  389. part_properties
  390. paste
  391. paste_special
  392. pin2pin
  393. pin_size_to
  394. pin_show_etype
  395. pin_table
  396. pin
  397. plot
  398. polar_coord
  399. post_bom
  400. post_compo
  401. post_d356
  402. post_drill
  403. post_gencad
  404. post_gerber
  405. post_rpt
  406. preference
  407. print_button
  408. project
  409. project_close
  410. project_kicad
  411. ps_diff_pair
  412. ps_diff_pair_gap
  413. ps_diff_pair_tune_length
  414. ps_diff_pair_tune_phase
  415. ps_tune_length
  416. push_pad_settings
  417. puzzle_piece
  418. py_script
  419. recent
  420. redo
  421. refresh
  422. reload
  423. render_mode
  424. rescue
  425. right
  426. router_len_tuner
  427. router_len_tuner_setup
  428. router_len_tuner_amplitude_decr
  429. router_len_tuner_amplitude_incr
  430. router_len_tuner_dist_decr
  431. router_len_tuner_dist_incr
  432. rotate_ccw
  433. rotate_cw
  434. rotate_ccw_x
  435. rotate_cw_x
  436. rotate_ccw_y
  437. rotate_cw_y
  438. rotate_ccw_z
  439. rotate_cw_z
  440. save_as
  441. save
  442. select_layer_pair
  443. select_w_layer
  444. select_same_sheet
  445. shape_3d
  446. shape_3d_back
  447. sheetset
  448. simulator
  449. sim_command
  450. sim_run
  451. sim_stop
  452. sim_tune
  453. sim_probe
  454. sim_add_signal
  455. slice_line
  456. search_tree
  457. set_origin
  458. show_dcodenumber
  459. show_dnp
  460. show_footprint
  461. show_mod_edge
  462. show_ratsnest
  463. showtrack
  464. show_not_in_posfile
  465. show_other
  466. show_tht
  467. show_smt
  468. show_zone
  469. show_zone_disable
  470. show_zone_outline_only
  471. show_zone_triangulation
  472. show_all_layers
  473. show_no_layers
  474. show_no_copper_layers
  475. show_all_copper_layers
  476. show_all_front_layers
  477. show_all_back_layers
  478. show_front_assembly_layers
  479. show_back_assembly_layers
  480. special_tools
  481. spreadsheet
  482. swap
  483. swap_layer
  484. switch_corner_rounding_shape
  485. text
  486. text_sketch
  487. thermal_spokes
  488. three_d
  489. tool_ratsnest
  490. tools
  491. trash
  492. undo
  493. unit_inch
  494. unit_mil
  495. unit_mm
  496. unknown
  497. unlocked
  498. unzip
  499. up
  500. update_pcb_from_sch
  501. update_sch_from_pcb
  502. via
  503. via_annulus
  504. via_buried
  505. via_microvia
  506. via_sketch
  507. via_diameter
  508. via_hole_diameter
  509. width_conn
  510. width_track_via
  511. width_track
  512. zip
  513. zone_duplicate
  514. zone_fillet
  515. zone_unfill
  516. zoom_area
  517. zoom_auto_fit_in_page
  518. zoom_fit_in_page
  519. zoom_fit_to_objects
  520. zoom_center_on_screen
  521. zoom_in
  522. zoom_out
  523. zoom_selection
  524. )
  525. # 24 x 24 for internal icons
  526. set( BMAPS_24
  527. icon_bitmap2component_24
  528. icon_eeschema_24
  529. icon_gerbview_24
  530. icon_libedit_24
  531. icon_modedit_24
  532. icon_pagelayout_editor_24
  533. icon_pcbcalculator_24
  534. icon_pcbnew_24
  535. )
  536. # 32 x 32 for icon sets
  537. set( BMAPS_32
  538. icon_bitmap2component_32
  539. icon_eeschema_32
  540. icon_gerbview_32
  541. icon_kicad_32
  542. icon_kicad_nightly_32
  543. icon_libedit_32
  544. icon_modedit_32
  545. icon_pagelayout_editor_32
  546. icon_pcbcalculator_32
  547. icon_pcbnew_32
  548. )
  549. # 48 x 48 for now
  550. set( BMAPS_BIG
  551. dialog_warning
  552. icon_3d
  553. icon_cvpcb
  554. icon_eeschema
  555. icon_gerbview
  556. icon_kicad
  557. icon_kicad_nightly
  558. icon_libedit
  559. icon_modedit
  560. icon_pcbnew
  561. icon_bitmap2component
  562. icon_pagelayout_editor
  563. icon_pcbcalculator
  564. icon_pcm
  565. reannotate_down_left
  566. reannotate_down_right
  567. reannotate_left_down
  568. reannotate_left_up
  569. reannotate_right_down
  570. reannotate_right_up
  571. reannotate_up_left
  572. reannotate_up_right
  573. icon_pagelayout_editor
  574. wizard_add_fplib_icon
  575. )
  576. # 64 x 64 for icon sets
  577. set( BMAPS_64
  578. icon_cvpcb
  579. icon_eeschema
  580. icon_gerbview
  581. icon_kicad
  582. icon_kicad_nightly
  583. icon_libedit
  584. icon_modedit
  585. icon_pcbnew
  586. icon_pagelayout_editor
  587. icon_bitmap2component
  588. icon_pcbcalculator
  589. )
  590. # 128 x 128 for icon sets
  591. set( BMAPS_128
  592. icon_cvpcb
  593. icon_eeschema
  594. icon_gerbview
  595. icon_kicad
  596. icon_kicad_nightly
  597. icon_libedit
  598. icon_modedit
  599. icon_pcbnew
  600. icon_pagelayout_editor
  601. icon_bitmap2component
  602. icon_pcbcalculator
  603. )
  604. # Images in this section are generated at whatever resolution is set in the source SVG file
  605. # Use Inkscape Document Properties > Custom Size to set (make sure units are pixels)
  606. # These are used for images in the UI that are not-square or very large (infographics, etc)
  607. set( BMAPS_OTHER
  608. att_bridge
  609. att_pi
  610. att_splitter
  611. att_tee
  612. c_microstrip
  613. coax
  614. color_code_multiplier
  615. color_code_tolerance
  616. color_code_value
  617. color_code_value_and_name
  618. cpw
  619. cpw_back
  620. microstrip
  621. microstrip_zodd_zeven
  622. pads_npth
  623. pads_npth_bottom
  624. pads_npth_top
  625. pads_npth_top_bottom
  626. pads_remove_unused
  627. pads_remove_unused_keep_bottom
  628. pads_reset_unused
  629. rectwaveguide
  630. regul
  631. regul_3pins
  632. stripline
  633. stroke_dash
  634. stroke_dashdot
  635. stroke_dashdotdot
  636. stroke_dot
  637. stroke_solid
  638. teardrop_sizes
  639. teardrop_rect_sizes
  640. teardrop_track_sizes
  641. tune_diff_pair_length_legend
  642. tune_diff_pair_skew_legend
  643. tune_single_track_length_legend
  644. twistedpair
  645. viacalc
  646. )
  647. # @todo keep these in sync with .bzrignore
  648. set( TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" )
  649. # true to generate log files, false to build icon files only
  650. # generate logs is useful only if you have problems
  651. set( CREATE_LOG_FILES false )
  652. #set( BITMAP_INFO_FILE "${CMAKE_SOURCE_DIR}/include/bitmaps/bitmap_info.h" )
  653. set( BITMAP_INFO_FILE "${CMAKE_SOURCE_DIR}/common/bitmap_info.cpp" )
  654. set( BITMAP_INFO_TEMPLATE "${CMAKE_SOURCE_DIR}/include/bitmaps/bitmap_info.cpp.in" )
  655. set( BITMAP_INFO_LIST "" )
  656. set( ALL_PNGS "" )
  657. function( svg2png inputFile outFile pngWidth pngHeight )
  658. #message( "svg2png( inputFile: ${inputFile} outFile: ${outFile} pngWidth: ${pngWidth} pngHeight: ${pngHeight})")
  659. if( CREATE_LOG_FILES )
  660. set( logfile "${TMP_DIR}/${bmn}.inkscape.log" )
  661. else()
  662. if( MSVC )
  663. set( logfile "nul" )
  664. else()
  665. set( logfile "null" )
  666. endif()
  667. endif()
  668. if( ${pngWidth} EQUAL -1 )
  669. set( sizeArgs --export-area-page )
  670. else()
  671. set( sizeArgs -w ${pngWidth} -h ${pngHeight} )
  672. endif()
  673. add_custom_command(
  674. OUTPUT ${outFile}
  675. # this Inkscape command line is for old Inkscape version < 1.0
  676. # COMMAND ${Inkscape_EXECUTABLE} --without-gui --export-area-snap -f ${inputFile} --export-png ${outFile} -w ${pngWidth} -h ${pngHeight} > ${logfile}
  677. # this Inkscape command line is for Inkscape >= 1.0
  678. COMMAND ${Inkscape_EXECUTABLE} --export-area-snap --export-type=png ${inputFile}
  679. --export-filename ${outFile} ${sizeArgs} > ${logfile}
  680. DEPENDS ${inputFile}
  681. COMMENT "Creating ${pngHeight} pixel tall ${outFile}"
  682. VERBATIM
  683. )
  684. endfunction()
  685. # Function png2png
  686. # converts a basic PNG to one
  687. function( png2png inputFile outFile )
  688. if( CREATE_LOG_FILES )
  689. set( logfile "${TMP_DIR}/${bmn}.pngcrush.log" )
  690. else()
  691. if( MSVC )
  692. set( logfile "nul" )
  693. else()
  694. set( logfile "null" )
  695. endif()
  696. endif()
  697. add_custom_command(
  698. OUTPUT ${outFile}
  699. # pngcrush all icons without background to remove any extraneous text records.
  700. COMMAND ${pngcrush_EXECUTABLE} -rem alla ${inputFile} ${outFile} > ${logfile}
  701. DEPENDS ${inputFile}
  702. COMMENT "Creating cleaned file ${outFile}"
  703. )
  704. endfunction()
  705. # Function png2cpp
  706. # converts a single *.png to *.cpp
  707. function( png2cpp inputFile outFile )
  708. add_custom_command(
  709. OUTPUT ${outFile}
  710. COMMAND ${CMAKE_COMMAND} -DinputFile=${inputFile} -DoutCppFile=${outFile}
  711. -P ${KICAD_CMAKE_MODULE_PATH}/BuildSteps/PNG2cpp.cmake
  712. DEPENDS ${inputFile} ${KICAD_CMAKE_MODULE_PATH}/BuildSteps/PNG2cpp.cmake
  713. COMMENT "Creating ${outFile}"
  714. )
  715. endfunction()
  716. # Function bitmap_dir
  717. # Creates build targets for all the source SVGs in the given list, output at the given resolution
  718. # Will create targets for each theme in the THEMES list.
  719. # A height of -1 means to export with the page area rather than scaling to a given resolution.
  720. # This is used for the BMAPS_OTHER list which have varying output sizes.
  721. function( bitmap_dir pngWidth pngHeight bmapList )
  722. set( pngDir "${CMAKE_CURRENT_SOURCE_DIR}/png" )
  723. file( MAKE_DIRECTORY ${pngDir} )
  724. #file( REMOVE_RECURSE ${TMP_DIR} )
  725. file( MAKE_DIRECTORY ${TMP_DIR} )
  726. foreach( theme ${THEMES} )
  727. if( NOT ${theme} STREQUAL "light" )
  728. set( themeTag "_${theme}" )
  729. else()
  730. set( themeTag "" )
  731. endif()
  732. if( ${pngHeight} EQUAL -1 )
  733. set( heightTag "" )
  734. else()
  735. set( heightTag "_${pngHeight}" )
  736. endif()
  737. foreach( bmn ${bmapList} )
  738. set( svgFile "${CMAKE_CURRENT_SOURCE_DIR}/sources/${theme}/${bmn}.svg" )
  739. set( pngFile "${bmn}${themeTag}${heightTag}.png" )
  740. set( pngPath "${pngDir}/${pngFile}" )
  741. set( tmpFile "${TMP_DIR}/${pngFile}" )
  742. if( NOT EXISTS ${svgFile} )
  743. message( "Warning: Source SVG ${svgFile} does not exist!" )
  744. continue()
  745. endif()
  746. #svg2png( inputFile outFile pngWidth pngHeight )
  747. svg2png( ${svgFile} ${tmpFile} ${pngWidth} ${pngHeight} )
  748. #png2png( inputFile outFile )
  749. png2png( ${tmpFile} ${pngPath} )
  750. set( bitmapInfo
  751. " aBitmapInfoCache[BITMAPS::${bmn}].emplace_back( BITMAPS::${bmn}, wxT( \"${pngFile}\" ), ${pngHeight}, wxT( \"${theme}\" ) );\n"
  752. )
  753. set( BITMAP_INFO_LIST "${BITMAP_INFO_LIST}${bitmapInfo}" )
  754. list( APPEND ALL_PNGS ${pngPath} )
  755. endforeach()
  756. endforeach()
  757. set( ALL_PNGS ${ALL_PNGS} PARENT_SCOPE )
  758. set( BITMAP_INFO_LIST ${BITMAP_INFO_LIST} PARENT_SCOPE )
  759. endfunction()
  760. include( FindUnixCommands )
  761. if( TAR STREQUAL "TAR-NOTFOUND" )
  762. # CMake on Windows CI seems to struggle to find tar even though it's in PATH
  763. # Let's help it out as modern windows (Server 2019 and 10 provide tar)
  764. if( MSVC )
  765. # yolo
  766. set( TAR "C:\\Windows\\System32\\tar.exe" )
  767. else()
  768. message( FATAL_ERROR "Could not find the tar program." )
  769. endif()
  770. endif()
  771. set( BITMAP_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/resources/images.tar.gz )
  772. if( NOT ALL_PNGS )
  773. file( GLOB_RECURSE ALL_PNGS ${CMAKE_CURRENT_SOURCE_DIR}/png/*.png )
  774. endif()
  775. if( MINGW )
  776. # This seems like a huge hack, but I can't find a better way. If anyone else does, please
  777. # feel free to replace this with it...
  778. file( TO_CMAKE_PATH "${BITMAP_ARCHIVE_PATH}" TAR_OUTPUT_FILE )
  779. string( REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" TAR_OUTPUT_FILE "${TAR_OUTPUT_FILE}" )
  780. else()
  781. set( TAR_OUTPUT_FILE "${BITMAP_ARCHIVE_PATH}" )
  782. endif()
  783. add_custom_target( bitmap_archive ALL
  784. COMMAND ${TAR} cfz "${TAR_OUTPUT_FILE}" .
  785. DEPENDS ${ALL_PNGS}
  786. BYPRODUCTS ${BITMAP_ARCHIVE_PATH}
  787. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/png
  788. COMMENT "Creating image archive ${TAR_OUTPUT_FILE}"
  789. VERBATIM
  790. )
  791. install( FILES ${BITMAP_ARCHIVE_PATH}
  792. DESTINATION ${KICAD_DATA}/resources
  793. )
  794. if( MAINTAIN_PNGS )
  795. # Inkscape is required to convert SVG files to PNG files.
  796. set( Inkscape_FOUND FALSE )
  797. if( NOT Inkscape_FOUND )
  798. find_program( Inkscape_EXECUTABLE inkscape
  799. PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inkscape;InstallDir]" "$ENV{PROGRAMFILES}\\Inkscape\\bin"
  800. DOC "Inkscape vector drawing program." )
  801. if( NOT Inkscape_EXECUTABLE )
  802. message( FATAL_ERROR "Could not find the Inkscape vector drawing program." )
  803. else( NOT Inkscape_EXECUTABLE )
  804. set( Inkscape_FOUND TRUE )
  805. set( Inkscape_EXECUTABLE ${Inkscape_EXECUTABLE}
  806. CACHE FILEPATH "Path and file name of the Inkscape program." )
  807. message( STATUS "The Inkscape vector drawing program found." )
  808. endif( NOT Inkscape_EXECUTABLE )
  809. endif( NOT Inkscape_FOUND )
  810. # pngcrush is required to reduce the size of the converted PNG files.
  811. set( pngcrush_FOUND FALSE )
  812. if( NOT pngcrush_FOUND )
  813. find_program( pngcrush_EXECUTABLE pngcrush DOC "The PNG size reduction program." )
  814. if( NOT pngcrush_EXECUTABLE )
  815. message( FATAL_ERROR "Could not find the pngcrush PNG size reduction program." )
  816. else( NOT pngcrush_EXECUTABLE )
  817. set( pngcrush_FOUND TRUE )
  818. set( pngcrush_EXECUTABLE ${pngcrush_EXECUTABLE}
  819. CACHE FILEPATH "Path and file name of the pngcrush program." )
  820. message( STATUS "The pngcrush PNG size reduction program found." )
  821. endif( NOT pngcrush_EXECUTABLE )
  822. endif( NOT pngcrush_FOUND )
  823. # these 3 cmake commands for each desired bitmap size set, repeat as needed:
  824. bitmap_dir( 16 16 "${BMAPS_SMALL}" )
  825. bitmap_dir( 24 24 "${BMAPS_MID}" )
  826. bitmap_dir( 32 32 "${BMAPS_32}" )
  827. bitmap_dir( 22 22 "${BMAPS_22}" )
  828. bitmap_dir( 24 24 "${BMAPS_24}" )
  829. bitmap_dir( 64 64 "${BMAPS_64}" )
  830. bitmap_dir( 128 128 "${BMAPS_128}" )
  831. bitmap_dir( 48 48 "${BMAPS_BIG}" )
  832. bitmap_dir( -1 -1 "${BMAPS_OTHER}" )
  833. configure_file( ${BITMAP_INFO_TEMPLATE} ${BITMAP_INFO_FILE} NEWLINE_STYLE UNIX )
  834. add_custom_target( generate_pngs ALL
  835. DEPENDS ${ALL_PNGS}
  836. COMMENT "Creating PNGs from SVGs"
  837. )
  838. add_dependencies( bitmap_archive generate_pngs )
  839. endif( MAINTAIN_PNGS )