summaryrefslogtreecommitdiff
path: root/common/CMakeLists.txt
blob: 549a2c86baff1a96a48a1e31304a4d3edea33dd4 (plain)
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
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
    ./dialogs
    ./dialog_about
    ${CAIRO_INCLUDE_DIR}
    ${GLEW_INCLUDE_DIR}
    ${CURL_INCLUDE_DIRS}
    ../3d-viewer
    ../pcbnew
    ../polygon
    ${INC_AFTER}
    )


if( NOT APPLE )     # windows and linux use openssl under curl
    find_package( OpenSSL REQUIRED )
endif()


# Generate header files containing shader programs
# Order of input files is significant
add_custom_command(
    OUTPUT gal/opengl/shader_src.h
    COMMAND ${CMAKE_COMMAND}
        -DinputFiles="${PROJECT_SOURCE_DIR}/common/gal/opengl/shader.vert\\;${PROJECT_SOURCE_DIR}/common/gal/opengl/shader.frag"
        -DoutputFile="shader_src.h"
        -P ${CMAKE_MODULE_PATH}/Shaders.cmake
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/common/gal/opengl
    COMMENT "Generating headers containing GLSL source code"
    )

add_custom_target(
    shader_headers ALL
    DEPENDS gal/opengl/shader_src.h
    )

set( GAL_SRCS
    # Common part
    draw_panel_gal.cpp
    painter.cpp
    worksheet_viewitem.cpp
    origin_viewitem.cpp
    gal/graphics_abstraction_layer.cpp
    gal/stroke_font.cpp
    gal/color4d.cpp
    view/view_controls.cpp
    view/wx_view_controls.cpp
    geometry/hetriang.cpp

    # OpenGL GAL
    gal/opengl/opengl_gal.cpp
    gal/opengl/shader.cpp
    gal/opengl/vertex_item.cpp
    gal/opengl/vertex_container.cpp
    gal/opengl/cached_container.cpp
    gal/opengl/noncached_container.cpp
    gal/opengl/vertex_manager.cpp
    gal/opengl/gpu_manager.cpp
    gal/opengl/opengl_compositor.cpp

    # Cairo GAL
    gal/cairo/cairo_gal.cpp
    gal/cairo/cairo_compositor.cpp
    )

add_library( gal STATIC ${GAL_SRCS} )
add_dependencies( gal shader_headers )
add_dependencies( gal lib-dependencies )

target_link_libraries( gal
    ${GLEW_LIBRARIES}
    ${CAIRO_LIBRARIES}
    ${PIXMAN_LIBRARY}
    ${OPENGL_LIBRARIES}
)


# Only for win32 cross compilation using MXE
if( WIN32 AND MSYS )
    add_definitions( -DGLEW_STATIC )
endif()


# A shared library subsetted from common which restricts what can go into
# a single_top link image.  By not linking to common, we control what does
# statically go into single_top link images.  My current thinking is that only
# wxWidgets should be a shared link from single top, everything else should be
# statically bound into it. Otherwise you will have DSO loading problems. After it
# sets the LIB PATHS however, we want the *.kiface modules to use shared linking.
add_library( singletop STATIC EXCLUDE_FROM_ALL
    confirm.cpp
    eda_doc.cpp
    kiway.cpp
    kiway_holder.cpp
    )


# A shared library used by multiple *.kiface files and one or two program
# launchers.  Object files can migrate into here over time, but only if they are
# surely needed and certainly used from more than one place without recompilation.
# Functions and data all need to use the #include <import_export.h> and be declared
# as APIEXPORT
set( LIB_KICAD_SRCS
    colors.cpp
    dlist.cpp
    string.cpp
    )

if( future )
add_library( lib_kicad SHARED
    )
target_link_libraries( lib_kicad
    ${wxWidgets_LIBRARIES}
    )
set_target_properties( lib_kicad PROPERTIES
    OUTPUT_NAME     ki
    )
install( TARGETS lib_kicad
    DESTINATION ${KICAD_BIN}
    COMPONENT binary
    )
endif()


# KiCad build version string defaults to "no-vcs-found" which forces the build version header
# command to look for git to create the version string header when the .git path is found in
# the source path.
set( KICAD_BRANCH_NAME "" CACHE STRING "KiCad repository name." )
set( KICAD_VERSION_EXTRA "" CACHE STRING
    "User defined configuration string to append to KiCad version." )

# Generate version header file.
add_custom_target(
    version_header ALL
    COMMAND ${CMAKE_COMMAND}
        -DKICAD_VERSION=${KICAD_VERSION}
        -DKICAD_BRANCH_NAME=${KICAD_BRANCH_NAME}
        -DKICAD_VERSION_EXTRA=${KICAD_VERSION_EXTRA}
        -DOUTPUT_FILE=${CMAKE_BINARY_DIR}/kicad_build_version.h
        -DSRC_PATH=${PROJECT_SOURCE_DIR}
        -DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
        -P ${CMAKE_MODULE_PATH}/WriteVersionHeader.cmake
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
    COMMENT "Generating version string header"
    )

set( COMMON_ABOUT_DLG_SRCS
    dialog_about/AboutDialog_main.cpp
    dialog_about/dialog_about.cpp
    dialog_about/dialog_about_base.cpp
    dialogs/dialog_display_info_HTML_base.cpp
    dialogs/dialog_exit_base.cpp
    dialogs/dialog_image_editor.cpp
    dialogs/dialog_image_editor_base.cpp
    dialogs/dialog_get_component.cpp
    dialogs/dialog_get_component_base.cpp
    dialogs/dialog_hotkeys_editor.cpp
    dialogs/dialog_hotkeys_editor_base.cpp
    dialogs/dialog_list_selector_base.cpp
    dialogs/dialog_page_settings_base.cpp
    dialogs/dialog_env_var_config_base.cpp
    dialogs/dialog_env_var_config.cpp
    dialogs/wx_html_report_panel_base.cpp
    dialogs/wx_html_report_panel.cpp
    )

set( COMMON_PAGE_LAYOUT_SRCS
    page_layout/title_block_shapes.cpp
    page_layout/class_worksheet_dataitem.cpp
    page_layout/class_worksheet_layout.cpp
    page_layout/page_layout_default_description.cpp
    page_layout/page_layout_graphic_items.cpp
    page_layout/page_layout_reader_keywords.cpp
    page_layout/page_layout_reader.cpp
    )

set( COMMON_SRCS
    ${LIB_KICAD_SRCS}
    ${COMMON_ABOUT_DLG_SRCS}
    ${COMMON_PAGE_LAYOUT_SRCS}
    base_struct.cpp
    basicframe.cpp
    bezier_curves.cpp
    bin_mod.cpp
    bitmap.cpp
    block_commande.cpp
    build_version.cpp
    class_bitmap_base.cpp
    class_colors_design_settings.cpp
    class_layer_box_selector.cpp
    class_marker_base.cpp
    class_plotter.cpp
    class_undoredo_container.cpp
    colors.cpp
    common.cpp
    common_plot_functions.cpp
    common_plotHPGL_functions.cpp
    common_plotPS_functions.cpp
    common_plotPDF_functions.cpp
    common_plotGERBER_functions.cpp
    common_plotDXF_functions.cpp
    common_plotSVG_functions.cpp
    config_params.cpp
    confirm.cpp
    copy_to_clipboard.cpp
    convert_basic_shapes_to_polygon.cpp
    dialog_shim.cpp
    displlst.cpp
    draw_frame.cpp
    draw_panel.cpp
    drawtxt.cpp
    dsnlexer.cpp
    eda_dde.cpp
    eda_doc.cpp
    filter_reader.cpp
#    findkicadhelppath.cpp.notused      deprecated, use searchhelpfilefullpath.cpp
    gestfich.cpp
    getrunningmicrosecs.cpp
    grid_tricks.cpp
    gr_basic.cpp
    hotkeys_basic.cpp
    html_messagebox.cpp
    kiface_i.cpp
    kiway.cpp
    kiway_express.cpp
    kiway_holder.cpp
    kiway_player.cpp
    lockfile.cpp
    msgpanel.cpp
    netlist_keywords.cpp
    newstroke_font.cpp
    prependpath.cpp
    project.cpp
    ptree.cpp
    reporter.cpp
    richio.cpp
    searchhelpfilefullpath.cpp
    search_stack.cpp
    selcolor.cpp
    systemdirsappend.cpp
    trigo.cpp
    utf8.cpp
    validators.cpp
    wildcards_and_files_ext.cpp
    worksheet.cpp
    wxwineda.cpp
    wx_unit_binder.cpp
    wx_status_popup.cpp
    xnode.cpp
    zoom.cpp
    )

if( TRUE OR NOT USE_KIWAY_DLLS )
#if( NOT USE_KIWAY_DLLS )
    # We DO NOT want pgm_base.cpp linked into the KIFACE, only into the KIWAY.
    # Check the map files to verify eda_pgm.o not being linked in.
    list( APPEND COMMON_SRCS pgm_base.cpp )
endif()

if( NOT HAVE_STRTOKR )
    list( APPEND COMMON_SRCS strtok_r.c )
endif()


set( COMMON_SRCS
    ${COMMON_SRCS}
    kicad_curl/kicad_curl.cpp
    kicad_curl/kicad_curl_easy.cpp

    view/view.cpp
    view/view_item.cpp
    view/view_group.cpp

    math/math_util.cpp

    tool/tool_action.cpp
    tool/tool_base.cpp
    tool/tool_manager.cpp
    tool/tool_dispatcher.cpp
    tool/tool_event.cpp
    tool/tool_interactive.cpp
    tool/action_manager.cpp
    tool/context_menu.cpp

    geometry/seg.cpp
    geometry/shape.cpp
    geometry/shape_line_chain.cpp
    geometry/shape_poly_set.cpp
    geometry/shape_collisions.cpp
    geometry/shape_file_io.cpp
    )
add_library( common STATIC ${COMMON_SRCS} )
add_dependencies( common lib-dependencies )
add_dependencies( common version_header )
target_link_libraries( common
    ${Boost_LIBRARIES}
    ${CURL_LIBRARIES}
    ${OPENSSL_LIBRARIES}        # empty on Apple
    )


set( PCB_COMMON_SRCS
    base_screen.cpp
    eda_text.cpp
    class_page_info.cpp
    pcbcommon.cpp
    lset.cpp
    footprint_info.cpp
    ../pcbnew/basepcbframe.cpp
    ../pcbnew/class_board.cpp
    ../pcbnew/class_board_connected_item.cpp
    ../pcbnew/class_board_design_settings.cpp
    ../pcbnew/class_board_item.cpp
    ../pcbnew/class_dimension.cpp
    ../pcbnew/class_drawsegment.cpp
    ../pcbnew/class_drc_item.cpp
    ../pcbnew/class_edge_mod.cpp
    ../pcbnew/class_netclass.cpp
    ../pcbnew/class_netinfo_item.cpp
    ../pcbnew/class_netinfolist.cpp
    ../pcbnew/class_marker_pcb.cpp
    ../pcbnew/class_mire.cpp
    ../pcbnew/class_module.cpp
    ../pcbnew/class_pad.cpp
    ../pcbnew/class_pad_draw_functions.cpp
    ../pcbnew/class_pcb_text.cpp
    ../pcbnew/class_text_mod.cpp
    ../pcbnew/class_track.cpp
    ../pcbnew/class_zone.cpp
    ../pcbnew/class_zone_settings.cpp
    ../pcbnew/classpcb.cpp
    ../pcbnew/ratsnest_data.cpp
    ../pcbnew/ratsnest_viewitem.cpp
    ../pcbnew/collectors.cpp
    ../pcbnew/netlist_reader.cpp
    ../pcbnew/legacy_netlist_reader.cpp
    ../pcbnew/kicad_netlist_reader.cpp
    ../pcbnew/sel_layer.cpp
    ../pcbnew/pcb_plot_params.cpp
    ../pcbnew/io_mgr.cpp
    ../pcbnew/plugin.cpp
    ../pcbnew/eagle_plugin.cpp
    ../pcbnew/legacy_plugin.cpp
    ../pcbnew/kicad_plugin.cpp
    ../pcbnew/gpcb_plugin.cpp
    ../pcbnew/pcb_netlist.cpp
    ../pcbnew/specctra.cpp
    ../pcbnew/specctra_export.cpp
    ../pcbnew/specctra_keywords.cpp
    pcb_plot_params_keywords.cpp
    pcb_keywords.cpp
    ../pcbnew/pcb_parser.cpp
    fp_lib_table_keywords.cpp
    fpid.cpp
    fp_lib_table.cpp
)

set( PCB_COMMON_SRCS
    ${PCB_COMMON_SRCS}
    ../pcbnew/pcb_painter.cpp
    )

# add -DPCBNEW to compilation of these PCBNEW sources
set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES
    COMPILE_DEFINITIONS "PCBNEW"
    )

add_library( pcbcommon STATIC ${PCB_COMMON_SRCS} )
add_dependencies( pcbcommon lib-dependencies )

# auto-generate specctra_lexer.h and specctra_keywords.cpp
make_lexer(
    ${PROJECT_SOURCE_DIR}/pcbnew/specctra.keywords
    ${PROJECT_SOURCE_DIR}/pcbnew/specctra_lexer.h
    ${PROJECT_SOURCE_DIR}/pcbnew/specctra_keywords.cpp
    DSN

    # Pass header file with dependency on *_lexer.h as extra_arg
    specctra.h
    )

add_custom_target(
    specctra_lexer_source_files ALL
    DEPENDS
        ${PROJECT_SOURCE_DIR}/pcbnew/specctra_lexer.h
        ${PROJECT_SOURCE_DIR}/pcbnew/specctra_keywords.cpp
    )

add_dependencies( pcbcommon specctra_lexer_source_files )

# auto-generate netlist_lexer.h and netlist_keywords.cpp
make_lexer(
    ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
    ${PROJECT_SOURCE_DIR}/include/netlist_lexer.h
    ${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp
    NL_T

    # Pass header file with dependency on *_lexer.h as extra_arg
    ${CMAKE_PROJECT_SOURCE_DIR}/pcbnew/netlist_reader.h
    )

add_custom_target(
    netlist_lexer_source_files ALL
    DEPENDS
        ${PROJECT_SOURCE_DIR}/include/netlist_lexer.h
        ${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp
    )

add_dependencies( common netlist_lexer_source_files )
add_dependencies( pcbcommon netlist_lexer_source_files )

# auto-generate pcb_plot_params_lexer.h and pcb_plot_params_keywords.cpp
make_lexer(
    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_plot_params.keywords
    ${PROJECT_SOURCE_DIR}/include/pcb_plot_params_lexer.h
    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_plot_params_keywords.cpp
    PCBPLOTPARAMS_T

    # Pass header file with dependencies on *_lexer.h as extra_arg
    ${PROJECT_SOURCE_DIR}/pcbnew/pcb_plot_params.h
    )

add_custom_target(
    pcb_plot_lexer_source_files ALL
    DEPENDS
        ${PROJECT_SOURCE_DIR}/include/pcb_plot_params_lexer.h
        ${CMAKE_CURRENT_SOURCE_DIR}/pcb_plot_params_keywords.cpp
    )

add_dependencies( pcbcommon pcb_plot_lexer_source_files )

# auto-generate pcbnew_sexpr.h and pcbnew_sexpr.cpp
make_lexer(
    ${CMAKE_CURRENT_SOURCE_DIR}/pcb.keywords
    ${PROJECT_SOURCE_DIR}/include/pcb_lexer.h
    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_keywords.cpp
    PCB_KEYS_T

    # Pass header file with dependency on *_lexer.h as extra_arg
    ${PROJECT_SOURCE_DIR}/pcbnew/pcb_parser.h
    )

add_custom_target(
    pcb_lexer_source_files ALL
    DEPENDS
        ${PROJECT_SOURCE_DIR}/include/pcb_lexer.h
        ${CMAKE_CURRENT_SOURCE_DIR}/pcb_keywords.cpp
    )

add_dependencies( pcbcommon pcb_lexer_source_files )

# auto-generate pcbnew s-expression footprint library table code.
make_lexer(
    ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table.keywords
    ${PROJECT_SOURCE_DIR}/include/fp_lib_table_lexer.h
    ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table_keywords.cpp
    FP_LIB_TABLE_T
    )

add_custom_target(
    fp_lib_table_lexer_source_files ALL
    DEPENDS
        ${PROJECT_SOURCE_DIR}/include/fp_lib_table_lexer.h
        ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table_keywords.cpp
    )

add_dependencies( pcbcommon fp_lib_table_lexer_source_files )

# auto-generate page layout reader s-expression page_layout_reader_lexer.h
# and title_block_reader_keywords.cpp.
make_lexer(
    ${CMAKE_CURRENT_SOURCE_DIR}/page_layout/page_layout_reader.keywords
    ${PROJECT_SOURCE_DIR}/include/page_layout_reader_lexer.h
    ${CMAKE_CURRENT_SOURCE_DIR}/page_layout/page_layout_reader_keywords.cpp
    TB_READER_T
    )

add_custom_target(
    page_layout_lexer_source_files ALL
    DEPENDS
        ${PROJECT_SOURCE_DIR}/include/page_layout_reader_lexer.h
        ${CMAKE_CURRENT_SOURCE_DIR}/page_layout/page_layout_reader_keywords.cpp
    )

add_dependencies( common page_layout_lexer_source_files )

# This one gets made only when testing.
# to build it, first enable #define STAND_ALONE at top of dsnlexer.cpp
add_executable( dsntest EXCLUDE_FROM_ALL dsnlexer.cpp )
target_link_libraries( dsntest common ${wxWidgets_LIBRARIES} rt )

add_dependencies( dsntest lib-dependencies )