-
-
Notifications
You must be signed in to change notification settings - Fork 486
/
CMakeLists.txt
953 lines (836 loc) · 33.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
add_compile_definitions( PCBNEW )
add_subdirectory(connectivity)
add_subdirectory(router)
# psnrouter depends on make_lexer outputs in common (bug #1285878 )
add_dependencies( pnsrouter pcbcommon )
file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swig )
# Infrequently needed headers go at end of search paths, append to INC_AFTER
set( INC_AFTER ${INC_AFTER} python/scripting )
set( INC_AFTER ${INC_AFTER} ${CMAKE_SOURCE_DIR}/common/swig )
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
./dialogs
./autorouter
./generators
${CMAKE_SOURCE_DIR}/3d-viewer
${CMAKE_SOURCE_DIR}/3d-viewer/dialogs
${CMAKE_SOURCE_DIR}/common
${CMAKE_SOURCE_DIR}/common/dialogs
./exporters
./importers
${CMAKE_SOURCE_DIR}/utils/idftools
./specctra_import_export
${INC_AFTER}
)
set( PCBNEW_DIALOGS
dialogs/dialog_filter_selection.cpp
dialogs/dialog_filter_selection_base.cpp
dialogs/dialog_board_setup.cpp
dialogs/dialog_board_statistics.cpp
dialogs/dialog_board_statistics_base.cpp
dialogs/dialog_board_reannotate.cpp
dialogs/dialog_board_reannotate_base.cpp
dialogs/dialog_cleanup_graphics.cpp
dialogs/dialog_cleanup_graphics_base.cpp
dialogs/dialog_cleanup_tracks_and_vias.cpp
dialogs/dialog_cleanup_tracks_and_vias_base.cpp
dialogs/dialog_copper_zones.cpp
dialogs/dialog_copper_zones_base.cpp
dialogs/dialog_create_array.cpp
dialogs/dialog_create_array_base.cpp
dialogs/dialog_dimension_properties.cpp
dialogs/dialog_dimension_properties_base.cpp
dialogs/dialog_drc.cpp
dialogs/dialog_drc_base.cpp
dialogs/dialog_footprint_associations.cpp
dialogs/dialog_footprint_associations_base.cpp
dialogs/dialog_footprint_checker.cpp
dialogs/dialog_footprint_checker_base.cpp
dialogs/dialog_footprint_chooser.cpp
dialogs/dialog_footprint_properties.cpp
dialogs/dialog_footprint_properties_base.cpp
dialogs/dialog_footprint_properties_fp_editor.cpp
dialogs/dialog_footprint_properties_fp_editor_base.cpp
dialogs/dialog_enum_pads.cpp
dialogs/dialog_enum_pads_base.cpp
dialogs/dialog_exchange_footprints.cpp
dialogs/dialog_exchange_footprints_base.cpp
dialogs/dialog_export_2581.cpp
dialogs/dialog_export_2581_base.cpp
dialogs/dialog_export_idf.cpp
dialogs/dialog_export_idf_base.cpp
dialogs/dialog_export_step.cpp
dialogs/dialog_export_odbpp.cpp
dialogs/dialog_export_odbpp_base.cpp
dialogs/dialog_export_step_base.cpp
dialogs/dialog_export_step_process.cpp
dialogs/dialog_export_step_process_base.cpp
dialogs/dialog_export_svg.cpp
dialogs/dialog_export_svg_base.cpp
dialogs/dialog_export_vrml.cpp
dialogs/dialog_export_vrml_base.cpp
dialogs/dialog_find.cpp
dialogs/dialog_find_base.cpp
dialogs/dialog_footprint_wizard_list.cpp
dialogs/dialog_footprint_wizard_list_base.cpp
dialogs/dialog_gen_footprint_position.cpp
dialogs/dialog_gen_footprint_position_file_base.cpp
dialogs/dialog_gencad_export_options.cpp
dialogs/dialog_gendrill.cpp
dialogs/dialog_gendrill_base.cpp
dialogs/dialog_generators.cpp
dialogs/dialog_generators_base.cpp
dialogs/dialog_get_footprint_by_name.cpp
dialogs/dialog_get_footprint_by_name_base.cpp
dialogs/dialog_global_deletion.cpp
dialogs/dialog_global_deletion_base.cpp
dialogs/dialog_global_edit_tracks_and_vias.cpp
dialogs/dialog_global_edit_tracks_and_vias_base.cpp
dialogs/dialog_global_edit_teardrops.cpp
dialogs/dialog_global_edit_teardrops_base.cpp
dialogs/dialog_global_edit_text_and_graphics.cpp
dialogs/dialog_global_edit_text_and_graphics_base.cpp
dialogs/dialog_global_fp_lib_table_config.cpp
dialogs/dialog_group_properties.cpp
dialogs/dialog_group_properties_base.cpp
dialogs/dialog_push_pad_properties.cpp
dialogs/dialog_push_pad_properties_base.cpp
dialogs/dialog_shape_properties.cpp
dialogs/dialog_shape_properties_base.cpp
dialogs/dialog_reference_image_properties.cpp
dialogs/dialog_reference_image_properties_base.cpp
dialogs/dialog_import_settings.cpp
dialogs/dialog_import_settings_base.cpp
dialogs/dialog_imported_layers_base.cpp
dialogs/dialog_map_layers.cpp
dialogs/dialog_rule_area_properties.cpp
dialogs/dialog_rule_area_properties_base.cpp
dialogs/dialog_layer_selection_base.cpp
dialogs/dialog_move_exact.cpp
dialogs/dialog_move_exact_base.cpp
dialogs/dialog_import_netlist.cpp
dialogs/dialog_import_netlist_base.cpp
dialogs/dialog_non_copper_zones_properties.cpp
dialogs/dialog_non_copper_zones_properties_base.cpp
dialogs/dialog_outset_items.cpp
dialogs/dialog_outset_items_base.cpp
dialogs/dialog_pad_properties.cpp
dialogs/dialog_pad_properties_base.cpp
dialogs/dialog_plot.cpp
dialogs/dialog_plot_base.cpp
dialogs/dialog_pns_diff_pair_dimensions.cpp
dialogs/dialog_pns_diff_pair_dimensions_base.cpp
dialogs/dialog_pns_settings.cpp
dialogs/dialog_pns_settings_base.cpp
dialogs/dialog_position_relative.cpp
dialogs/dialog_position_relative_base.cpp
dialogs/dialog_print_pcbnew.cpp
dialogs/dialog_set_offset_base.cpp
dialogs/dialog_set_offset.cpp
dialogs/dialog_swap_layers.cpp
dialogs/dialog_swap_layers_base.cpp
dialogs/dialog_table_properties.cpp
dialogs/dialog_table_properties_base.cpp
dialogs/dialog_tablecell_properties.cpp
dialogs/dialog_tablecell_properties_base.cpp
dialogs/dialog_target_properties.cpp
dialogs/dialog_target_properties_base.cpp
dialogs/dialog_text_properties.cpp
dialogs/dialog_text_properties_base.cpp
dialogs/dialog_textbox_properties.cpp
dialogs/dialog_textbox_properties_base.cpp
dialogs/dialog_track_via_properties.cpp
dialogs/dialog_track_via_properties_base.cpp
dialogs/dialog_track_via_size.cpp
dialogs/dialog_track_via_size_base.cpp
dialogs/dialog_tuning_pattern_properties.cpp
dialogs/dialog_tuning_pattern_properties_base.cpp
dialogs/dialog_unused_pad_layers.cpp
dialogs/dialog_unused_pad_layers_base.cpp
dialogs/dialog_update_pcb.cpp
dialogs/dialog_update_pcb_base.cpp
dialogs/dialog_multichannel_generate_rule_areas_base.cpp
dialogs/dialog_multichannel_generate_rule_areas.cpp
dialogs/dialog_multichannel_repeat_layout_base.cpp
dialogs/dialog_multichannel_repeat_layout.cpp
dialogs/panel_pcb_display_options.cpp
dialogs/panel_pcb_display_options_base.cpp
dialogs/panel_edit_options.cpp
dialogs/panel_edit_options_base.cpp
dialogs/panel_fp_lib_table.cpp
dialogs/panel_fp_lib_table_base.cpp
dialogs/panel_fp_editor_color_settings.cpp
dialogs/panel_fp_editor_defaults.cpp
dialogs/panel_fp_editor_defaults_base.cpp
dialogs/panel_fp_properties_3d_model.cpp
dialogs/panel_fp_properties_3d_model_base.cpp
dialogs/panel_pcbnew_action_plugins.cpp
dialogs/panel_pcbnew_action_plugins_base.cpp
dialogs/panel_pcbnew_color_settings.cpp
dialogs/panel_pcbnew_display_origin.cpp
dialogs/panel_pcbnew_display_origin_base.cpp
dialogs/panel_rule_area_properties_keepout_base.cpp
dialogs/panel_rule_area_properties_placement_base.cpp
dialogs/panel_setup_constraints.cpp
dialogs/panel_setup_constraints_base.cpp
dialogs/panel_setup_formatting.cpp
dialogs/panel_setup_formatting_base.cpp
dialogs/panel_setup_mask_and_paste.cpp
dialogs/panel_setup_mask_and_paste_base.cpp
dialogs/panel_setup_layers.cpp
dialogs/panel_setup_layers_base.cpp
dialogs/panel_setup_rules.cpp
dialogs/panel_setup_rules_base.cpp
dialogs/panel_setup_teardrops.cpp
dialogs/panel_setup_teardrops_base.cpp
dialogs/panel_setup_text_and_graphics.cpp
dialogs/panel_setup_text_and_graphics_base.cpp
dialogs/panel_setup_tracks_and_vias.cpp
dialogs/panel_setup_tracks_and_vias_base.cpp
dialogs/panel_setup_tuning_patterns.cpp
dialogs/panel_setup_tuning_patterns_base.cpp
footprint_wizard.cpp
footprint_wizard_frame.cpp
footprint_wizard_frame_functions.cpp
)
set( PCBNEW_BRDSTACKUP_MGR
board_stackup_manager/dielectric_material.cpp
board_stackup_manager/stackup_predefined_prms.cpp
board_stackup_manager/panel_board_finish.cpp
board_stackup_manager/panel_board_finish_base.cpp
board_stackup_manager/panel_board_stackup.cpp
board_stackup_manager/panel_board_stackup_base.cpp
board_stackup_manager/board_stackup_reporter.cpp
board_stackup_manager/dialog_dielectric_list_manager_base.cpp
board_stackup_manager/dialog_dielectric_list_manager.cpp
)
set( PCBNEW_IMPORT_GFX
import_gfx/dialog_import_graphics.cpp
import_gfx/dialog_import_graphics_base.cpp
import_gfx/graphics_importer_pcbnew.cpp
)
set( PCBNEW_EXPORTERS
exporters/export_hyperlynx.cpp
exporters/export_d356.cpp
exporters/export_footprint_associations.cpp
exporters/export_gencad.cpp
exporters/export_gencad_writer.cpp
exporters/export_idf.cpp
exporters/export_svg.cpp
exporters/step/exporter_step.cpp
exporters/step/step_pcb_model.cpp
exporters/step/KI_XCAFDoc_AssemblyGraph.cxx
exporters/exporter_vrml.cpp
exporters/place_file_exporter.cpp
exporters/gen_drill_report_files.cpp
exporters/gendrill_Excellon_writer.cpp
exporters/gendrill_file_writer_base.cpp
exporters/gendrill_gerber_writer.cpp
exporters/gerber_jobfile_writer.cpp
exporters/gerber_placefile_writer.cpp
)
set( PCBNEW_MICROWAVE_SRCS
microwave/microwave_footprint.cpp
microwave/microwave_inductor.cpp
microwave/microwave_polygon.cpp
microwave/microwave_tool.cpp
)
set( PCBNEW_GENERATORS_SRCS
generators/pcb_tuning_pattern.cpp
)
set( PCBNEW_DRC_SRCS
drc/drc_interactive_courtyard_clearance.cpp
drc/drc_creepage_utils.cpp
drc/drc_report.cpp
drc/drc_test_provider.cpp
drc/drc_test_provider_annular_width.cpp
drc/drc_test_provider_disallow.cpp
drc/drc_test_provider_clearance_base.cpp
drc/drc_test_provider_creepage.cpp
drc/drc_test_provider_connectivity.cpp
drc/drc_test_provider_connection_width.cpp
drc/drc_test_provider_copper_clearance.cpp
drc/drc_test_provider_physical_clearance.cpp
drc/drc_test_provider_courtyard_clearance.cpp
drc/drc_test_provider_edge_clearance.cpp
drc/drc_test_provider_footprint_checks.cpp
drc/drc_test_provider_hole_to_hole.cpp
drc/drc_test_provider_hole_size.cpp
drc/drc_test_provider_library_parity.cpp
drc/drc_test_provider_schematic_parity.cpp
drc/drc_test_provider_misc.cpp
drc/drc_test_provider_text_dims.cpp
drc/drc_test_provider_track_angle.cpp
drc/drc_test_provider_track_width.cpp
drc/drc_test_provider_track_segment_length.cpp
drc/drc_test_provider_zone_connections.cpp
drc/drc_test_provider_via_diameter.cpp
drc/drc_test_provider_solder_mask.cpp
drc/drc_test_provider_silk_clearance.cpp
drc/drc_test_provider_matched_length.cpp
drc/drc_test_provider_diff_pair_coupling.cpp
drc/drc_test_provider_sliver_checker.cpp
)
set( PCBNEW_NETLIST_SRCS
netlist_reader/board_netlist_updater.cpp
netlist_reader/netlist.cpp
)
set( ZONE_MANAGER_SRCS
zone_manager/board_edges_bounding_item.cpp
zone_manager/dialog_zone_manager.cpp
zone_manager/dialog_zone_manager_base.cpp
zone_manager/model_zones_overview_table.cpp
zone_manager/pane_zone_viewer.cpp
zone_manager/panel_zone_gal.cpp
zone_manager/panel_zone_properties.cpp
zone_manager/panel_zone_properties_base.cpp
zone_manager/zone_manager_preference.cpp
zone_manager/zone_painter.cpp
zone_manager/zones_container.cpp
)
set( PCBNEW_CLASS_SRCS
${PCBNEW_DIALOGS}
${PCBNEW_EXPORTERS}
${PCBNEW_GENERATORS_SRCS}
${PCBNEW_DRC_SRCS}
${PCBNEW_IMPORT_GFX}
${PCBNEW_NETLIST_SRCS}
${ZONE_MANAGER_SRCS}
${PCBNEW_BRDSTACKUP_MGR}
autorouter/spread_footprints.cpp
autorouter/ar_autoplacer.cpp
autorouter/ar_matrix.cpp
autorouter/autoplace_tool.cpp
action_plugin.cpp
array_pad_number_provider.cpp
build_BOM_from_board.cpp
cleanup_item.cpp
component_class_manager.cpp
convert_shape_list_to_polygon.cpp
cross-probing.cpp
edit.cpp
edit_track_width.cpp
files.cpp
footprint_info_impl.cpp
footprint_wizard.cpp
footprint_editor_utils.cpp
footprint_editor_settings.cpp
fp_tree_synchronizing_adapter.cpp
footprint_chooser_frame.cpp
footprint_edit_frame.cpp
footprint_libraries_utils.cpp
footprint_viewer_frame.cpp
fp_tree_model_adapter.cpp
generate_footprint_info.cpp
graphics_cleaner.cpp
grid_layer_box_helpers.cpp
grid_layer_box_helpers.h
initpcb.cpp
layer_pairs.cpp
load_select_footprint.cpp
menubar_footprint_editor.cpp
menubar_pcb_editor.cpp
pcb_base_edit_frame.cpp
pcb_layer_box_selector.cpp
pcb_edit_frame.cpp
pcbnew_config.cpp
pcbnew_jobs_handler.cpp
pcbnew_printout.cpp
pcbnew_settings.cpp
pcbplot.cpp
plot_board_layers.cpp
plot_brditems_plotter.cpp
specctra_import_export/specctra.cpp
specctra_import_export/specctra_export.cpp
specctra_import_export/specctra_import.cpp
pcb_fields_grid_table.cpp
toolbars_footprint_editor.cpp
toolbars_footprint_viewer.cpp
toolbars_pcb_editor.cpp
tracks_cleaner.cpp
undo_redo.cpp
zone_filler.cpp
edit_zone_helpers.cpp
ratsnest/ratsnest.cpp
tools/array_tool.cpp
tools/board_editor_control.cpp
tools/board_inspection_tool.cpp
tools/board_reannotate_tool.cpp
tools/convert_tool.cpp
tools/drawing_tool.cpp
tools/drawing_stackup_table_tool.cpp
tools/drc_tool.cpp
tools/edit_tool.cpp
tools/edit_tool_move_fct.cpp
tools/pcb_edit_table_tool.cpp
tools/global_edit_tool.cpp
tools/group_tool.cpp
tools/footprint_editor_control.cpp
tools/item_modification_routine.cpp
tools/pad_tool.cpp
tools/pcb_control.cpp
tools/pcb_picker_tool.cpp
tools/pcb_selection.cpp
tools/pcb_selection_conditions.cpp
tools/pcb_selection_tool.cpp
tools/pcb_tool_base.cpp
tools/placement_tool.cpp
tools/pcb_point_editor.cpp
tools/pcb_tool_utils.cpp
tools/position_relative_tool.cpp
tools/tool_event_utils.cpp
tools/zone_create_helper.cpp
tools/zone_filler_tool.cpp
tools/generator_tool.cpp
tools/generator_tool_pns_proxy.cpp
tools/multichannel_tool.cpp
footprint_preview_panel.cpp
footprint_tree_pane.cpp
widgets/appearance_controls.cpp
widgets/appearance_controls_base.cpp
widgets/panel_footprint_chooser.cpp
widgets/panel_selection_filter.cpp
widgets/panel_selection_filter_base.cpp
widgets/pcb_properties_panel.cpp
widgets/pcb_search_pane.cpp
widgets/search_handlers.cpp
widgets/net_inspector_panel.cpp
widgets/pcb_net_inspector_panel.cpp
)
set( PCBNEW_GIT_SRCS
git/kigit_pcb_merge.cpp
)
set( PCBNEW_SRCS
${PCBNEW_MICROWAVE_SRCS}
${PCBNEW_CLASS_SRCS}
${PCBNEW_DIALOGS}
${PCBNEW_GIT_SRCS}
)
# extra sources from common
set( PCBNEW_COMMON_SRCS
)
set( PCBNEW_SCRIPTING_PYTHON_HELPERS
${CMAKE_SOURCE_DIR}/common/swig/wx_python_helpers.cpp
python/scripting/pcbnew_action_plugins.cpp
python/scripting/pcbnew_footprint_wizards.cpp
python/scripting/pcbnew_scripting_helpers.cpp
python/scripting/pcbnew_scripting.cpp
python/scripting/pcbnew_utils_3d.cpp
python/scripting/pcb_scripting_tool.cpp
)
if( KICAD_IPC_API )
set( PCBNEW_SRCS ${PCBNEW_SRCS}
api/api_handler_pcb.cpp
)
endif()
if( COMPILER_SUPPORTS_WARNINGS )
# Only compile our source files with the warnings, since the SWIG generated
# files contain a lot of warnings, we just ignore it.
set_source_files_properties(
${PCBNEW_SRCS} ${PCBNEW_COMMON_SRCS} ${PCBNEW_SCRIPTING_PYTHON_HELPERS}
PROPERTIES COMPILE_FLAGS ${WARN_FLAGS_CXX}
)
endif()
# Disable all warnings for the SWIG file
if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( MSYS )
# For some reason the .cxx file generated by SWIG cannot be linked if compiled with debug options:
# it creates a *lot* of not found symbols. So compile it with release mode
set_source_files_properties( pcbnew_wrap.cxx PROPERTIES COMPILE_FLAGS "-O2 -w" )
else()
set_source_files_properties( pcbnew_wrap.cxx PROPERTIES COMPILE_FLAGS "-w" )
endif()
endif()
set( PCBNEW_SCRIPTING_SRCS
pcbnew_wrap.cxx
${PCBNEW_SCRIPTING_PYTHON_HELPERS}
)
set( SWIG_FLAGS
-I${CMAKE_CURRENT_SOURCE_DIR}
-I${CMAKE_SOURCE_DIR}/include
-I${CMAKE_SOURCE_DIR}/scripting
-I${CMAKE_SOURCE_DIR}/pcbnew/python/scripting
-I${CMAKE_SOURCE_DIR}/common/swig
-I${CMAKE_SOURCE_DIR}/libs/core/include
-I${CMAKE_SOURCE_DIR}/libs/kimath/include
-I${CMAKE_BINARY_DIR}
)
if( DEBUG )
set( SWIG_FLAGS ${SWIG_FLAGS} -DDEBUG )
endif()
# collect CFLAGS , and pass them to swig later
get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS )
foreach( d ${DirDefs} )
set( SWIG_FLAGS ${SWIG_FLAGS} -D${d} )
endforeach()
# We deliberately do not use the CMake support for swig here,
# i.e. swig_add_footprint()) because we want full control.
# Avoid threading in SWIG (breaks threads in pcbnew)
set( SWIG_OPTS -python -c++ -nothreads -fastdispatch -fvirtual )
set( SWIG_OPTS ${SWIG_OPTS} -outdir ${CMAKE_CURRENT_BINARY_DIR} ${SWIG_FLAGS} )
if( EXISTS ${CMAKE_CURRENT_BINARY_DIR}/doxygen-xml )
set( SWIG_OPTS ${SWIG_OPTS} -DENABLE_DOCSTRINGS_FROM_DOXYGEN )
set( SWIG_OPTS ${SWIG_OPTS} -I${CMAKE_CURRENT_BINARY_DIR}/docstrings )
endif()
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
DEPENDS python/swig/pcbnew.i
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.d
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docstrings
# Make docstrings.i available if it doesn't exist
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/docstrings/docstrings.i
COMMAND ${SWIG_EXECUTABLE}
${SWIG_OPTS} -MMD -MF ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.d -MT pcbnew/pcbnew_wrap.cxx -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx ${CMAKE_SOURCE_DIR}/pcbnew/python/swig/pcbnew.i
# was needed only with SWIG version < 4 to disable a python section "def swig_import_helper()"
# found in pcbnew.py but not existing in SWIG version >= 4
# So it is left here for documentation purpose
#COMMAND ${PYTHON_EXECUTABLE}
# ${CMAKE_SOURCE_DIR}/tools/build/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
if( UNIX AND NOT APPLE )
list( APPEND PCBNEW_EXTRA_LIBS rt )
endif()
###
# Doxygen python documentation
###
if( DOXYGEN_FOUND )
# create XML files from doxygen parsing
add_custom_target( doxygen-python-xml
${CMAKE_COMMAND} -E remove_directory doxygen-python-xml
COMMAND SOURCES_DIR=${CMAKE_SOURCE_DIR} ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_xml
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS Doxyfile_xml
COMMENT "building doxygen docs into directory doxygen-python/html"
)
add_dependencies( doxygen-python-xml version_header )
# create .i files from XML doxygen parsing, docstrings.i will include all of them
add_custom_target( xml-to-docstrings
COMMAND ${CMAKE_COMMAND} -E remove_directory docstrings
COMMAND ${CMAKE_COMMAND} -E make_directory docstrings
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/build/extract_docstrings.py pcbnew.py doxygen-xml/xml docstrings
COMMAND ${CMAKE_COMMAND} -E remove pcbnew.py # force removal so it will be recreated later with the new docstrings
COMMENT "building docstring files"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS pcbnew.py
)
add_dependencies( xml-to-docstrings doxygen-python-xml )
# The sources to give to the Python Doxygen target
set( DOXYGEN_PYTHON_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
${CMAKE_CURRENT_SOURCE_DIR}/python/plugins/FootprintWizardBase.py
${CMAKE_CURRENT_SOURCE_DIR}/python/plugins/PadArray.py )
# The Doxyfile expects a space-separated list in the env var
string(REPLACE ";" " " DOXYGEN_PYTHON_SOURCES_STR "${DOXYGEN_PYTHON_SOURCES}")
# Create doxygen-python html
add_custom_target( doxygen-python
${CMAKE_COMMAND} -E remove_directory doxygen-python
COMMAND ${CMAKE_COMMAND} -E env
PYTHON_SOURCES_TO_DOC=${DOXYGEN_PYTHON_SOURCES_STR}
CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_python
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS Doxyfile_python
DEPENDS ${DOXYGEN_PYTHON_SOURCES}
COMMENT "building doxygen docs into directory doxygen-python/html"
)
add_dependencies( doxygen-python version_header xml-to-docstrings )
endif()
if( WIN32 )
if( MINGW )
# PCBNEW_RESOURCES variable is set by the macro.
mingw_resource_compiler( pcbnew )
else()
set( PCBNEW_RESOURCES ${CMAKE_SOURCE_DIR}/resources/msw/pcbnew.rc )
endif()
endif()
# Function to process a markdown (.md) file into a header (.h) file
function(callMrkdn2C inFile outFile)
add_custom_command(
OUTPUT "${outFile}"
COMMAND ${CMAKE_COMMAND} -DinputFile="${inFile}" -DoutputFile="${outFile}" -P "${KICAD_CMAKE_MODULE_PATH}/BuildSteps/markdown2C.cmake"
DEPENDS "${inFile}" "${KICAD_CMAKE_MODULE_PATH}/BuildSteps/markdown2C.cmake"
COMMENT "Generating header: ${outFile}"
)
endfunction()
# Locate all .md files in the specified directory
file(GLOB markdownFiles ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help_*.md)
# Create a custom target to generate all .h files
add_custom_target(generate_headers ALL)
# Loop over all .md files and convert them into .h files in the same directory as the .md files
foreach(file ${markdownFiles})
# Extract the filename without extension and define output path in the same folder as the .md file
get_filename_component(filename "${file}" NAME_WE)
set(outputHeader "${CMAKE_CURRENT_SOURCE_DIR}/dialogs/${filename}.h")
# Call the custom function to process the file
callMrkdn2C("${file}" "${outputHeader}")
# Create a per-file custom target and add it as a dependency
add_custom_target(${filename}_gen DEPENDS "${outputHeader}")
add_dependencies(generate_headers ${filename}_gen)
# Mark the output header as a dependency of the source file
set_source_files_properties(dialogs/panel_setup_rules.cpp
PROPERTIES OBJECT_DEPENDS "${outputHeader}")
endforeach()
if( APPLE )
# setup bundle
set( PCBNEW_RESOURCES pcbnew.icns pcbnew_doc.icns fpedit.icns fpedit_doc.icns )
set_source_files_properties(
"${CMAKE_CURRENT_SOURCE_DIR}/pcbnew.icns"
"${CMAKE_CURRENT_SOURCE_DIR}/pcbnew_doc.icns"
"${CMAKE_CURRENT_SOURCE_DIR}/fpedit.icns"
"${CMAKE_CURRENT_SOURCE_DIR}/fpedit_doc.icns"
PROPERTIES MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE pcbnew.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad.kicad )
set( MACOSX_BUNDLE_NAME pcbnew )
endif()
add_subdirectory( pcb_io/pcad )
add_subdirectory( pcb_io/altium )
add_subdirectory( pcb_io/cadstar )
add_subdirectory( pcb_io/easyeda )
add_subdirectory( pcb_io/easyedapro )
add_subdirectory( pcb_io/fabmaster )
add_subdirectory( pcb_io/ipc2581 )
add_subdirectory( pcb_io/odbpp )
set( PCBNEW_IO_LIBRARIES pcad2kicadpcb altium2pcbnew cadstar2pcbnew easyeda easyedapro fabmaster ipc2581 odbpp CACHE INTERNAL "")
# a very small program launcher for pcbnew_kiface
add_executable( pcbnew WIN32 MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/common/single_top.cpp
${PCBNEW_RESOURCES}
)
set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp pcbnew.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PCB_EDITOR;PGM_DATA_FILE_EXT=\"kicad_pcb\";BUILD_KIWAY_DLL"
)
target_link_libraries( pcbnew
kicommon
${wxWidgets_LIBRARIES}
)
target_link_options( pcbnew PRIVATE
$<$<BOOL:${KICAD_MAKE_LINK_MAPS}>:-Wl,--cref,-Map=pcbnew.map>
)
# the main pcbnew program, in DSO form.
add_library( pcbnew_kiface_objects OBJECT
pcbnew.cpp
${PCBNEW_SRCS}
${PCBNEW_COMMON_SRCS}
${PCBNEW_SCRIPTING_SRCS}
)
# auto-generate specctra_lexer.h and specctra_keywords.cpp
make_lexer(
pcbnew_kiface_objects
specctra_import_export/specctra.keywords
specctra_import_export/specctra_lexer.h
specctra_import_export/specctra_keywords.cpp
DSN
)
target_link_libraries( pcbnew_kiface_objects
PRIVATE
common
core
nlohmann_json
rectpack2d
gzip-hpp
Boost::boost
ZLIB::ZLIB
${OCC_LIBRARIES}
)
add_library( pcbnew_kiface MODULE )
set_target_properties( pcbnew_kiface PROPERTIES
# Decorate OUTPUT_NAME with PREFIX and SUFFIX, creating something like
# _pcbnew.so, _pcbnew.dll, or _pcbnew.kiface
OUTPUT_NAME pcbnew
PREFIX ${KIFACE_PREFIX}
SUFFIX ${KIFACE_SUFFIX}
)
if ( KICAD_BUILD_TESTS )
if ( UNIX )
add_custom_command(TARGET pcbnew_kiface POST_BUILD
COMMAND ln -sf _pcbnew.kiface lib_pcbnew_kiface.so )
else()
add_custom_command(TARGET pcbnew_kiface POST_BUILD
COMMAND copy _pcbnew.kiface lib_pcbnew_kiface.dll )
endif()
endif ()
set( PCBNEW_KIFACE_LIBRARIES
pcbnew_kiface_objects
3d-viewer
connectivity
pcbcommon
pnsrouter
kicommon
kiplatform
common
gal
scripting
core
idf3
markdown_lib
${PCBNEW_IO_LIBRARIES}
${wxWidgets_LIBRARIES}
${PYTHON_LIBRARIES}
Boost::headers
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
)
target_link_libraries( pcbnew_kiface
PRIVATE
${PCBNEW_KIFACE_LIBRARIES}
)
set_source_files_properties( pcbnew.cpp PROPERTIES
# The KIFACE is in pcbnew.cpp, export it:
COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL"
)
target_link_options( pcbnew_kiface PRIVATE
$<$<BOOL:${KICAD_MAKE_LINK_MAPS}>:-Wl,--cref,-Map=_pcbnew.kiface.map>
)
# if building pcbnew, then also build pcbnew_kiface if out of date.
add_dependencies( pcbnew pcbnew_kiface )
if( WIN32 )
# Copy dynamic lib dependency to build dir to allow running directly
add_custom_command( TARGET pcbnew POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:kicad_3dsg>" "$<TARGET_FILE_DIR:pcbnew>"
)
add_custom_command( TARGET pcbnew POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:kiapi>" "$<TARGET_FILE_DIR:pcbnew>"
)
endif()
# these 2 binaries are a matched set, keep them together:
if( APPLE )
set_target_properties( pcbnew PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pcbnew/Info.plist
)
# puts binaries into the *.app bundle while linking
set_target_properties( pcbnew_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
)
set_target_properties( pcbnew PROPERTIES INSTALL_RPATH
"@executable_path/../Frameworks;@executable_path/../Frameworks/Python.framework" )
set_target_properties( pcbnew_kiface PROPERTIES INSTALL_RPATH
"@executable_path/../Frameworks;@executable_path/../Frameworks/Python.framework" )
set_target_properties( pcbnew_kiface PROPERTIES BUILD_WITH_INSTALL_RPATH 1 )
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS pcbnew
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
set( KICAD_CMAKE_MODULE_PATH \"${KICAD_CMAKE_MODULE_PATH}\" )
set( KICAD_BIN \"${KICAD_BIN}\" )
set( OSX_BUNDLE_INSTALL_BIN_DIR \"${OSX_BUNDLE_INSTALL_BIN_DIR}\" )
set( OSX_BUNDLE_INSTALL_LIB_DIR \"${OSX_BUNDLE_INSTALL_LIB_DIR}\" )
set( OSX_BUNDLE_BUILD_KIFACE_DIR \"${OSX_BUNDLE_BUILD_KIFACE_DIR}\" )
" )
install( CODE [[
include( ${KICAD_CMAKE_MODULE_PATH}/InstallSteps/InstallMacOS.cmake )
# Install any dependencies
install_runtime_deps( "${KICAD_BIN}/pcbnew.app/Contents/MacOS/pcbnew"
"${OSX_BUNDLE_BUILD_KIFACE_DIR}/_pcbnew.kiface"
""
)
]] )
else()
if( MSVC )
target_sources( pcbnew_kiface PRIVATE ${CMAKE_SOURCE_DIR}/resources/msw/pcbnew-dll.rc )
endif()
install( TARGETS pcbnew
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( TARGETS pcbnew_kiface
DESTINATION ${KICAD_KIFACE}
COMPONENT binary
)
endif()
if( KICAD_WIN32_INSTALL_PDBS )
# Get the PDBs to copy over for MSVC
install(FILES $<TARGET_PDB_FILE:pcbnew> DESTINATION ${KICAD_BIN})
install(FILES $<TARGET_PDB_FILE:pcbnew_kiface> DESTINATION ${KICAD_KIFACE})
endif()
if( NOT APPLE )
install( FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py DESTINATION ${PYTHON_DEST} )
else()
# put into bundle at build time, it is relocated at install
add_custom_target( ScriptingPcbnewPyCopy ALL
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py" "${PYTHON_DEST}/"
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
COMMENT "Copying pcbnew.py into ${PYTHON_DEST}"
)
add_dependencies( ScriptingPcbnewPyCopy ScriptingPythonDirectoryCreation )
endif()
# python plugins
install( DIRECTORY ${PROJECT_SOURCE_DIR}/pcbnew/python/plugins/
DESTINATION ${KICAD_DATA}/scripting/plugins
FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
)
# Here is built the _pcbnew.{so,pyd} which is the native part of the pcbnew Python library
# when Python is used from the command line.
if( WIN32 )
install( FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.pyd DESTINATION ${PYTHON_DEST} )
set( PYMOD_EXT "pyd" )
elseif( APPLE )
# put everything into bundle at build time, it is relocated at install
add_custom_target( ScriptingModulesPcbnewSoCopy ALL
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so" "${PYTHON_DEST}/"
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.so
COMMENT "Copying _pcbnew.so into ${PYTHON_DEST}"
)
add_dependencies( ScriptingModulesPcbnewSoCopy ScriptingPythonDirectoryCreation )
set( PYMOD_EXT "so" )
else()
# Linux is the remaining platform, and all that has to be installed is the created symlink.
set( PYMOD_EXT "so" )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/python/_pcbnew.${PYMOD_EXT} DESTINATION ${PYTHON_DEST} )
endif()
if( APPLE )
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
DEPENDS pcbnew_kiface
COMMAND ${CMAKE_COMMAND} -E copy ${OSX_BUNDLE_BUILD_KIFACE_DIR}/_pcbnew.kiface _pcbnew.${PYMOD_EXT}
COMMENT "Creating python's pcbnew native module _pcbnew.${PYMOD_EXT} for command line use."
)
set( PYTHON_FILES ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT} )
elseif( WIN32 )
# For phase 1, copy _pcbnew.kiface to the python module.
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
DEPENDS pcbnew_kiface
COMMAND ${CMAKE_COMMAND} -E copy _pcbnew${KIFACE_SUFFIX} _pcbnew.${PYMOD_EXT}
COMMENT "Creating python's pcbnew native module _pcbnew.${PYMOD_EXT} for command line use."
)
set( PYTHON_FILES ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT} )
else()
# For linux, just create a symlink in the build directory to ensure the unit tests can find the library
# We don't actually do anything with this symlink though, since we create the proper one for the install
# later.
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
DEPENDS pcbnew_kiface
COMMAND ${CMAKE_COMMAND} -E create_symlink _pcbnew${KIFACE_SUFFIX} _pcbnew.${PYMOD_EXT}
COMMENT "Symlinking _pcbnew.${PYMOD_EXT} to _pcbnew${KIFACE_SUFFIX}."
)
if( IS_ABSOLUTE ${KICAD_KIFACE} )
file( RELATIVE_PATH PCBNEW_PYTHON_SYMLINK ${PYTHON_FULL_DEST} ${KICAD_KIFACE}/_pcbnew${KIFACE_SUFFIX} )
else()
file( RELATIVE_PATH PCBNEW_PYTHON_SYMLINK ${PYTHON_FULL_DEST} ${CMAKE_INSTALL_PREFIX}/${KICAD_KIFACE}/_pcbnew${KIFACE_SUFFIX} )
endif()
file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python )
# This is the symlink we use in the installation directory, so it will not resolve in the build directory.
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python/_pcbnew.${PYMOD_EXT}
DEPENDS pcbnew_kiface
COMMAND ln -sf "${PCBNEW_PYTHON_SYMLINK}" "${CMAKE_CURRENT_BINARY_DIR}/python/_pcbnew.${PYMOD_EXT}"
COMMENT "Creating install symlink from _pcbnew.${PYMOD_EXT} to _pcbnew${KIFACE_SUFFIX}."
)
set( PYTHON_FILES
${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
${CMAKE_CURRENT_BINARY_DIR}/python/_pcbnew.${PYMOD_EXT}
)
endif()
add_custom_target(
pcbnew_python_module ALL
DEPENDS ${PYTHON_FILES}
)
if( APPLE )
# If we don't have wxPython, then we must create the site-packages directory
add_custom_target( ScriptingPythonDirectoryCreation ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${PYTHON_DEST}"
COMMENT "Creating Python library directory ${PYTHON_DEST}"
)
endif()