forked from Ultimaker/cura-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1549 lines (1413 loc) · 64.6 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
project(cura-build)
cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(ExternalProject)
include(GNUInstallDirs)
# Define Options
option(BUILD_PYTHON "Include Python" ON)
option(BUILD_CYTHON "Include Cython" ON)
option(BUILD_QT "Include Qt" ON)
option(BUILD_SIP "Include SIP" ON)
option(BUILD_PYQT "Include PyQt" ON)
option(BUILD_OPENBLAS "Include OpenBLAS" ON)
option(BUILD_NUMPY "Include Numpy" ON)
option(BUILD_SCIPY "Include Scipy" ON)
option(BUILD_SCIPY_LITE "Include Scipy Lite" OFF)
option(BUILD_PYSERIAL "Include PySerial" ON)
option(BUILD_NUMPY_STL "Include Numpy-STL" ON)
# option(BUILD_PYTHON_UTILS "Include Python-Utils" ON)
option(BUILD_ZEROCONF "Include python-zeroconf" ON)
option(BUILD_TYPING "Include python-typing" ON)
option(BUILD_SAVITAR "Include Savitar Library" ON)
option(BUILD_APPDIRS "Include AppDirs Library" ON)
option(BUILD_NETIFACES "Include Netifaces Library" ON)
option(BUILD_PYTHONSIX "Include Python Six Library" ON)
option(BUILD_PYTHON_SETUPTOOLS "Include Python SetupTools Library" ON)
option(BUILD_PYTHON_PACKAGING "Include Python Packaging Library" ON)
option(BUILD_PYPARSING "Include Python Parsing Library" ON)
option(BUILD_PYTHON_NOSE "Include Python NOSE Library" ON)
option(BUILD_MARLIN_FIRMWARES "Build Firmware for 3Dprinters as a part of Cura build" OFF)
option(SIGN_APP_OSX "Sign the app on OSX build" OFF)
macro(string_option name info default_value)
if (${name})
set(${name} ${${name}} CACHE STRING "${info}")
else()
set(${name} ${default_value} CACHE STRING "${info}")
endif()
endmacro()
string_option(MINIMUM_PYTHON_VERSION "Minimum Python Version" "3.5.0")
string_option(ARCUS_URL "Arcus Git Url" "https://code.alephobjects.com/source/arcus.git")
string_option(SAVITAR_URL "Savitar Git Url" "https://code.alephobjects.com/source/savitar.git")
string_option(CURA_URL "Cura Git Url" "https://code.alephobjects.com/source/cura-lulzbot.git")
string_option(CURAENGINE_URL "CuraEngine Git Url" "https://code.alephobjects.com/source/curaengine-lulzbot.git")
string_option(URANIUM_URL "Uranium Git Url" "https://code.alephobjects.com/diffusion/U/uranium.git")
string_option(CURA_POSTPROCESSING_URL "PostProcessing Url" "https://code.alephobjects.com/source/cura-lulzbot-postprocessing.git")
string_option(CURA_BINARY_URL "Binary Data Url" "https://code.alephobjects.com/diffusion/CBD/cura-binary-data.git")
if(WIN32)
option(BUILD_64BIT "Create a 64-bit build" OFF)
endif()
# Create variables to simplify OS management
set(BUILD_OS_OSX OFF)
set(BUILD_OS_LINUX OFF)
set(BUILD_OS_WINDOWS OFF)
set(BUILD_OS_WIN32 OFF)
set(BUILD_OS_WIN64 OFF)
if(CYGWIN)
message(FATAL_ERROR "Cygwin is not supported")
endif()
if(APPLE)
set(BUILD_OS_OSX ON)
elseif(WIN32)
set(BUILD_OS_WINDOWS ON)
# Possibly all platforms could use SIP 4.19 but Windows is the only one that needs it right now in order to use
# the pip versions of PyQt5, which only support SIP 4.19. (Versions of SIP cannot be mixed in the same app.)
if(BUILD_64BIT)
set(BUILD_OS_WIN64 ON)
else()
set(BUILD_OS_WIN32 ON)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(BUILD_OS_LINUX ON)
else()
message(FATAL_ERROR "Unsupported Operating System: ${CMAKE_SYSTEM_NAME}")
endif()
# Explicitly disable unsupported options
if(BUILD_OS_WINDOWS)
if(BUILD_OS_WIN64)
# Sip is required to build the Arcus python bindings, which works fine on Win32
# but fails on Win64. So we need an externally built SIP and Arcus bindings on Win64.
set(BUILD_SIP OFF)
else()
set(BUILD_PYTHON OFF)
set(BUILD_QT OFF)
set(BUILD_PYQT OFF)
set(BUILD_OPENBLAS OFF)
set(BUILD_NUMPY OFF)
set(BUILD_SCIPY OFF)
set(BUILD_CYTHON OFF)
set(PYTHONPATH "${CMAKE_CURRENT_BINARY_DIR}/inst/lib/python3.5/site-packages")
endif()
elseif(BUILD_OS_LINUX)
set(BUILD_TYPING OFF)
elseif(BUILD_OS_OSX)
set(BUILD_TYPING OFF)
endif()
set(TAG_OR_BRANCH "master" CACHE STRING "The name of the tag or branch to build")
set(SAVITAR_TAG_OR_BRANCH ${TAG_OR_BRANCH} CACHE STRING "The name of the Savitar tag or branch to build")
set(CURA_TAG_OR_BRANCH ${TAG_OR_BRANCH} CACHE STRING "The name of the Cura tag or branch to build")
set(URANIUM_TAG_OR_BRANCH ${TAG_OR_BRANCH} CACHE STRING "The name of the Uranium tag or branch to build")
set(CURA_ENGINE_TAG_OR_BRANCH ${TAG_OR_BRANCH} CACHE STRING "The name of the CuraEngine tag or branch to build")
set(CURA_BINARY_TAG_OR_BRANCH ${TAG_OR_BRANCH} CACHE STRING "The name of the Cura Binary Data tag or branch to build")
set(CURA_POSTPROCESSING_TAG_OR_BRANCH ${TAG_OR_BRANCH} CACHE STRING "The name of the Cura Post Processing Plugin tag or branch to build")
set(ARCUS_TAG_OR_BRANCH ${TAG_OR_BRANCH} CACHE STRING "The name of the Arcus tag or branch to build")
set(EXTRA_REPOSITORIES "" CACHE STRING "Extra repositories to install. Expected to have a CMake based build system.")
set(EXTERNALPROJECT_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/inst)
set(APPLE_ID_CERT_NAME "" CACHE STRING "Apple Identity name used for signing")
if(BUILD_OS_OSX)
if(NOT "${APPLE_ID_CERT_NAME}" STREQUAL "")
set(SIGN_APP_OSX ON)
endif()
endif()
# Create the version-related variables
# These can optionally be overridden from the build enviroment.
unset(CURA_MAJOR_VERSION CACHE)
if(DEFINED ENV{CURA_MAJOR_VERSION})
set(CURA_MAJOR_VERSION $ENV{CURA_MAJOR_VERSION} CACHE STRING "Cura Major Version" FORCE)
else()
set(CURA_MAJOR_VERSION "3" CACHE STRING "Cura Major Version")
endif()
unset(CURA_MINOR_VERSION CACHE)
if(DEFINED ENV{CURA_MINOR_VERSION})
set(CURA_MINOR_VERSION $ENV{CURA_MINOR_VERSION} CACHE STRING "Cura Minor Version" FORCE)
else()
set(CURA_MINOR_VERSION "2" CACHE STRING "Cura Minor Version")
endif()
unset(CURA_PATCH_VERSION CACHE)
if(DEFINED ENV{CURA_PATCH_VERSION})
set(CURA_PATCH_VERSION $ENV{CURA_PATCH_VERSION} CACHE STRING "Cura Patch Version" FORCE)
else()
set(CURA_PATCH_VERSION "17" CACHE STRING "Cura Patch Version")
endif()
unset(CURA_EXTRA_VERSION CACHE)
if(DEFINED ENV{CURA_EXTRA_VERSION})
set(CURA_EXTRA_VERSION $ENV{CURA_EXTRA_VERSION} CACHE STRING "Cura Extra Version Information" FORCE)
else()
set(CURA_EXTRA_VERSION "" CACHE STRING "Cura Extra Version Information")
endif()
set(CURA_VERSION "${CURA_MAJOR_VERSION}.${CURA_MINOR_VERSION}.${CURA_PATCH_VERSION}")
if(NOT "${CURA_EXTRA_VERSION}" STREQUAL "")
set(CURA_VERSION "${CURA_VERSION}-${CURA_EXTRA_VERSION}")
endif()
if(BUILD_OS_WINDOWS)
set(MAKE_EXECUTABLE mingw32-make)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
# Some of the cmake files expect this to be lower-case for some reason ???
string( TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR )
message(STATUS "---> System Processor: ${CMAKE_SYSTEM_PROCESSOR}")
elseif(BUILD_OS_LINUX OR BUILD_OS_OSX)
set(MAKE_EXECUTABLE make)
endif()
message(STATUS "---> Make executable: ${MAKE_EXECUTABLE}")
message(STATUS "Building Cura ${CURA_VERSION}")
if(BUILD_PYTHON)
if(BUILD_OS_OSX)
set(PYTHON_CONFIGURE_CFLAGS "CFLAGS=-I/usr/local/opt/openssl/include")
set(PYTHON_CONFIGURE_LDFLAGS "LDFLAGS=-L/usr/local/opt/openssl/lib")
else()
set(PYTHON_CONFIGURE_CFLAGS)
set(PYTHON_CONFIGURE_LDFLAGS)
endif()
set(PYTHON_VERSION_MAJOR 3)
set(PYTHON_VERSION_MINOR 5)
# For now let's leave only WINDOWS with 3.5.2
if(BUILD_OS_WINDOWS)
set(PYTHON_VERSION_PATCH 2)
else()
set(PYTHON_VERSION_PATCH 3)
endif()
set(PYTHON_VERSION_STRING ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})
set(PYTHON_EXECUTABLE ${EXTERNALPROJECT_INSTALL_PREFIX}/bin/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
set(PYTHONINTERP_FOUND True)
if(BUILD_OS_WINDOWS)
set(PYTHON_LIBRARY ${EXTERNALPROJECT_INSTALL_PREFIX}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m.so)
else()
set(PYTHON_LIBRARY ${EXTERNALPROJECT_INSTALL_PREFIX}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.so)
endif()
set(PYTHON_INCLUDE_DIR ${EXTERNALPROJECT_INSTALL_PREFIX}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
set(EXTRA_PYTHON_DEFINES
-DBUILD_PYTHON=${BUILD_PYTHON}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHON_VERSION_MAJOR=${PYTHON_VERSION_MAJOR}
-DPYTHON_VERSION_MINOR=${PYTHON_VERSION_MINOR}
-DPYTHON_LIBRARY=${PYTHON_LIBRARY}
-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}
-DPython_ADDITIONAL_VERSIONS=${Python_ADDITIONAL_VERSIONS}
)
if (BUILD_OS_WINDOWS)
string(REPLACE "/" "\\" CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}")
set (pythonpatch_source_path ${CMAKE_BINARY_DIR}\\PythonPatch-prefix\\src\\PythonPatch\\bin)
set (pythonpatch_destination_path ${EXTERNALPROJECT_INSTALL_PREFIX}\\bin)
set(pythonpatch_build_command ${pythonpatch_destination_path}\\patch.exe -t -p1
-i ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python\\cmake\\patches-win32\\01-PY3-dynload_win.patch
-d ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python-${PYTHON_VERSION_STRING} )
list(APPEND pythonpatch_build_command COMMAND ${pythonpatch_destination_path}\\patch.exe -t -p1
-i ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python\\cmake\\patches-win32\\02-PY3-posixmodule.patch
-d ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python-${PYTHON_VERSION_STRING} )
list(APPEND pythonpatch_build_command COMMAND ${pythonpatch_destination_path}\\patch.exe -t -p1
-i ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python\\cmake\\patches-win32\\03-PY3-getpathp.patch
-d ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python-${PYTHON_VERSION_STRING} )
list(APPEND pythonpatch_build_command COMMAND ${pythonpatch_destination_path}\\patch.exe -t -p1
-i ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python\\cmake\\patches-win32\\04-PY3-pytime.patch
-d ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python-${PYTHON_VERSION_STRING} )
list(APPEND pythonpatch_build_command COMMAND ${pythonpatch_destination_path}\\patch.exe -t -p1
-i ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python\\cmake\\patches-win32\\05-PY3-libffi-latest.patch
-d ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\Python-${PYTHON_VERSION_STRING} )
set (pythonpatch_configure_command ${CMAKE_COMMAND} -E copy
${pythonpatch_source_path}\\patch.exe
${pythonpatch_destination_path}\\patch.exe )
ExternalProject_Add(PythonPatch
URL https://downloads.sourceforge.net/project/gnuwin32/patch/2.5.9-7/patch-2.5.9-7-bin.zip
CONFIGURE_COMMAND ${pythonpatch_configure_command}
BUILD_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
list(APPEND pythonpatch_build_command COMMAND)
else()
set (pythonpatch_build_command)
add_custom_target(PythonPatch)
endif()
# For now let's switch WIN to CMAKE Python only
if(BUILD_OS_WINDOWS)
# We'll need to find OpenSSL
find_package(OpenSSL)
# For windows we'll try to build using CMake for python
set(python_configure_command ${pythonpatch_build_command})
list(APPEND python_configure_command ${CMAKE_COMMAND} <SOURCE_DIR> -DCMAKE_INSTALL_PREFIX=${EXTERNALPROJECT_INSTALL_PREFIX} )
list(APPEND python_configure_command -DBUILD_LIBPYTHON_SHARED=ON)
list(APPEND python_configure_command -G ${CMAKE_GENERATOR})
if (BUILD_OS_WINDOWS)
list(APPEND python_configure_command -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++)
# Don't build extensions as built-in
# list(APPEND python_configure_command -DBUILD_EXTENSIONS_AS_BUILTIN=ON)
list(APPEND python_configure_command -DENABLE_XXLIMITED=OFF )
list(APPEND python_configure_command -DENABLE_CTYPES=OFF )
list(APPEND python_configure_command -DENABLE_CTYPES_TEST=OFF )
else()
endif()
ExternalProject_Add(Python
DEPENDS PythonPatch
GIT_REPOSITORY https://code.alephobjects.com/source/python-cmake-buildsystem.git
GIT_TAG origin/master
CONFIGURE_COMMAND ${python_configure_command}
BUILD_COMMAND ${MAKE_EXECUTABLE}
INSTALL_COMMAND ${MAKE_EXECUTABLE} install
)
# Download python itself and place it into the right spot
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/inst/${PYTHON_SITE_PACKAGES_DIR})
set(_download_link "http://www.python.org/ftp/python/${PYTHON_VERSION_STRING}/Python-${PYTHON_VERSION_STRING}.tgz")
get_filename_component(_filename ${_download_link} NAME)
if (BUILD_OS_WINDOWS)
set(_archive_filepath ${CMAKE_BINARY_DIR}\\Python-prefix\\src\\${_filename})
else()
set(_archive_filepath ${CMAKE_BINARY_DIR}/Python-prefix/src/${_filename})
endif()
if(EXISTS "${_archive_filepath}")
message(STATUS "${_archive_filepath} already downloaded")
else()
message(STATUS "Downloading ${_archive_filepath}")
file(
DOWNLOAD ${_download_link} ${_archive_filepath}
# EXPECTED_MD5 ${_download_${PY_VERSION}_md5}
SHOW_PROGRESS
)
endif()
if (BUILD_OS_WINDOWS)
message(STATUS "Extracting ${_archive_filepath} to ${CMAKE_BINARY_DIR}\\Python-prefix\\src" )
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${_archive_filepath}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}\\Python-prefix\\src
RESULT_VARIABLE rv)
else()
message(STATUS "Extracting ${_archive_filepath} to ${CMAKE_BINARY_DIR}/Python-prefix/src" )
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${_archive_filepath}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Python-prefix/src
RESULT_VARIABLE rv)
endif()
if(NOT rv EQUAL 0)
message(FATAL_ERROR "error: extraction of '${_filename}' failed")
endif()
else() # elseif(BUILD_OS_OSX OR BUILD_OS_LINUX)
set( python_configure_command ./configure )
if (BUILD_OS_OSX)
list(APPEND python_configure_command --enable-universalsdk)
endif()
list(APPEND python_configure_command --prefix=${EXTERNALPROJECT_INSTALL_PREFIX})
list(APPEND python_configure_command --exec-prefix=${EXTERNALPROJECT_INSTALL_PREFIX})
list(APPEND python_configure_command --bindir=${EXTERNALPROJECT_INSTALL_PREFIX}/bin)
list(APPEND python_configure_command --datarootdir=${EXTERNALPROJECT_INSTALL_PREFIX}/share)
list(APPEND python_configure_command --sbindir=${EXTERNALPROJECT_INSTALL_PREFIX}/bin)
list(APPEND python_configure_command --libdir=${EXTERNALPROJECT_INSTALL_PREFIX}/lib)
list(APPEND python_configure_command --libexecdir=${EXTERNALPROJECT_INSTALL_PREFIX}/lib)
list(APPEND python_configure_command --includedir=${EXTERNALPROJECT_INSTALL_PREFIX}/include)
list(APPEND python_configure_command --oldincludedir=${EXTERNALPROJECT_INSTALL_PREFIX}/include)
list(APPEND python_configure_command
--enable-shared
--with-threads
--without-pymalloc
${PYTHON_CONFIGURE_CFLAGS}
${PYTHON_CONFIGURE_LDFLAGS}
)
if (BUILD_OS_OSX)
set( python_configure_patch_command COMMAND sed -ie
"s/#define HAVE_GETENTROPY 1/\\/* #undef HAVE_GETENTROPY *\\//g" pyconfig.h)
list(APPEND python_configure_patch_command COMMAND
echo "fixing pyconfig.h with sed -ie 's/#define HAVE_GETENTROPY 1/\\/* #undef HAVE_GETENTROPY *\\//g'")
list(APPEND python_configure_patch_command COMMAND sed -ie
"s/#define HAVE_CLOCK_GETTIME 1/\\/* #undef HAVE_CLOCK_GETTIME *\\//g" pyconfig.h)
list(APPEND python_configure_patch_command COMMAND
echo "fixing pyconfig.h with sed -ie 's/#define HAVE_CLOCK_GETTIME 1/\\/* #undef HAVE_CLOCK_GETTIME *\\//g'")
else()
set( python_configure_patch_command)
endif()
ExternalProject_Add(Python
URL https://www.python.org/ftp/python/${PYTHON_VERSION_STRING}/Python-${PYTHON_VERSION_STRING}.tgz
# PATCH_COMMAND ${python_patch_command}
CONFIGURE_COMMAND ${python_configure_command} ${python_configure_patch_command}
BUILD_IN_SOURCE 1
)
endif()
# We want to be able to link to python Libs while running CMAKE
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} " )
else()
find_package(PythonInterp ${MINIMUM_PYTHON_VERSION} REQUIRED)
find_package(PythonLibs REQUIRED)
add_custom_target(Python) # In order to satisfy dependencies
set(EXTRA_PYTHON_DEFINES)
endif()
message(STATUS "---> Python executable: ${PYTHON_EXECUTABLE}")
message(STATUS "---> Python libraries: ${PYTHON_LIBRARIES}")
message(STATUS "---> Python includes: ${PYTHON_INCLUDE_DIRS}")
message(STATUS "---> Python libraries version: ${PYTHONLIBS_VERSION_STRING}")
message(STATUS "---> Python extra defines: ${EXTRA_PYTHON_DEFINES}")
if(BUILD_OS_WINDOWS)
set(PYTHON_DIRECTORY "python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
set(PYTHON_SITE_PACKAGES_DIR lib/${PYTHON_DIRECTORY}/site-packages)
elseif(BUILD_OS_LINUX OR BUILD_OS_OSX)
# Set the packages dir to a standard 3.X dir if building Python ourselves
if (BUILD_PYTHON)
set(PYTHON_SITE_PACKAGES_DIR lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
else()
set(PYTHON_SITE_PACKAGES_DIR lib/python${PYTHON_VERSION_MAJOR}/dist-packages)
endif()
elseif(BUILD_OS_OSX)
if (BUILD_PYTHON)
set(PYTHON_SITE_PACKAGES_DIR lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
else()
set(PYTHON_SITE_PACKAGES_DIR lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages)
endif()
endif()
message(STATUS "---> Python site-packages: ${PYTHON_SITE_PACKAGES_DIR}")
if(WIN32)
# To deal with stupid setuptools not creating install directories
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/inst/${PYTHON_SITE_PACKAGES_DIR})
endif()
if(BUILD_QT)
set(qt_url http://download.lulzbot.com/Software/Cura2/build-resources/qt-everywhere-opensource-src-5.9.1.tar.gz)
set(qt_md5 e2a13e5a80372e814da08e8b15998a79)
if(BUILD_OS_WINDOWS)
set(qt_options configure.bat )
else()
set(qt_options ./configure)
endif()
list(APPEND qt_options -release)
# If one wants to build debuggable library:
# list(APPEND qt_options -force-debug-info)
list(APPEND qt_options -prefix ${EXTERNALPROJECT_INSTALL_PREFIX})
list(APPEND qt_options -archdatadir ${EXTERNALPROJECT_INSTALL_PREFIX}/lib)
list(APPEND qt_options -datadir ${EXTERNALPROJECT_INSTALL_PREFIX}/share)
list(APPEND qt_options -opensource -confirm-license )
list(APPEND qt_options -nomake examples -nomake tests -nomake tools )
list(APPEND qt_options -no-cups -no-sql-db2 -no-sql-ibase -no-sql-mysql)
list(APPEND qt_options -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds)
list(APPEND qt_options -no-icu)
# Let's try to use system-provided harfbuzz
if(BUILD_OS_LINUX)
# list(APPEND qt_options -system-harfbuzz)
# list(APPEND qt_options -qt-harfbuzz)
endif()
list(APPEND qt_options -no-harfbuzz)
# Bundle PNG mainly because stretch is using libpng16 and jessie uses libpng12
list(APPEND qt_options -qt-libpng)
# It seems like we'll need SSL for Cura plugins (Octoprint is using PyQt5.QtNetwork for example)
if(BUILD_OS_OSX OR BUILD_OS_WINDOWS)
list(APPEND qt_options -no-openssl )
endif()
list(APPEND qt_options -qt-pcre)
if(BUILD_OS_LINUX OR BUILD_OS_OSX)
list(APPEND qt_options -no-eglfs)
endif()
list(APPEND qt_options -skip qtactiveqt)
# list(APPEND qt_options -skip qtbase)
list(APPEND qt_options -skip qtcanvas3d)
list(APPEND qt_options -skip qtcharts)
list(APPEND qt_options -skip qtconnectivity)
list(APPEND qt_options -skip qtdatavis3d)
# list(APPEND qt_options -skip qtdeclarative)
list(APPEND qt_options -skip qtdoc)
list(APPEND qt_options -skip qtenginio)
list(APPEND qt_options -skip qtgamepad)
# qtgraphicaleffects is needed for qtquickcontrols2
# list(APPEND qt_options -skip qtgraphicaleffects)
# list(APPEND qt_options -skip qtimageformats)
list(APPEND qt_options -skip qtlocation)
list(APPEND qt_options -skip qtmultimedia)
# list(APPEND qt_options -skip qtnetworkauth)
list(APPEND qt_options -skip qtpurchasing)
# list(APPEND qt_options -skip qtquickcontrols)
# list(APPEND qt_options -skip qtquickcontrols2)
list(APPEND qt_options -skip qtremoteobjects)
list(APPEND qt_options -skip qtscript)
list(APPEND qt_options -skip qtsensors)
list(APPEND qt_options -skip qtserialbus)
list(APPEND qt_options -skip qtserialport)
list(APPEND qt_options -skip qtspeech)
# list(APPEND qt_options -skip qtsvg)
list(APPEND qt_options -skip qttools)
# list(APPEND qt_options -skip qttranslations)
list(APPEND qt_options -skip qtvirtualkeyboard)
list(APPEND qt_options -skip qtwayland)
list(APPEND qt_options -skip qtwebchannel)
list(APPEND qt_options -skip qtwebengine)
list(APPEND qt_options -skip qtwebsockets)
list(APPEND qt_options -skip qtwebview)
list(APPEND qt_options -skip qtxmlpatterns)
list(APPEND qt_options -skip qt3d)
# Following are not disabled:
# coin gnuwin32
if(BUILD_OS_OSX)
list(APPEND qt_options -no-framework)
list(APPEND qt_options -skip qtwinextras -skip qtx11extras -skip qtandroidextras)
elseif(BUILD_OS_WINDOWS)
list(APPEND qt_options -opengl desktop)
list(APPEND qt_options -skip qtx11extras -skip qtmacextras -skip qtandroidextras)
elseif(BUILD_OS_LINUX)
list(APPEND qt_options -no-rpath -qt-xcb)
list(APPEND qt_options -skip qtmacextras -skip qtwinextras -skip qtandroidextras)
endif()
if(BUILD_OS_WINDOWS)
string(REPLACE "/" "\\" qt_options "${qt_options}")
endif()
message(STATUS "---> Qt config: ${qt_options}")
ExternalProject_Add(Qt
URL ${qt_url}
URL_MD5 ${qt_md5}
CONFIGURE_COMMAND ${qt_options}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System Qt will be used")
add_custom_target(Qt)
endif()
if(BUILD_SIP)
set(sip_command ${PYTHON_EXECUTABLE} configure.py )
list(APPEND sip_command --bindir=${EXTERNALPROJECT_INSTALL_PREFIX}/bin)
list(APPEND sip_command --destdir=${EXTERNALPROJECT_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES_DIR} )
list(APPEND sip_command --incdir=${EXTERNALPROJECT_INSTALL_PREFIX}/include )
list(APPEND sip_command --sipdir=${EXTERNALPROJECT_INSTALL_PREFIX}/share/sip )
list(APPEND sip_command --stubsdir=${EXTERNALPROJECT_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES_DIR} )
if(BUILD_OS_WINDOWS)
list(APPEND sip_command --platform win32-g++)
# Apparently Sip doesn't like hypot
# list(APPEND sip_command CFLAGS+="-DPy_TRACE_DEFS")
# list(APPEND sip_command CXXFLAGS+="-DPy_TRACE_DEFS")
endif()
if(BUILD_OS_WINDOWS)
set(SIP_VERSION 0x041301)
set(SIP_VERSION_STR 4.19.3 )
else()
set(SIP_VERSION 0x041301)
set(SIP_VERSION_STR 4.19.3 )
endif()
# set(SIP_VERSION_NUM )
set(SIP_BINARY_PATH ${EXTERNALPROJECT_INSTALL_PREFIX}/bin/sip )
set(SIP_DEFAULT_SIP_DIR ${EXTERNALPROJECT_INSTALL_PREFIX}/share/sip )
set(SIP_INCLUDE_DIR ${EXTERNALPROJECT_INSTALL_PREFIX}/include )
set(SIP_FOUND True)
if(BUILD_OS_WINDOWS)
string(REPLACE "/" "\\" sip_command "${sip_command}")
endif()
message(STATUS "---> SIP command: ${sip_command}")
ExternalProject_Add(Sip
DEPENDS Python
URL http://downloads.sourceforge.net/project/pyqt/sip/sip-${SIP_VERSION_STR}/sip-${SIP_VERSION_STR}.zip
CONFIGURE_COMMAND ${sip_command}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System SIP will be used")
add_custom_target(Sip)
endif()
#--------------- Building some python modules before PyQt/NumPy/SciPy ------------#
# Platform Standard installation location Default value
# Unix (pure) prefix/lib/pythonX.Y/site-packages /usr/local/lib/pythonX.Y/site-packages
# Unix (non-pure) exec-prefix/lib/pythonX.Y/site-packages /usr/local/lib/pythonX.Y/site-packages
# Windows prefix\Lib\site-packages C:\PythonXY\Lib\site-packages
if(BUILD_OS_WINDOWS)
# Because setuptools is stupid and will interpret "C:/..." as a relative path
string(REPLACE "/" "\\" native_prefix "${EXTERNALPROJECT_INSTALL_PREFIX}")
set(python_install
--install-lib=${native_prefix}\\lib\\${PYTHON_DIRECTORY}\\site-packages
--install-data=${native_prefix}\\share
--install-scripts=${native_prefix}\\bin
# --single-version-externally-managed
--record=${native_prefix}\\lib\\${PYTHON_DIRECTORY}\\record.txt
)
elseif(BUILD_OS_LINUX OR BUILD_OS_OSX)
set(python_install
--install-lib=${EXTERNALPROJECT_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES_DIR}
--install-data=${EXTERNALPROJECT_INSTALL_PREFIX}/share
--install-scripts=${EXTERNALPROJECT_INSTALL_PREFIX}/bin
# --single-version-externally-managed
--record=${EXTERNALPROJECT_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES_DIR}/record.txt
)
endif()
# include_dirs
message(STATUS "---> Python Install: ${python_install}")
# We should not need it, leaving here just in case
# Apparently Six is required for OctoPrint plugin :(
if(BUILD_PYTHONSIX)
set(build_python_six ${PYTHON_EXECUTABLE} setup.py sdist)
# --single-version-externally-managed
# set(install_python_six ${PYTHON_EXECUTABLE} setup.py setopt --command=easy_install --option=zip-ok --set-value=False)
list(APPEND install_python_six COMMAND ${PYTHON_EXECUTABLE} setup.py install --verbose ${python_install} --single-version-externally-managed)
message(STATUS "---> PythonSix Build: ${build_python_six}")
message(STATUS "---> PythonSix Install: ${install_python_six}")
ExternalProject_Add(PythonSix
DEPENDS Python
URL https://pypi.python.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_python_six}
INSTALL_COMMAND ${install_python_six}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System PythonSix will be used")
add_custom_target(PythonSix
DEPENDS Python
)
endif()
if(BUILD_PYPARSING)
set(build_pyparsing ${PYTHON_EXECUTABLE} setup.py build)
# --single-version-externally-managed
set(install_pyparsing ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose )
message(STATUS "---> PyParsing Build: ${build_pyparsing}")
message(STATUS "---> PyParsing Install: ${install_pyparsing}")
ExternalProject_Add(PyParsing
DEPENDS Python
URL https://downloads.sourceforge.net/project/pyparsing/pyparsing/pyparsing-2.2.0/pyparsing-2.2.0.tar.gz
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_pyparsing}
INSTALL_COMMAND ${install_pyparsing}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System PyParsing will be used")
add_custom_target(PyParsing
DEPENDS Python
)
endif()
if(BUILD_PYTHON_PACKAGING)
set(build_python_packaging ${PYTHON_EXECUTABLE} setup.py build)
# --single-version-externally-managed
set(install_python_packaging ${PYTHON_EXECUTABLE} setup.py setopt --command=easy_install --option=zip-ok --set-value=False)
list(APPEND install_python_packaging COMMAND ${PYTHON_EXECUTABLE} setup.py install --verbose ${python_install})
if(BUILD_OS_WINDOWS)
string(REPLACE "/" "\\" install_python_packaging "${install_python_packaging}")
endif()
message(STATUS "---> PythonPackaging Build: ${build_python_packaging}")
message(STATUS "---> PythonPackaging Install: ${install_python_packaging}")
ExternalProject_Add(PythonPackaging
DEPENDS Python PythonSix PyParsing
GIT_REPOSITORY git://github.com/pypa/packaging.git
GIT_TAG 79c84ead5177939a9ac93b3532b4a7c15babaffd
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_python_packaging}
INSTALL_COMMAND ${install_python_packaging}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System PythonPackaging will be used")
add_custom_target(PythonPackaging
DEPENDS Python PythonSix PyParsing
)
endif()
if(BUILD_APPDIRS)
set(build_python_appdirs ${PYTHON_EXECUTABLE} setup.py build)
# --single-version-externally-managed
set(install_python_appdirs ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose)
message(STATUS "---> PythonAppDirs Build: ${build_python_appdirs}")
message(STATUS "---> PythonAppDirs Install: ${install_python_appdirs}")
ExternalProject_Add(PythonAppDirs
DEPENDS Python
GIT_REPOSITORY git://github.com/ActiveState/appdirs.git
GIT_TAG 859eac40ac7d0b5f3260068c4810d027012f0488
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_python_appdirs}
INSTALL_COMMAND ${install_python_appdirs}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System AppDirs will be used")
add_custom_target(PythonAppDirs
DEPENDS Python
)
endif()
if(BUILD_PYTHON_SETUPTOOLS)
set(build_python_setuptools ${PYTHON_EXECUTABLE} bootstrap.py COMMAND ${PYTHON_EXECUTABLE} setup.py build)
set(install_python_setuptools ${PYTHON_EXECUTABLE} setup.py install --verbose ${python_install} --single-version-externally-managed)
message(STATUS "---> PythonSetupTools Build: ${build_python_setuptools}")
message(STATUS "---> PythonSetupTools Install: ${install_python_setuptools}")
ExternalProject_Add(PythonSetupTools
DEPENDS Python PythonPackaging PythonSix PyParsing PythonAppDirs
GIT_REPOSITORY git://github.com/pypa/setuptools.git
GIT_TAG d8e1ed570126dfc99ed7f9126df3bfc890e7005d
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_python_setuptools}
INSTALL_COMMAND ${install_python_setuptools}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System PythonSetupTools will be used")
add_custom_target(PythonSetupTools
DEPENDS Python PythonPackaging PythonSix PyParsing PythonAppDirs
)
endif()
# if(BUILD_PYTHON_UTILS)
# set(build_python_utils ${PYTHON_EXECUTABLE} setup.py build)
# set(install_python_utils ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose --single-version-externally-managed)
# if(BUILD_OS_WINDOWS)
# string(REPLACE "/" "\\" install_python_utils "${install_python_utils}")
# endif()
# message(STATUS "---> PythonUtils Build: ${build_python_utils}")
# message(STATUS "---> PythonUtils Install: ${install_python_utils}")
# ExternalProject_Add(PythonUtils
# DEPENDS Python PythonSetupTools
# GIT_REPOSITORY https://github.com/WoLpH/python-utils.git
# GIT_TAG origin/master
# CONFIGURE_COMMAND ""
# BUILD_COMMAND ${build_python_utils}
# INSTALL_COMMAND ${install_python_utils}
# BUILD_IN_SOURCE 1
# )
#else()
# message(STATUS "---> System PythonUtils will be used")
# add_custom_target(PythonUtils
# DEPENDS Python PythonSetupTools
# )
#endif()
if(BUILD_NETIFACES)
set(build_python_netifaces ${PYTHON_EXECUTABLE} setup.py build)
set(install_python_netifaces ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose --single-version-externally-managed)
message(STATUS "---> PythonNetifaces Build: ${build_python_netifaces}")
message(STATUS "---> PythonNetifaces Install: ${install_python_netifaces}")
ExternalProject_Add(PythonNetifaces
DEPENDS Python PythonAppDirs
URL https://pypi.python.org/packages/18/fa/dd13d4910aea339c0bb87d2b3838d8fd923c11869b1f6e741dbd0ff3bc00/netifaces-0.10.4.tar.gz
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_python_netifaces}
INSTALL_COMMAND ${install_python_netifaces}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System NetIfaces will be used")
add_custom_target(PythonNetifaces
DEPENDS Python PythonAppDirs
)
endif()
if(BUILD_ZEROCONF)
set(build_python_zeroconf ${PYTHON_EXECUTABLE} setup.py build)
set(install_python_zeroconf ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose --single-version-externally-managed)
message(STATUS "---> PythonZeroconf Build: ${build_python_zeroconf}")
message(STATUS "---> PythonZeroconf Install: ${install_python_zeroconf}")
ExternalProject_Add(PythonZeroconf
DEPENDS PythonNetifaces
GIT_REPOSITORY https://github.com/jstasiak/python-zeroconf
GIT_TAG 0.17.6
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_python_zeroconf}
INSTALL_COMMAND ${install_python_zeroconf}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System ZeroConf will be used")
add_custom_target(PythonZeroconf
DEPENDS PythonNetifaces
)
endif()
if ( BUILD_CYTHON )
# Currently Cython can be build only with Python... but we will see
set(build_cython ${PYTHON_EXECUTABLE} setup.py build)
if(BUILD_OS_WINDOWS)
list(APPEND build_cython --compiler=mingw32)
endif()
set(install_cython ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose --single-version-externally-managed)
message(STATUS "---> Cython Build: ${build_cython}")
message(STATUS "---> Cython Install: ${install_cython}")
ExternalProject_Add(Cython
DEPENDS Python Sip PythonAppDirs PythonSetupTools
URL https://pypi.python.org/packages/b7/67/7e2a817f9e9c773ee3995c1e15204f5d01c8da71882016cac10342ef031b/Cython-0.25.2.tar.gz
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_cython}
INSTALL_COMMAND ${install_cython}
BUILD_IN_SOURCE 1
)
else()
if(BUILD_OS_WIN32)
add_custom_target(Cython
COMMAND ${PYTHON_EXECUTABLE} -m pip install --target=${PYTHONPATH} Cython
COMMENT "Installing Cython"
)
else()
message(STATUS "---> System Cython will be used")
add_custom_target(Cython
DEPENDS Python Sip PythonAppDirs PythonSetupTools
)
endif()
endif()
if(BUILD_PYQT)
set(pyqt_command ${PYTHON_EXECUTABLE} configure.py)
list(APPEND pyqt_command --confirm-license)
list(APPEND pyqt_command --destdir=${EXTERNALPROJECT_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES_DIR})
list(APPEND pyqt_command --bindir=${EXTERNALPROJECT_INSTALL_PREFIX}/bin)
list(APPEND pyqt_command --sipdir=${EXTERNALPROJECT_INSTALL_PREFIX}/share/sip)
list(APPEND pyqt_command --stubsdir=${EXTERNALPROJECT_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES_DIR})
list(APPEND pyqt_command --verbose)
list(APPEND pyqt_command --no-python-dbus)
list(APPEND pyqt_command --no-designer-plugin)
if(BUILD_OS_WINDOWS)
list(APPEND pyqt_command --static )
list(APPEND pyqt_command --target-py-version=3.5 )
list(APPEND pyqt_command --spec win32-g++)
list(APPEND pyqt_command --sip ${EXTERNALPROJECT_INSTALL_PREFIX}/bin/sip.exe)
list(APPEND pyqt_command --qmake=${EXTERNALPROJECT_INSTALL_PREFIX}/bin/qmake.exe)
# All the code on WIN is position independent, removing -fPIC
list(APPEND pyqt_command QMAKE_CFLAGS+="-m32 -D_hypot=hypot -std=c++11 -static-libstdc++")
list(APPEND pyqt_command QMAKE_CXXFLAGS+="-m32 -D_hypot=hypot -std=c++11 -static-libstdc++")
list(APPEND pyqt_command QMAKE_LFLAGS+="-LC:/Python352 -LC:/Python352/libs -lpython35")
elseif(BUILD_OS_LINUX OR BUILD_OS_OSX)
list(APPEND pyqt_command --sip=${EXTERNALPROJECT_INSTALL_PREFIX}/bin/sip)
list(APPEND pyqt_command --qmake=${EXTERNALPROJECT_INSTALL_PREFIX}/bin/qmake)
endif()
if(BUILD_OS_WINDOWS)
string(REPLACE "/" "\\" pyqt_command "${pyqt_command}")
endif()
message(STATUS "---> PyQt config: ${pyqt_command}")
ExternalProject_Add(PyQt
DEPENDS Python Qt Sip
# URL https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.8.1/PyQt5_gpl-5.8.1.tar.gz/download
URL https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.9/PyQt5_gpl-5.9.tar.gz/download
# PATCH_COMMAND ${pyqt_patch}
CONFIGURE_COMMAND ${pyqt_command}
BUILD_IN_SOURCE 1
)
else()
if(BUILD_OS_WIN32)
add_custom_target(PyQt
DEPENDS Python Qt Sip
COMMAND ${PYTHON_EXECUTABLE} -m pip install --target=${PYTHONPATH} PyQt5==5.9
COMMENT "Installing PyQt5"
)
else()
message(STATUS "---> System PyQt will be used")
add_custom_target(PyQt
DEPENDS Python Qt Sip
)
endif()
endif()
if(BUILD_OPENBLAS)
# Fortran compiler is needed for OpenBLAS, but it does no check whether it is available.
enable_language (Fortran)
set(openblas_options DYNAMIC_ARCH=1 NO_STATIC=1)
# Let's Use the git untill we have next release
message(STATUS "---> OpenBLAS config: ${openblas_options}")
ExternalProject_Add(OpenBLAS
# URL https://github.com/xianyi/OpenBLAS/archive/v0.2.19.tar.gz
GIT_REPOSITORY git://github.com/xianyi/OpenBLAS.git
GIT_TAG 20a413e154948d8b7fc47e7a6d9f13cae98e3856
CONFIGURE_COMMAND ""
BUILD_COMMAND ${MAKE_EXECUTABLE} ${openblas_options}
INSTALL_COMMAND ${MAKE_EXECUTABLE} PREFIX=${EXTERNALPROJECT_INSTALL_PREFIX} install
BUILD_IN_SOURCE 1
)
# SET(OpenBLAS_LIBRARIES ${CMAKE_BINARY_DIR}/inst/lib/libopenblas*)
else()
message(STATUS "---> System OpenBLAS will be used")
add_custom_target(OpenBLAS)
endif()
if(BUILD_PYTHON_NOSE)
set(build_python_nose ${PYTHON_EXECUTABLE} setup.py build)
set(install_python_nose ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose --single-version-externally-managed)
message(STATUS "---> PythonNose Build: ${build_python_nose}")
message(STATUS "---> PythonNose Install: ${install_python_nose}")
ExternalProject_Add(PythonNose
DEPENDS Python PythonSetupTools
GIT_REPOSITORY git://github.com/nose-devs/nose.git
GIT_TAG 7c26ad1e6b7d308cafa328ad34736d34028c122a
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_python_nose}
INSTALL_COMMAND ${install_python_nose}
BUILD_IN_SOURCE 1
)
else()
message(STATUS "---> System PythonNose will be used")
add_custom_target(PythonNose
DEPENDS Python PythonSetupTools
)
endif()
if(BUILD_NUMPY)
set(envvar_numpy)
set(build_numpy ${PYTHON_EXECUTABLE} setup.py)
if(BUILD_OS_LINUX )
list(APPEND build_numpy config --compiler=unix --fcompiler=gnu95 )
list(APPEND build_numpy build_clib --compiler=unix --fcompiler=gnu95 )
list(APPEND build_numpy build_ext --compiler=unix --fcompiler=gnu95 )
list(APPEND envvar_numpy CC=gcc CXX=g++ F90=gfortran)
elseif (BUILD_OS_OSX)
list(APPEND build_numpy config )
list(APPEND build_numpy build_clib )
list(APPEND build_numpy build_ext )
# list(APPEND build_numpy build_ext -j 1 --inplace)
elseif(BUILD_OS_WINDOWS)
list(APPEND build_numpy --no-user-cfg )
list(APPEND build_numpy config --compiler=mingw32 )
list(APPEND build_numpy setopt --command=ALL --option=extra_compile_args --set-value="")
list(APPEND build_numpy build_ext)
list(APPEND build_numpy --compiler=mingw32 )
list(APPEND build_numpy --fcompiler=gnu95 )
list(APPEND build_numpy --inplace )
endif()
# set(install_numpy ${PYTHON_EXECUTABLE} setup.py install --prefix ${EXTERNALPROJECT_INSTALL_PREFIX})
set(install_numpy ${PYTHON_EXECUTABLE} setup.py install --single-version-externally-managed ${python_install})
message(STATUS "---> NumPy build: ${build_numpy}")
message(STATUS "---> NumPy install: ${install_numpy}")
ExternalProject_Add(Numpy
DEPENDS Python OpenBLAS Sip Cython PythonSetupTools PythonNose
# URL http://downloads.sourceforge.net/project/numpy/NumPy/1.11.2/numpy-1.11.2.tar.gz
# URL_MD5 03bd7927c314c43780271bf1ab795ebc
GIT_REPOSITORY git://github.com/numpy/numpy.git
GIT_TAG 32776774fd6d7f0e62e68ff191b8f834a77932a4
CONFIGURE_COMMAND ""
BUILD_COMMAND ${envvar_numpy} ${build_numpy}
INSTALL_COMMAND ${envvar_numpy} ${install_numpy}
BUILD_IN_SOURCE 1
)
else()
if(BUILD_OS_WIN32)
add_custom_target(Numpy
DEPENDS Python OpenBLAS Sip Cython PythonSetupTools PythonNose
COMMAND ${PYTHON_EXECUTABLE} -m pip install --target=${PYTHONPATH} http://software.ultimaker.com/cura-binary-dependencies/numpy-1.11.3+mkl-cp35-cp35m-win32.whl
COMMENT "Installing NumPy"
)
else()
message(STATUS "---> System NumPy will be used")
add_custom_target(Numpy
DEPENDS Python OpenBLAS Sip Cython PythonSetupTools PythonNose
)
endif()
endif()
if (BUILD_SCIPY AND BUILD_SCIPY_LITE)
message(FATAL_ERROR "Can't build SciPy and SciPyLite at the same time")
endif()
if(BUILD_SCIPY)
set(envvar_scipy)
set(build_scipy ${PYTHON_EXECUTABLE} setup.py build_ext)
if(BUILD_OS_LINUX)
list(APPEND envvar_scipy CC=gcc CXX=g++ F90=gfortran)
list(APPEND build_scipy config --compiler=unix --fcompiler=gnu95)
list(APPEND build_scipy build_clib --compiler=unix --fcompiler=gnu95)
list(APPEND build_scipy build_ext --compiler=unix --fcompiler=gnu95)
# -i -j 1
elseif(BUILD_OS_OSX)
list(APPEND build_scipy config )
list(APPEND build_scipy build_clib )
list(APPEND build_scipy build_ext )
elseif(BUILD_OS_WINDOWS)
list(APPEND build_scipy config )
list(APPEND build_scipy build_clib )
list(APPEND build_scipy build_ext)
endif()
# set(install_scipy ${PYTHON_EXECUTABLE} setup.py install --prefix=${EXTERNALPROJECT_INSTALL_PREFIX})
set(install_scipy ${PYTHON_EXECUTABLE} setup.py install ${python_install} --single-version-externally-managed)
message(STATUS "---> SciPy build: ${build_scipy}")
message(STATUS "---> SciPy install: ${install_scipy}")
ExternalProject_Add(Scipy
DEPENDS Python Numpy PythonSix PythonPackaging
# URL http://downloads.sourceforge.net/project/scipy/scipy/0.16.1/scipy-0.16.1.tar.gz
GIT_REPOSITORY git://github.com/scipy/scipy.git
GIT_TAG 46cbf563f5010b27017324ca66e1daffb6d21c47
CONFIGURE_COMMAND ""
BUILD_COMMAND ${envvar_scipy} ${build_scipy}
INSTALL_COMMAND ${envvar_scipy} ${install_scipy}
BUILD_IN_SOURCE 1
)
elseif(NOT BUILD_SCIPY_LITE)
if(BUILD_OS_WIN32)
add_custom_target(Scipy
DEPENDS Python Numpy PythonSix PythonPackaging
COMMAND ${PYTHON_EXECUTABLE} -m pip install --target=${PYTHONPATH} http://software.ultimaker.com/cura-binary-dependencies/scipy-0.19.0-cp35-cp35m-win32.whl
COMMENT "Installing SciPy"
)
else()
message(STATUS "---> System SciPy will be used")
add_custom_target(Scipy
DEPENDS Python Numpy PythonSix PythonPackaging
)
endif()
endif()
if (BUILD_SCIPY_LITE)
# PyHULL is needed then
set(build_pyhull ${PYTHON_EXECUTABLE} setup.py build)
set(install_pyhull ${PYTHON_EXECUTABLE} setup.py install ${python_install} --verbose --single-version-externally-managed)
message(STATUS "---> PyHull Build: ${build_pyhull}")
message(STATUS "---> PyHull Install: ${install_pyhull}")
ExternalProject_Add(PyHull
DEPENDS Python
URL https://github.com/materialsvirtuallab/pyhull/archive/v1.5.0.tar.gz
CONFIGURE_COMMAND ""
BUILD_COMMAND ${build_pyhull}
INSTALL_COMMAND ${install_pyhull}
BUILD_IN_SOURCE 1
)
# And SciPyLite