This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
1348 lines (1298 loc) · 40.7 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
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required(VERSION 3.5)
project(python LANGUAGES C CXX VERSION 3.8.5)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_TOOLCHAIN_FILE)
message(SEND_ERROR "
")
file(GLOB TOOLCHAIN_FILES RELATIVE ${CMAKE_SOURCE_DIR} util/*.cmake)
list(FILTER TOOLCHAIN_FILES EXCLUDE REGEX util/.*-common\.cmake)
string(REPLACE ";" "\n " TOOLCHAIN_FILES "${TOOLCHAIN_FILES}")
message(FATAL_ERROR "
Error: This project requires a toolchain file.
Please specify CMAKE_TOOLCHAIN_FILE. Example:
$ mkdir build
$ cd build
$ cmake -GNinja -D CMAKE_TOOLCHAIN_FILE=../util/platform009-clang.cmake ..
Available toolchain files:
${TOOLCHAIN_FILES}
")
endif()
# Append flags set by util/*.cmake files.
# Note that setting CMAKE_C_FLAGS directly in util/*.cmake is problematic
# because using `-DCMAKE_C_FLAGS=` would unintentionally override the platform
# flags.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_COMPILER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_COMPILER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} ${PLATFORM_LINKER_FLAGS}")
# Add an option to disable cpython-tests to avoid source files getting compiled
# for two targets and confusing the compilation database used by clang-tidy.
option(ENABLE_CPYTHON_TESTS "Add cpython-tests target" ON)
# Add an option to copy pre-built freeze_modules.py output instead of running
# Python to avoid circular dependencies in the third-party2 build.
option(USE_PRECOMPILED_FROZEN_MODULES "Use pre-compiled frozen modules" OFF)
# Add -DSKYBISON_ASAN=1 to the cmake command line to enable asan.
if (${SKYBISON_ASAN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
set(BENCHMARK_ENABLE_TESTING CACHE BOOL OFF FORCE)
set(BENCHMARK_ENABLE_EXCEPTIONS CACHE BOOL OFF FORCE)
set(BENCHMARK_ENABLE_INSTALL CACHE BOOL OFF FORCE)
add_subdirectory(third-party/benchmark-1.5.1)
set(INSTALL_GTEST CACHE BOOL OFF FORCE)
add_subdirectory(third-party/googletest)
set(THIRD_PARTY_SIPHASH third-party/siphash-20170224)
add_subdirectory(${THIRD_PARTY_SIPHASH})
add_subdirectory(third-party/systemtap)
add_subdirectory(third-party/valgrind-3.15.0)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
set(WARN_MISSING_DECLARATIONS -Wmissing-prototypes)
else()
set(WARN_MISSING_DECLARATIONS -Wmissing-declarations)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OS_DEFINE "-DOS_OSX" CACHE STRING "")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(OS_DEFINE "-DOS_LINUX" CACHE STRING "")
else()
message("Unknown CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
endif()
set(CMAKE_C_EXTENSIONS NO)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED YES)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# DebugOpt build type: debug assertions/checks with -Os. Runs tests much more
# quickly than Debug, but isn't as debuggable as a Debug build in gdb or lldb.
set(CMAKE_C_FLAGS_DEBUGOPT "-Os -g3" CACHE STRING
"Flags used by the C compiler during DebugOpt builds."
FORCE)
set(CMAKE_CXX_FLAGS_DEBUGOPT "-Os -g3" CACHE STRING
"Flags used by the C++ compiler during DebugOpt builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEBUGOPT
"${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
"Flags used for linking binaries during DebugOpt builds."
FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUGOPT
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
"Flags used by the shared libraries linker during DebugOpt builds."
FORCE)
mark_as_advanced(
CMAKE_CXX_FLAGS_DEBUGOPT
CMAKE_C_FLAGS_DEBUGOPT
CMAKE_EXE_LINKER_FLAGS_DEBUGOPT
CMAKE_SHARED_LINKER_FLAGS_DEBUGOPT)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "DebugOpt" "Release" "RelWithDebInfo" "MinSizeRel")
# Set a default for CMAKE_BUILD_TYPE.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug")
endif()
set(
PYRO_COMPILE_OPTIONS
-Wall
-Werror
-Wextra
-Wno-missing-braces
-Wno-missing-field-initializers
-Wpedantic
-Wshadow
-fno-exceptions
-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fno-rtti)
set(CPYTHON_DIR ${CMAKE_SOURCE_DIR}/third-party/cpython)
set(CPYTHON_BUILD_DIR ${CMAKE_BINARY_DIR}/third-party/cpython)
file(MAKE_DIRECTORY ${CPYTHON_BUILD_DIR})
set(CPYTHON_EXECUTABLE ${CPYTHON_BUILD_DIR}/python)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# The binary has a .exe suffix on systems with a case-insensitive filesystem.
set(CPYTHON_EXECUTABLE ${CPYTHON_EXECUTABLE}.exe)
endif()
file(GLOB_RECURSE CPYTHON_FILES ${CPYTHON_DIR}/*)
# Filter out files starting with a dot (to catch vim .xxx.swp files)
list(FILTER CPYTHON_FILES EXCLUDE REGEX "/\\.")
# Filter out emacs temp files
list(FILTER CPYTHON_FILES EXCLUDE REGEX "~$")
list(FILTER CPYTHON_FILES EXCLUDE REGEX "/#.*#$")
# Filer out Pyro generated bytecode files
list(FILTER CPYTHON_FILES EXCLUDE REGEX "/__pycache__/")
set(CPYTHON_CONFIGURE_FLAGS)
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPER)
if (${BUILD_TYPE_UPPER} MATCHES "^DEBUG")
set(LIBCPYTHON_BIN ${CPYTHON_BUILD_DIR}/libpython3.8d.a)
set(CPYTHON_CONFIGURE_FLAGS "${CPYTHON_CONFIGURE_FLAGS} --with-pydebug")
else()
set(LIBCPYTHON_BIN ${CPYTHON_BUILD_DIR}/libpython3.8.a)
endif()
set(CPYTHON_CFLAGS
"${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BUILD_TYPE_UPPER}} -fPIC")
set(CPYTHON_CPPFLAGS)
set(CPYTHON_LDFLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CPYTHON_CONFIGURE_FLAGS
"${CPYTHON_CONFIGURE_FLAGS} --with-openssl=${OPENSSL_PREFIX}")
foreach(dir
${BZIP2_INCLUDE_DIRS}
${FFI_INCLUDE_DIRS}
${NCURSES_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
${READLINE_INCLUDE_DIRS}
${SQLITE_INCLUDE_DIRS}
${XZ_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS})
set(CPYTHON_CPPFLAGS "${CPYTHON_CPPFLAGS} -I${dir}")
endforeach()
foreach(dir
${BZIP2_LIBRARY_DIRS}
${FFI_LIBRARY_DIRS}
${NCURSES_LIBRARY_DIRS}
${OPENSSL_LIBRARY_DIRS}
${READLINE_LIBRARY_DIRS}
${SQLITE_LIBRARY_DIRS}
${XZ_LIBRARY_DIRS}
${ZLIB_LIBRARY_DIRS})
set(CPYTHON_LDFLAGS "${CPYTHON_LDFLAGS} -L${dir}")
endforeach()
if (CMAKE_OSX_SYSROOT)
set(CPYTHON_CFLAGS "${CPYTHON_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
set(CPYTHON_LDFLAGS "${CPYTHON_LDFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
# Write commands into a script to avoid quoting problems.
file(GENERATE OUTPUT ${CPYTHON_BUILD_DIR}/build.sh CONTENT "
set -eu
export CC=\"${CMAKE_C_COMPILER}\"
export CXX=\"${CMAKE_CXX_COMPILER}\"
export CFLAGS=\"${CPYTHON_CFLAGS}\"
export CPPFLAGS=\"${CPYTHON_CPPFLAGS}\"
export LDFLAGS=\"${CPYTHON_LDFLAGS}\"
rm -f ${CPYTHON_BUILD_DIR}/Modules/Setup
${CPYTHON_DIR}/configure ${CPYTHON_CONFIGURE_FLAGS}
make -j
")
add_custom_command(
OUTPUT ${LIBCPYTHON_BIN} ${CPYTHON_EXECUTABLE}
COMMAND cat ${CPYTHON_BUILD_DIR}/build.sh
COMMAND /bin/sh ${CPYTHON_BUILD_DIR}/build.sh
COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${LIBCPYTHON_BIN}
${CPYTHON_EXECUTABLE}
DEPENDS ${CPYTHON_FILES}
WORKING_DIRECTORY ${CPYTHON_BUILD_DIR}
USES_TERMINAL)
add_custom_target(cpython DEPENDS ${LIBCPYTHON_BIN})
add_library(libcpython STATIC IMPORTED)
add_dependencies(libcpython cpython)
set_target_properties(libcpython PROPERTIES IMPORTED_LOCATION ${LIBCPYTHON_BIN})
set(
C_API_HEADERS
${CMAKE_SOURCE_DIR}/capi/Python.h
${CMAKE_SOURCE_DIR}/capi/abstract.h
${CMAKE_SOURCE_DIR}/capi/bltinmodule.h
${CMAKE_SOURCE_DIR}/capi/boolobject.h
${CMAKE_SOURCE_DIR}/capi/bytearrayobject.h
${CMAKE_SOURCE_DIR}/capi/bytesobject.h
${CMAKE_SOURCE_DIR}/capi/cellobject.h
${CMAKE_SOURCE_DIR}/capi/ceval.h
${CMAKE_SOURCE_DIR}/capi/classobject.h
${CMAKE_SOURCE_DIR}/capi/code.h
${CMAKE_SOURCE_DIR}/capi/codecs.h
${CMAKE_SOURCE_DIR}/capi/compile.h
${CMAKE_SOURCE_DIR}/capi/complexobject.h
${CMAKE_SOURCE_DIR}/capi/cpython-data.h
${CMAKE_SOURCE_DIR}/capi/cpython-func.h
${CMAKE_SOURCE_DIR}/capi/cpython-types.h
${CMAKE_SOURCE_DIR}/capi/datetime.h
${CMAKE_SOURCE_DIR}/capi/descrobject.h
${CMAKE_SOURCE_DIR}/capi/dictobject.h
${CMAKE_SOURCE_DIR}/capi/dtoa.h
${CMAKE_SOURCE_DIR}/capi/enumobject.h
${CMAKE_SOURCE_DIR}/capi/eval.h
${CMAKE_SOURCE_DIR}/capi/fileobject.h
${CMAKE_SOURCE_DIR}/capi/fileutils.h
${CMAKE_SOURCE_DIR}/capi/floatobject.h
${CMAKE_SOURCE_DIR}/capi/funcobject.h
${CMAKE_SOURCE_DIR}/capi/genobject.h
${CMAKE_SOURCE_DIR}/capi/import.h
${CMAKE_SOURCE_DIR}/capi/intrcheck.h
${CMAKE_SOURCE_DIR}/capi/iterobject.h
${CMAKE_SOURCE_DIR}/capi/listobject.h
${CMAKE_SOURCE_DIR}/capi/longintrepr.h
${CMAKE_SOURCE_DIR}/capi/longobject.h
${CMAKE_SOURCE_DIR}/capi/memoryobject.h
${CMAKE_SOURCE_DIR}/capi/methodobject.h
${CMAKE_SOURCE_DIR}/capi/modsupport.h
${CMAKE_SOURCE_DIR}/capi/moduleobject.h
${CMAKE_SOURCE_DIR}/capi/namespaceobject.h
${CMAKE_SOURCE_DIR}/capi/object.h
${CMAKE_SOURCE_DIR}/capi/objimpl.h
${CMAKE_SOURCE_DIR}/capi/odictobject.h
${CMAKE_SOURCE_DIR}/capi/osmodule.h
${CMAKE_SOURCE_DIR}/capi/patchlevel.h
${CMAKE_SOURCE_DIR}/capi/pyarena.h
${CMAKE_SOURCE_DIR}/capi/pyatomic.h
${CMAKE_SOURCE_DIR}/capi/pycapsule.h
${CMAKE_SOURCE_DIR}/capi/pyconfig-linux.h
${CMAKE_SOURCE_DIR}/capi/pyconfig-osx.h
${CMAKE_SOURCE_DIR}/capi/pyconfig.h
${CMAKE_SOURCE_DIR}/capi/pyctype.h
${CMAKE_SOURCE_DIR}/capi/pydebug.h
${CMAKE_SOURCE_DIR}/capi/pyerrors.h
${CMAKE_SOURCE_DIR}/capi/pyfpe.h
${CMAKE_SOURCE_DIR}/capi/pyhash.h
${CMAKE_SOURCE_DIR}/capi/pylifecycle.h
${CMAKE_SOURCE_DIR}/capi/pymacconfig.h
${CMAKE_SOURCE_DIR}/capi/pymacro.h
${CMAKE_SOURCE_DIR}/capi/pymath.h
${CMAKE_SOURCE_DIR}/capi/pymem.h
${CMAKE_SOURCE_DIR}/capi/pyport.h
${CMAKE_SOURCE_DIR}/capi/pystate.h
${CMAKE_SOURCE_DIR}/capi/pystrcmp.h
${CMAKE_SOURCE_DIR}/capi/pystrtod.h
${CMAKE_SOURCE_DIR}/capi/pythonrun.h
${CMAKE_SOURCE_DIR}/capi/pythread.h
${CMAKE_SOURCE_DIR}/capi/pytime.h
${CMAKE_SOURCE_DIR}/capi/rangeobject.h
${CMAKE_SOURCE_DIR}/capi/setobject.h
${CMAKE_SOURCE_DIR}/capi/sliceobject.h
${CMAKE_SOURCE_DIR}/capi/structmember.h
${CMAKE_SOURCE_DIR}/capi/structseq.h
${CMAKE_SOURCE_DIR}/capi/sysmodule.h
${CMAKE_SOURCE_DIR}/capi/traceback.h
${CMAKE_SOURCE_DIR}/capi/tupleobject.h
${CMAKE_SOURCE_DIR}/capi/typeslots.h
${CMAKE_SOURCE_DIR}/capi/unicodeobject.h
${CMAKE_SOURCE_DIR}/capi/warnings.h
${CMAKE_SOURCE_DIR}/capi/weakrefobject.h)
add_library(capi-headers INTERFACE)
target_sources(
capi-headers
INTERFACE
${C_API_HEADERS})
target_include_directories(
capi-headers
INTERFACE
capi)
file(READ capi/cpython-data.h cpython_data)
if (NOT cpython_data MATCHES
".*#define PY_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}\n.*" OR
NOT cpython_data MATCHES
".*#define PY_MINOR_VERSION ${PROJECT_VERSION_MINOR}\n.*" OR
NOT cpython_data MATCHES
".*#define PY_MICRO_VERSION ${PROJECT_VERSION_PATCH}\n.*")
message(SEND_ERROR "
PY_MAJOR_VERSION, PY_MINOR_VERSION, PY_MICRO_VERSION defines in
`capi/cpython-data.h` do not match version from `CMakeLists.txt`: \
${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
")
endif()
set(IMPLEMENTATION_DIR pyro${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
set(BUILD_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/${IMPLEMENTATION_DIR}")
string(
REGEX
REPLACE "(${CMAKE_SOURCE_DIR}\/capi\/)" "${BUILD_INCLUDE_DIR}/"
C_API_HEADERS_OUTPUT
"${C_API_HEADERS}")
add_custom_command(
OUTPUT ${C_API_HEADERS_OUTPUT}
COMMAND
${CMAKE_COMMAND} -E make_directory ${BUILD_INCLUDE_DIR}
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${C_API_HEADERS} ${BUILD_INCLUDE_DIR}
DEPENDS ${C_API_HEADERS}
COMMENT "Copying C-API headers")
add_custom_target(copy-capi-headers ALL DEPENDS ${C_API_HEADERS_OUTPUT})
include(${CMAKE_SOURCE_DIR}/frozen_library_files.cmake)
set(FROZEN_MODULE_INPUT ${SYSCONFIGDATA} ${FROZEN_LIBRARY_FILES})
set(
FROZEN_MODULE_OUTPUT_DIR
${CMAKE_BINARY_DIR}/bootstrap)
set(
FROZEN_MODULE_OUTPUT
${FROZEN_MODULE_OUTPUT_DIR}/builtins.cpp
${FROZEN_MODULE_OUTPUT_DIR}/builtins.h
${FROZEN_MODULE_OUTPUT_DIR}/frozen-modules.cpp
${FROZEN_MODULE_OUTPUT_DIR}/frozen-modules.h)
if (USE_PRECOMPILED_FROZEN_MODULES)
set(
PRECOMPILED_FROZEN_MODULE_INPUT_DIR
${CMAKE_SOURCE_DIR}/precompiled_frozen_modules)
set(
PRECOMPILED_FROZEN_MODULE_INPUT
${PRECOMPILED_FROZEN_MODULE_INPUT_DIR}/builtins.cpp
${PRECOMPILED_FROZEN_MODULE_INPUT_DIR}/builtins.h
${PRECOMPILED_FROZEN_MODULE_INPUT_DIR}/frozen-modules.cpp
${PRECOMPILED_FROZEN_MODULE_INPUT_DIR}/frozen-modules.h)
add_custom_command(
OUTPUT
${FROZEN_MODULE_OUTPUT}
COMMAND
${CMAKE_COMMAND} -E copy_if_different
${PRECOMPILED_FROZEN_MODULE_INPUT} ${FROZEN_MODULE_OUTPUT_DIR}
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
DEPENDS ${PRECOMPILED_FROZEN_MODULE_INPUT})
else()
add_custom_command(
OUTPUT
${FROZEN_MODULE_OUTPUT}
COMMAND
/usr/bin/python3.8 util/freeze_modules.py ${FROZEN_MODULE_OUTPUT_DIR}
${FROZEN_MODULE_INPUT}
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
DEPENDS util/freeze_modules.py ${FROZEN_MODULE_INPUT})
endif()
# This target is built in util/run_clang_tidy.py:create_compile_commands() to
# ensure all generated files are present when clang-tidy runs.
add_custom_target(
frozen-sources
DEPENDS
${FROZEN_MODULE_OUTPUT})
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(
RUNTIME_OS_SOURCES
runtime/file-darwin.cpp
runtime/os-darwin.cpp
runtime/mutex-darwin.cpp)
set(
EXTENSION_OS_SOURCES
ext/Python/pystrcmp-posix.cpp)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(
RUNTIME_OS_SOURCES
runtime/file-linux.cpp
runtime/os-linux.cpp
runtime/mutex-linux.cpp)
set(
EXTENSION_OS_SOURCES
ext/Python/pystrcmp-posix.cpp)
endif()
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set(
RUNTIME_ARCH_SOURCES
runtime/interpreter-gen-x64.cpp
)
else()
message(FATAL_ERROR "Unsupported architecture ${CMAKE_SYSTEM_PROCESSOR}")
endif()
add_library(
libpython
SHARED
capi/cpython-func.h
ext/libpython.cpp
)
target_compile_options(
libpython
PRIVATE
-Wno-return-type
)
target_include_directories(
libpython
PRIVATE
capi
)
set_target_properties(
libpython
PROPERTIES
OUTPUT_NAME
python.pyro3.8 # Produces libpython.pyro3.8.so
)
add_library(
runtime
OBJECT
runtime/array-module.cpp
runtime/array-module.h
runtime/assembler-utils.cpp
runtime/assembler-utils.h
runtime/assembler-x64.cpp
runtime/assembler-x64.h
runtime/asserts.cpp
runtime/asserts.h
runtime/attributedict.cpp
runtime/attributedict.h
runtime/builtins-module.cpp
runtime/builtins-module.h
runtime/bytearray-builtins.cpp
runtime/bytearray-builtins.h
runtime/bytecode.cpp
runtime/bytecode.h
runtime/bytes-builtins.cpp
runtime/bytes-builtins.h
runtime/byteslike.cpp
runtime/byteslike.h
runtime/capi.h
runtime/code-builtins.cpp
runtime/code-builtins.h
runtime/complex-builtins.cpp
runtime/complex-builtins.h
runtime/debugging.cpp
runtime/debugging.h
runtime/descriptor-builtins.cpp
runtime/descriptor-builtins.h
runtime/dict-builtins.cpp
runtime/dict-builtins.h
runtime/disassembler-x64.cpp
runtime/disassembler.cpp
runtime/disassembler.h
runtime/event.h
runtime/exception-builtins.cpp
runtime/exception-builtins.h
runtime/faulthandler-module.cpp
runtime/file.h
runtime/float-builtins.cpp
runtime/float-builtins.h
runtime/float-conversion.cpp
runtime/float-conversion.h
runtime/formatter-utils.h
runtime/formatter.cpp
runtime/formatter.h
runtime/frame-proxy-builtins.cpp
runtime/frame-proxy-builtins.h
runtime/frame.cpp
runtime/frame.h
runtime/function-builtins.cpp
runtime/gc-module.cpp
runtime/generator-builtins.cpp
runtime/globals.h
runtime/handles.cpp
runtime/handles.h
runtime/heap-profiler.cpp
runtime/heap-profiler.h
runtime/heap.cpp
runtime/heap.h
runtime/ic.cpp
runtime/ic.h
runtime/int-builtins.cpp
runtime/int-builtins.h
runtime/interpreter-gen.h
runtime/interpreter.cpp
runtime/interpreter.h
runtime/iterator-builtins.cpp
runtime/iterator-builtins.h
runtime/layout-builtins.cpp
runtime/layout-builtins.h
runtime/layout.h
runtime/linked-list.h
runtime/list-builtins.cpp
runtime/list-builtins.h
runtime/mappingproxy-builtins.cpp
runtime/mappingproxy-builtins.h
runtime/marshal-module.cpp
runtime/marshal.cpp
runtime/marshal.h
runtime/memory-region.cpp
runtime/memory-region.h
runtime/memoryview-builtins.cpp
runtime/memoryview-builtins.h
runtime/mmap-module.cpp
runtime/mmap-module.h
runtime/module-builtins.cpp
runtime/module-builtins.h
runtime/module-proxy-builtins.cpp
runtime/module-proxy-builtins.h
runtime/modules.cpp
runtime/modules.h
runtime/mro.cpp
runtime/mro.h
runtime/mutex.h
runtime/object-builtins.cpp
runtime/objects.cpp
runtime/objects.h
runtime/os.cpp
runtime/os.h
runtime/profiling.cpp
runtime/profiling.h
runtime/range-builtins.cpp
runtime/range-builtins.h
runtime/ref-builtins.cpp
runtime/ref-builtins.h
runtime/register-state.cpp
runtime/register-state.h
runtime/runtime.cpp
runtime/runtime.h
runtime/scavenger.cpp
runtime/scavenger.h
runtime/set-builtins.cpp
runtime/set-builtins.h
runtime/slice-builtins.cpp
runtime/slice-builtins.h
runtime/space.cpp
runtime/space.h
runtime/str-builtins.cpp
runtime/str-builtins.h
runtime/str-intern.cpp
runtime/str-intern.h
runtime/strarray-builtins.cpp
runtime/strarray-builtins.h
runtime/structseq-builtins.cpp
runtime/structseq-builtins.h
runtime/super-builtins.cpp
runtime/super-builtins.h
runtime/symbols.cpp
runtime/symbols.h
runtime/sys-module.cpp
runtime/sys-module.h
runtime/thread.cpp
runtime/thread.h
runtime/traceback-builtins.cpp
runtime/traceback-builtins.h
runtime/trampolines.cpp
runtime/trampolines.h
runtime/tuple-builtins.cpp
runtime/tuple-builtins.h
runtime/type-builtins.cpp
runtime/under-builtins-module.cpp
runtime/under-bytecode-utils-module.cpp
runtime/under-codecs-module.cpp
runtime/under-collections-module.cpp
runtime/under-collections-module.h
runtime/under-contextvars-module.cpp
runtime/under-contextvars-module.h
runtime/under-ctypes-module.cpp
runtime/under-imp-module.cpp
runtime/under-imp-module.h
runtime/under-io-module.cpp
runtime/under-io-module.h
runtime/under-json-module.cpp
runtime/under-os-module.cpp
runtime/under-path-module.cpp
runtime/under-signal-module.cpp
runtime/under-signal-module.h
runtime/under-thread-module.cpp
runtime/under-valgrind-module.cpp
runtime/under-warnings-module.cpp
runtime/under-weakref-module.cpp
runtime/unicode-db.cpp
runtime/unicode-db.h
runtime/unicode.cpp
runtime/unicode.h
runtime/unicodedata-module.cpp
runtime/utils.cpp
runtime/utils.h
runtime/valuecell-builtins.cpp
runtime/valuecell-builtins.h
runtime/vector.h
runtime/version.cpp
runtime/version.h
runtime/view.h
runtime/visitor.h
${FROZEN_MODULE_OUTPUT}
${RUNTIME_OS_SOURCES}
${RUNTIME_ARCH_SOURCES})
target_compile_options(
runtime
PRIVATE
${PYRO_COMPILE_OPTIONS}
${WARN_MISSING_DECLARATIONS})
target_include_directories(
runtime
INTERFACE
runtime
PRIVATE
${FFI_INCLUDE_DIRS}
${THIRD_PARTY_SIPHASH}/include)
target_link_libraries(
runtime
PUBLIC
capi-headers
-pthread
PRIVATE
${CMAKE_DL_LIBS}
modules
systemtap
valgrind
${FFI_LIBRARIES})
target_include_directories(runtime PRIVATE ${FROZEN_MODULE_OUTPUT_DIR}
${CMAKE_SOURCE_DIR}/runtime)
add_library(
expat
OBJECT
${CPYTHON_DIR}/Modules/expat/ascii.h
${CPYTHON_DIR}/Modules/expat/asciitab.h
${CPYTHON_DIR}/Modules/expat/expat_config.h
${CPYTHON_DIR}/Modules/expat/expat_external.h
${CPYTHON_DIR}/Modules/expat/expat.h
${CPYTHON_DIR}/Modules/expat/iasciitab.h
${CPYTHON_DIR}/Modules/expat/internal.h
${CPYTHON_DIR}/Modules/expat/latin1tab.h
${CPYTHON_DIR}/Modules/expat/nametab.h
${CPYTHON_DIR}/Modules/expat/pyexpatns.h
${CPYTHON_DIR}/Modules/expat/siphash.h
${CPYTHON_DIR}/Modules/expat/utf8tab.h
${CPYTHON_DIR}/Modules/expat/winconfig.h
${CPYTHON_DIR}/Modules/expat/xmlparse.c
${CPYTHON_DIR}/Modules/expat/xmlrole.c
${CPYTHON_DIR}/Modules/expat/xmlrole.h
${CPYTHON_DIR}/Modules/expat/xmltok.c
${CPYTHON_DIR}/Modules/expat/xmltok.h
${CPYTHON_DIR}/Modules/expat/xmltok_impl.c
${CPYTHON_DIR}/Modules/expat/xmltok_impl.h
${CPYTHON_DIR}/Modules/expat/xmltok_ns.c
)
target_compile_options(
expat
PRIVATE
-DHAVE_EXPAT_CONFIG_H
-DXML_POOR_ENTROPY)
target_link_libraries(
expat
PRIVATE
capi-headers
)
add_library(
extension-modules
OBJECT
${CPYTHON_DIR}/Modules/_bisectmodule.c
${CPYTHON_DIR}/Modules/_blake2/blake2b_impl.c
${CPYTHON_DIR}/Modules/_blake2/blake2module.c
${CPYTHON_DIR}/Modules/_blake2/blake2s_impl.c
${CPYTHON_DIR}/Modules/_blake2/clinic/blake2b_impl.c.h
${CPYTHON_DIR}/Modules/_blake2/clinic/blake2s_impl.c.h
${CPYTHON_DIR}/Modules/_bz2module.c
${CPYTHON_DIR}/Modules/_cursesmodule.c
${CPYTHON_DIR}/Modules/_csv.c
${CPYTHON_DIR}/Modules/_datetimemodule.c
${CPYTHON_DIR}/Modules/_hashopenssl.c
${CPYTHON_DIR}/Modules/_localemodule.c
${CPYTHON_DIR}/Modules/_lzmamodule.c
${CPYTHON_DIR}/Modules/_math.c
${CPYTHON_DIR}/Modules/_math.h
${CPYTHON_DIR}/Modules/_multiprocessing/multiprocessing.h
${CPYTHON_DIR}/Modules/_multiprocessing/multiprocessing.c
${CPYTHON_DIR}/Modules/_multiprocessing/posixshmem.c
${CPYTHON_DIR}/Modules/_multiprocessing/semaphore.c
${CPYTHON_DIR}/Modules/_posixsubprocess.c
${CPYTHON_DIR}/Modules/_randommodule.c
${CPYTHON_DIR}/Modules/_sha3/sha3module.c
${CPYTHON_DIR}/Modules/_sqlite/cache.c
${CPYTHON_DIR}/Modules/_sqlite/cache.h
${CPYTHON_DIR}/Modules/_sqlite/connection.c
${CPYTHON_DIR}/Modules/_sqlite/connection.h
${CPYTHON_DIR}/Modules/_sqlite/cursor.c
${CPYTHON_DIR}/Modules/_sqlite/cursor.h
${CPYTHON_DIR}/Modules/_sqlite/microprotocols.c
${CPYTHON_DIR}/Modules/_sqlite/microprotocols.h
${CPYTHON_DIR}/Modules/_sqlite/module.c
${CPYTHON_DIR}/Modules/_sqlite/module.h
${CPYTHON_DIR}/Modules/_sqlite/prepare_protocol.c
${CPYTHON_DIR}/Modules/_sqlite/prepare_protocol.h
${CPYTHON_DIR}/Modules/_sqlite/row.c
${CPYTHON_DIR}/Modules/_sqlite/row.h
${CPYTHON_DIR}/Modules/_sqlite/statement.c
${CPYTHON_DIR}/Modules/_sqlite/statement.h
${CPYTHON_DIR}/Modules/_sqlite/util.c
${CPYTHON_DIR}/Modules/_sqlite/util.h
${CPYTHON_DIR}/Modules/_ssl.c
${CPYTHON_DIR}/Modules/_ssl_data.h
${CPYTHON_DIR}/Modules/_stat.c
${CPYTHON_DIR}/Modules/_struct.c
${CPYTHON_DIR}/Modules/addrinfo.h
${CPYTHON_DIR}/Modules/atexitmodule.c
${CPYTHON_DIR}/Modules/binascii.c
${CPYTHON_DIR}/Modules/clinic/_bz2module.c.h
${CPYTHON_DIR}/Modules/clinic/_cursesmodule.c.h
${CPYTHON_DIR}/Modules/clinic/_hashopenssl.c.h
${CPYTHON_DIR}/Modules/clinic/_lzmamodule.c.h
${CPYTHON_DIR}/Modules/clinic/_ssl.c.h
${CPYTHON_DIR}/Modules/clinic/arraymodule.c.h
${CPYTHON_DIR}/Modules/clinic/binascii.c.h
${CPYTHON_DIR}/Modules/clinic/cmathmodule.c.h
${CPYTHON_DIR}/Modules/clinic/fcntlmodule.c.h
${CPYTHON_DIR}/Modules/clinic/grpmodule.c.h
${CPYTHON_DIR}/Modules/clinic/md5module.c.h
${CPYTHON_DIR}/Modules/clinic/posixmodule.c.h
${CPYTHON_DIR}/Modules/clinic/pwdmodule.c.h
${CPYTHON_DIR}/Modules/clinic/pyexpat.c.h
${CPYTHON_DIR}/Modules/clinic/sha1module.c.h
${CPYTHON_DIR}/Modules/clinic/sha256module.c.h
${CPYTHON_DIR}/Modules/clinic/sha512module.c.h
${CPYTHON_DIR}/Modules/clinic/symtablemodule.c.h
${CPYTHON_DIR}/Modules/clinic/zlibmodule.c.h
${CPYTHON_DIR}/Modules/errnomodule.c
${CPYTHON_DIR}/Modules/fcntlmodule.c
${CPYTHON_DIR}/Modules/grpmodule.c
${CPYTHON_DIR}/Modules/hashlib.h
${CPYTHON_DIR}/Modules/mathmodule.c
${CPYTHON_DIR}/Modules/posixmodule.c
${CPYTHON_DIR}/Modules/posixmodule.h
${CPYTHON_DIR}/Modules/pwdmodule.c
${CPYTHON_DIR}/Modules/pyexpat.c
${CPYTHON_DIR}/Modules/readline.c
${CPYTHON_DIR}/Modules/resource.c
${CPYTHON_DIR}/Modules/selectmodule.c
${CPYTHON_DIR}/Modules/socketmodule.c
${CPYTHON_DIR}/Modules/socketmodule.h
${CPYTHON_DIR}/Modules/symtablemodule.c
${CPYTHON_DIR}/Modules/syslogmodule.c
${CPYTHON_DIR}/Modules/termios.c
${CPYTHON_DIR}/Modules/timemodule.c
${CPYTHON_DIR}/Modules/unicodename_db.h
${CPYTHON_DIR}/Modules/zlibmodule.c
${CPYTHON_DIR}/Objects/accu.c
${CPYTHON_DIR}/Objects/capsule.c
${CPYTHON_DIR}/Objects/unicodectype.c
${CPYTHON_DIR}/Objects/unicodetype_db.h
${CPYTHON_DIR}/Parser/acceler.c
${CPYTHON_DIR}/Parser/grammar1.c
${CPYTHON_DIR}/Parser/listnode.c
${CPYTHON_DIR}/Parser/myreadline.c
${CPYTHON_DIR}/Parser/node.c
${CPYTHON_DIR}/Parser/parser.c
${CPYTHON_DIR}/Parser/parser.h
${CPYTHON_DIR}/Parser/parsetok.c
${CPYTHON_DIR}/Parser/token.c
${CPYTHON_DIR}/Parser/tokenizer.c
${CPYTHON_DIR}/Parser/tokenizer.h
${CPYTHON_DIR}/Python/Python-ast.c
${CPYTHON_DIR}/Python/asdl.c
${CPYTHON_DIR}/Python/ast.c
${CPYTHON_DIR}/Python/ast_opt.c
${CPYTHON_DIR}/Python/ast_unparse.c
${CPYTHON_DIR}/Python/dtoa.c
${CPYTHON_DIR}/Python/fileutils.c
${CPYTHON_DIR}/Python/future.c
${CPYTHON_DIR}/Python/graminit.c
${CPYTHON_DIR}/Python/mystrtoul.c
${CPYTHON_DIR}/Python/parser.c
${CPYTHON_DIR}/Python/pyarena.c
${CPYTHON_DIR}/Python/pyctype.c
${CPYTHON_DIR}/Python/pystrcmp.c
${CPYTHON_DIR}/Python/pystrhex.c
${CPYTHON_DIR}/Python/pystrtod.c
${CPYTHON_DIR}/Python/pytime.c
${CPYTHON_DIR}/Python/symtable.c
${CPYTHON_DIR}/Python/wordcode_helpers.h
capi/cpython-internal/Python-ast.h
capi/cpython-internal/asdl.h
capi/cpython-internal/ast.h
capi/cpython-internal/bitset.h
capi/cpython-internal/errcode.h
capi/cpython-internal/graminit.h
capi/cpython-internal/grammar.h
capi/cpython-internal/node.h
capi/cpython-internal/osdefs.h
capi/cpython-internal/py_curses.h
capi/cpython-internal/pystrhex.h
capi/cpython-internal/symtable.h
capi/cpython-internal/token.h
capi/cpython-internal/ucnhash.h)
target_include_directories(
extension-modules
PUBLIC
capi/cpython-internal
${CPYTHON_DIR}/Modules
${CPYTHON_DIR}/Modules/_sha3
${CPYTHON_DIR}/Modules/expat
${BZIP2_INCLUDE_DIRS}
${NCURSES_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
${READLINE_INCLUDE_DIRS}
${SQLITE_INCLUDE_DIRS}
${XZ_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS})
target_compile_definitions(extension-modules PRIVATE _GNU_SOURCE)
target_compile_options(
extension-modules
PRIVATE
-Wall
-Werror
-Wextra
-Wno-missing-field-initializers
-Wno-unused-parameter
-Wno-unused-result
-Wsign-compare
-Wstrict-prototypes
-DPy_BUILD_CORE)
if (CMAKE_C_COMPILER_ID MATCHES "GNU")
target_compile_options(extension-modules PRIVATE -Wno-cast-function-type)
endif()
target_link_libraries(
extension-modules
PUBLIC
capi-headers
PRIVATE
extension
expat
util
${BZIP2_LIBRARIES}
${NCURSES_LIBRARIES}
${OPENSSL_LIBRARIES}
${READLINE_LIBRARIES}
${SQLITE_LIBRARIES}
${XZ_LIBRARIES}
${ZLIB_LIBRARIES})
add_library(
extension
OBJECT
ext/Internal/api-handle.cpp
ext/Internal/api-handle-dict.h
ext/Internal/api-handle.h
ext/Internal/bytearrayobject-utils.h
ext/Internal/bytesobject-utils.h
ext/Internal/capi-state.cpp
ext/Internal/capi-state.h
ext/Internal/capi-trampolines.cpp
ext/Internal/capi-trampolines.h
ext/Internal/capi-typeslots.cpp
ext/Internal/capi-typeslots.h
ext/Internal/extension-object.cpp
ext/Internal/function-utils.cpp
ext/Internal/function-utils.h
ext/Internal/type-utils.cpp
ext/Internal/type-utils.h
ext/Modules/_datetimemodule.cpp
ext/Modules/_parsermodule.cpp
ext/Modules/_sre/_sre.cpp
ext/Modules/gcmodule.cpp
ext/Modules/getbuildinfo.cpp
ext/Modules/main.cpp
ext/Modules/signalmodule.cpp
ext/Objects/abstract.cpp
ext/Objects/boolobject.cpp
ext/Objects/bytearrayobject.cpp
ext/Objects/bytesobject.cpp
ext/Objects/classobject.cpp
ext/Objects/codeobject.cpp
ext/Objects/complexobject.cpp
ext/Objects/descrobject.cpp
ext/Objects/dictobject.cpp
ext/Objects/exceptions.cpp
ext/Objects/fileobject.cpp
ext/Objects/floatobject.cpp
ext/Objects/frameobject.cpp
ext/Objects/funcobject.cpp
ext/Objects/genobject.cpp
ext/Objects/iterobject.cpp
ext/Objects/listobject.cpp
ext/Objects/longobject.cpp
ext/Objects/memoryobject.cpp
ext/Objects/methodobject.cpp
ext/Objects/moduleobject.cpp
ext/Objects/namespaceobject.cpp
ext/Objects/object.cpp
ext/Objects/obmalloc.cpp
ext/Objects/odictobject.cpp
ext/Objects/rangeobject.cpp
ext/Objects/setobject.cpp
ext/Objects/sliceobject.cpp
ext/Objects/structseq.cpp
ext/Objects/tupleobject.cpp
ext/Objects/typeobject.cpp
ext/Objects/unicodeobject.cpp
ext/Objects/weakrefobject.cpp
ext/Python/_warnings.cpp
ext/Python/ceval.cpp
ext/Python/codecs.cpp
ext/Python/compile.cpp
ext/Python/errors.cpp
ext/Python/getargs.cpp
ext/Python/getcompiler.cpp
ext/Python/getcopyright.cpp
ext/Python/getplatform.cpp
ext/Python/getversion.cpp
ext/Python/import.cpp
ext/Python/modsupport-internal.h
ext/Python/modsupport.cpp
ext/Python/mysnprintf.cpp
ext/Python/pathconfig.cpp
ext/Python/pyctype.cpp
ext/Python/pyhash.cpp
ext/Python/pylifecycle.cpp
ext/Python/pystate.cpp
ext/Python/pythonrun.cpp
ext/Python/random.cpp
ext/Python/sysmodule.cpp
ext/Python/thread.cpp
ext/Python/traceback.cpp
${EXTENSION_OS_SOURCES})
target_compile_options(
extension
PRIVATE
${OS_DEFINE}
${PYRO_COMPILE_OPTIONS})
target_include_directories(
extension
PRIVATE
capi/cpython-internal
$<TARGET_PROPERTY:capi-headers,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gmock,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>
ext/Internal
runtime)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(
extension
PRIVATE
systemtap)
endif()
# Include list of files in `third-party/cpython/Lib/`.
include(${CMAKE_SOURCE_DIR}/cpython_library_files.cmake)
# Include list of files in `library/`.
include(${CMAKE_SOURCE_DIR}/library_files.cmake)
list(REMOVE_ITEM LIBRARY_FILES ${FROZEN_MODULE_INPUT})
set(BINARY_LIB_DIR ${CMAKE_BINARY_DIR}/lib/${IMPLEMENTATION_DIR})
set(ALL_LIBRARY_FILES)
foreach(file ${CPYTHON_LIBRARY_FILES})
set(src_file ${CPYTHON_DIR}/Lib/${file})
set(dst_file ${BINARY_LIB_DIR}/${file})
get_filename_component(dst_dir ${dst_file} DIRECTORY)
add_custom_command(
OUTPUT ${dst_file}
VERBATIM
# Create the directory structure
COMMAND mkdir -p "${dst_dir}"
# Copy from the source files into its destination location
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${src_file}" "${dst_file}"
DEPENDS ${src_file}
COMMENT "Copying to ${dst_file}")
list(APPEND ALL_LIBRARY_FILES ${dst_file})
endforeach()
foreach(file ${LIBRARY_FILES})
set(src_file ${CMAKE_SOURCE_DIR}/library/${file})
set(dst_file ${BINARY_LIB_DIR}/${file})
get_filename_component(dst_dir ${dst_file} DIRECTORY)
add_custom_command(
OUTPUT ${dst_file}