-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathSearchInstalledSoftware.cmake
2079 lines (1932 loc) · 84.7 KB
/
SearchInstalledSoftware.cmake
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
# Copyright (C) 1995-2022, Rene Brun and Fons Rademakers.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.
#----------------------------------------------------------------------------
# macro ROOT_CHECK_CONNECTION(option)
# Try to download a file to check internet connection.
# If fail-on-missing=ON is set, a failed connection check will cause a fatal
# configuration error.
# Input variables:
# option:
# A hint to the user on which option to set to avoid the part of the
# configuration that requested the connection check.
# Output variables:
# NO_CONNECTION:
# This variable is set based on the result of the connection check:
# - FALSE: An active internet connection was found.
# - TRUE: No internet connection was found or the download failed.
# Note: if the value of NO_CONNECTION is already FALSE, when calling the
# macro, the connection check will not run again.
#----------------------------------------------------------------------------
macro(ROOT_CHECK_CONNECTION option)
# Do something only if connection check is not already done
if(NOT DEFINED NO_CONNECTION)
message(STATUS "Checking internet connectivity")
file(DOWNLOAD https://root.cern/files/cmake_connectivity_test.txt ${CMAKE_CURRENT_BINARY_DIR}/cmake_connectivity_test.txt
TIMEOUT 10 STATUS DOWNLOAD_STATUS
)
# Get the status code from the download status
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
# Check if download was successful.
if(${STATUS_CODE} EQUAL 0)
# Succcess
message(STATUS "Checking internet connectivity - found")
# Now let's delete the file
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmake_connectivity_test.txt)
set(NO_CONNECTION FALSE)
else()
# Error
if(fail-on-missing)
message(FATAL_ERROR "No internet connection. Please check your connection, set '-D${option}' or disable 'fail-on-missing' to automatically disable options requiring internet access")
endif()
message(STATUS "Checking internet connectivity - failed: will not automatically download external dependencies")
set(NO_CONNECTION TRUE)
endif()
endif()
endmacro()
#----------------------------------------------------------------------------
# macro ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION(option_name)
# Check internet connection. If no connection, either disable the option or
# stop the configuration with a FATAL_ERROR in case of fail-on-missing=ON.
#----------------------------------------------------------------------------
macro(ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION option_name)
ROOT_CHECK_CONNECTION("$(option_name)=OFF")
if(NO_CONNECTION)
message(STATUS "No internet connection, disabling '${option_name}' option")
set(${option_name} OFF CACHE BOOL "Disabled because there is no internet connection" FORCE)
endif()
endmacro()
# Building Clad requires an internet connection, if we're not side-loading the source directory
if(clad AND NOT DEFINED CLAD_SOURCE_DIR)
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("clad")
endif()
#---Check for installed packages depending on the build options/components enabled --
include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX)
include(ExternalProject)
include(FindPackageHandleStandardArgs)
set(lcgpackages http://lcgpackages.web.cern.ch/lcgpackages/tarFiles/sources)
string(REPLACE "-Werror " "" ROOT_EXTERNAL_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
macro(find_package)
if(NOT "${ARGV0}" IN_LIST ROOT_BUILTINS)
_find_package(${ARGV})
endif()
endmacro()
#---On MacOSX, try to find frameworks after standard libraries or headers------------
set(CMAKE_FIND_FRAMEWORK LAST)
#---If -Dshared=Off, prefer static libraries-----------------------------------------
if(NOT shared)
if(WINDOWS)
message(FATAL_ERROR "Option \"shared=Off\" not supported on Windows!")
else()
message("Preferring static libraries.")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;${CMAKE_FIND_LIBRARY_SUFFIXES}")
endif()
endif()
#---Check for Cocoa/Quartz graphics backend (MacOS X only)---------------------------
if(cocoa)
if(APPLE)
set(x11 OFF CACHE BOOL "Disabled because cocoa requested (${x11_description})" FORCE)
set(builtin_freetype ON CACHE BOOL "Enabled because needed for Cocoa graphics (${builtin_freetype_description})" FORCE)
else()
message(STATUS "Cocoa option can only be enabled on MacOSX platform")
set(cocoa OFF CACHE BOOL "Disabled because only available on MacOSX (${cocoa_description})" FORCE)
endif()
endif()
#---Check for Zlib ------------------------------------------------------------------
if(NOT builtin_zlib)
message(STATUS "Looking for ZLib")
# Clear cache variables, or LLVM may use old values for ZLIB
foreach(suffix FOUND INCLUDE_DIR LIBRARY LIBRARY_DEBUG LIBRARY_RELEASE)
unset(ZLIB_${suffix} CACHE)
endforeach()
if(fail-on-missing)
find_package(ZLIB REQUIRED)
else()
find_package(ZLIB)
if(NOT ZLIB_FOUND)
message(STATUS "Zlib not found. Switching on builtin_zlib option")
set(builtin_zlib ON CACHE BOOL "Enabled because Zlib not found (${builtin_zlib_description})" FORCE)
endif()
endif()
endif()
if(builtin_zlib)
list(APPEND ROOT_BUILTINS ZLIB)
add_subdirectory(builtins/zlib)
endif()
#---Check for nlohmann/json.hpp---------------------------------------------------------
if(NOT builtin_nlohmannjson)
message(STATUS "Looking for nlohmann/json.hpp")
if(fail-on-missing)
find_package(nlohmann_json 3.9 REQUIRED)
else()
find_package(nlohmann_json 3.9 QUIET)
if(nlohmann_json_FOUND)
get_target_property(_nlohmann_json_incl nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Found nlohmann/json.hpp in ${_nlohmann_json_incl} (found version ${nlohmann_json_VERSION})")
else()
message(STATUS "nlohmann/json.hpp not found. Switching on builtin_nlohmannjson option")
set(builtin_nlohmannjson ON CACHE BOOL "Enabled because nlohmann/json.hpp not found" FORCE)
endif()
endif()
endif()
if(builtin_nlohmannjson)
add_subdirectory(builtins/nlohmann)
endif()
#---Check for Unuran ------------------------------------------------------------------
if(unuran AND NOT builtin_unuran)
message(STATUS "Looking for Unuran")
if(fail-on-missing)
find_Package(Unuran REQUIRED)
else()
find_Package(Unuran)
if(NOT UNURAN_FOUND)
message(STATUS "Unuran not found. Switching on builtin_unuran option")
set(builtin_unuran ON CACHE BOOL "Enabled because Unuran not found (${builtin_unuran_description})" FORCE)
endif()
endif()
endif()
#---Check for Freetype---------------------------------------------------------------
if(NOT builtin_freetype)
message(STATUS "Looking for Freetype")
if(fail-on-missing)
find_package(Freetype REQUIRED)
else()
find_package(Freetype)
if(FREETYPE_FOUND)
set(FREETYPE_INCLUDE_DIR ${FREETYPE_INCLUDE_DIR_freetype2})
else()
message(STATUS "FreeType not found. Switching on builtin_freetype option")
set(builtin_freetype ON CACHE BOOL "Enabled because FreeType not found (${builtin_freetype_description})" FORCE)
endif()
endif()
endif()
if(builtin_freetype)
set(freetype_version 2.12.1)
message(STATUS "Building freetype version ${freetype_version} included in ROOT itself")
set(FREETYPE_LIBRARY ${CMAKE_BINARY_DIR}/FREETYPE-prefix/src/FREETYPE/objs/.libs/${CMAKE_STATIC_LIBRARY_PREFIX}freetype${CMAKE_STATIC_LIBRARY_SUFFIX})
if(WIN32)
set(FREETYPE_LIB_DIR ".")
if(CMAKE_GENERATOR MATCHES Ninja)
set(freetypelib freetype.lib)
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(freetypelib freetyped.lib)
endif()
else()
set(freetypebuild Release)
set(freetypelib freetype.lib)
if(winrtdebug)
set(freetypebuild Debug)
set(freetypelib freetyped.lib)
endif()
set(FREETYPE_LIB_DIR "${freetypebuild}")
set(FREETYPE_EXTRA_BUILD_ARGS --config ${freetypebuild})
endif()
ExternalProject_Add(
FREETYPE
URL ${CMAKE_SOURCE_DIR}/graf2d/freetype/src/freetype-${freetype_version}.tar.gz
URL_HASH SHA256=efe71fd4b8246f1b0b1b9bfca13cfff1c9ad85930340c27df469733bbb620938
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS -G ${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DFT_DISABLE_BZIP2=TRUE
BUILD_COMMAND ${CMAKE_COMMAND} --build . ${FREETYPE_EXTRA_BUILD_ARGS}
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FREETYPE_LIB_DIR}/${freetypelib} ${FREETYPE_LIBRARY}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 BUILD_IN_SOURCE 0
BUILD_BYPRODUCTS ${FREETYPE_LIBRARY}
TIMEOUT 600
)
else()
set(_freetype_cflags -O)
set(_freetype_cc ${CMAKE_C_COMPILER})
if(CMAKE_SYSTEM_NAME STREQUAL AIX)
set(_freetype_zlib --without-zlib)
endif()
set(_freetype_brotli "--with-brotli=no")
if(CMAKE_OSX_SYSROOT)
set(_freetype_cc "${_freetype_cc} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
ExternalProject_Add(
FREETYPE
URL ${CMAKE_SOURCE_DIR}/graf2d/freetype/src/freetype-${freetype_version}.tar.gz
URL_HASH SHA256=efe71fd4b8246f1b0b1b9bfca13cfff1c9ad85930340c27df469733bbb620938
CONFIGURE_COMMAND ./configure --prefix <INSTALL_DIR> --with-pic
--disable-shared --with-png=no --with-bzip2=no
--with-harfbuzz=no ${_freetype_brotli} ${_freetype_zlib}
"CC=${_freetype_cc}" CFLAGS=${_freetype_cflags}
INSTALL_COMMAND ""
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${FREETYPE_LIBRARY}
TIMEOUT 600
)
endif()
set(FREETYPE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/FREETYPE-prefix/src/FREETYPE/include)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR})
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
set(FREETYPE_TARGET FREETYPE)
endif()
#---Check for PCRE-------------------------------------------------------------------
if(NOT builtin_pcre)
message(STATUS "Looking for PCRE")
# Clear cache before calling find_package(PCRE),
# necessary to be able to toggle builtin_pcre and
# not have find_package(PCRE) find builtin pcre.
foreach(suffix FOUND INCLUDE_DIR PCRE_LIBRARY)
unset(PCRE_${suffix} CACHE)
endforeach()
find_package(PCRE2)
if(NOT PCRE2_FOUND)
if(fail-on-missing)
find_package(PCRE REQUIRED)
else()
find_package(PCRE)
if(NOT PCRE_FOUND)
message(STATUS "PCRE not found. Switching on builtin_pcre option")
set(builtin_pcre ON CACHE BOOL "Enabled because PCRE not found (${builtin_pcre_description})" FORCE)
endif()
endif()
endif()
endif()
if(builtin_pcre)
list(APPEND ROOT_BUILTINS PCRE)
add_subdirectory(builtins/pcre)
endif()
#---Check for LZMA-------------------------------------------------------------------
if(NOT builtin_lzma)
message(STATUS "Looking for LZMA")
if(fail-on-missing)
find_package(LibLZMA REQUIRED)
else()
find_package(LibLZMA)
if(NOT LIBLZMA_FOUND)
message(STATUS "LZMA not found. Switching on builtin_lzma option")
set(builtin_lzma ON CACHE BOOL "Enabled because LZMA not found (${builtin_lzma_description})" FORCE)
endif()
endif()
endif()
if(builtin_lzma)
set(lzma_version 5.2.4)
set(LZMA_TARGET LZMA)
message(STATUS "Building LZMA version ${lzma_version} included in ROOT itself")
if(WIN32)
set(lzma_version 5.6.3)
set(LIBLZMA_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}lzma${CMAKE_STATIC_LIBRARY_SUFFIX})
ExternalProject_Add(
LZMA
URL ${CMAKE_SOURCE_DIR}/core/lzma/src/xz-${lzma_version}.tar.gz
URL_HASH SHA256=b1d45295d3f71f25a4c9101bd7c8d16cb56348bbef3bbc738da0351e17c73317
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS -G ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG> --target liblzma
INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config $<CONFIG> --component liblzma_Development
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${LIBLZMA_LIBRARIES}
TIMEOUT 600
)
set(LIBLZMA_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
else()
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(LIBLZMA_CFLAGS "-Wno-format-nonliteral")
set(LIBLZMA_LDFLAGS "-Qunused-arguments")
elseif( CMAKE_CXX_COMPILER_ID STREQUAL Intel)
set(LIBLZMA_CFLAGS "-wd188 -wd181 -wd1292 -wd10006 -wd10156 -wd2259 -wd981 -wd128 -wd3179 -wd2102")
endif()
if(CMAKE_OSX_SYSROOT)
set(LIBLZMA_CFLAGS "${LIBLZMA_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
set(LIBLZMA_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}lzma${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LIBLZMA_CFLAGS "${LIBLZMA_CFLAGS} -O3")
ExternalProject_Add(
LZMA
URL ${CMAKE_SOURCE_DIR}/core/lzma/src/xz-${lzma_version}.tar.gz
URL_HASH SHA256=b512f3b726d3b37b6dc4c8570e137b9311e7552e8ccbab4d39d47ce5f4177145
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR> --libdir <INSTALL_DIR>/lib
--with-pic --disable-shared --quiet
--disable-scripts --disable-xz --disable-xzdec --disable-lzmadec --disable-lzmainfo --disable-lzma-links
CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS=${LIBLZMA_CFLAGS} LDFLAGS=${LIBLZMA_LDFLAGS}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${LIBLZMA_LIBRARIES}
TIMEOUT 600
)
set(LIBLZMA_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
endif()
endif()
#---Check for xxHash-----------------------------------------------------------------
if(NOT builtin_xxhash)
message(STATUS "Looking for xxHash")
if(fail-on-missing)
find_package(xxHash 0.8 REQUIRED)
else()
find_package(xxHash 0.8)
if(NOT xxHash_FOUND)
message(STATUS "xxHash not found. Switching on builtin_xxhash option")
set(builtin_xxhash ON CACHE BOOL "Enabled because xxHash not found (${builtin_xxhash_description})" FORCE)
endif()
endif()
endif()
if(builtin_xxhash)
list(APPEND ROOT_BUILTINS xxHash)
add_subdirectory(builtins/xxhash)
endif()
#---Check for ZSTD-------------------------------------------------------------------
if(NOT builtin_zstd)
message(STATUS "Looking for ZSTD")
foreach(suffix FOUND INCLUDE_DIR LIBRARY LIBRARIES LIBRARY_DEBUG LIBRARY_RELEASE)
unset(ZSTD_${suffix} CACHE)
endforeach()
if(fail-on-missing)
find_package(ZSTD REQUIRED)
if(ZSTD_VERSION VERSION_LESS 1.0.0)
message(FATAL "Version of installed ZSTD is too old: ${ZSTD_VERSION}. Please install newer version (>1.0.0)")
endif()
else()
find_package(ZSTD)
if(NOT ZSTD_FOUND)
message(STATUS "ZSTD not found. Switching on builtin_zstd option")
set(builtin_zstd ON CACHE BOOL "Enabled because ZSTD not found (${builtin_zstd_description})" FORCE)
elseif(ZSTD_FOUND AND ZSTD_VERSION VERSION_LESS 1.0.0)
message(STATUS "Version of installed ZSTD is too old: ${ZSTD_VERSION}. Switching on builtin_zstd option")
set(builtin_zstd ON CACHE BOOL "Enabled because ZSTD not found (${builtin_zstd_description})" FORCE)
endif()
endif()
endif()
if(builtin_zstd)
list(APPEND ROOT_BUILTINS ZSTD)
add_subdirectory(builtins/zstd)
endif()
#---Check for LZ4--------------------------------------------------------------------
if(NOT builtin_lz4)
message(STATUS "Looking for LZ4")
foreach(suffix FOUND INCLUDE_DIR LIBRARY LIBRARY_DEBUG LIBRARY_RELEASE)
unset(LZ4_${suffix} CACHE)
endforeach()
if(fail-on-missing)
find_package(LZ4 REQUIRED)
else()
find_package(LZ4)
if(NOT LZ4_FOUND)
message(STATUS "LZ4 not found. Switching on builtin_lz4 option")
set(builtin_lz4 ON CACHE BOOL "Enabled because LZ4 not found (${builtin_lz4_description})" FORCE)
endif()
endif()
endif()
if(builtin_lz4)
list(APPEND ROOT_BUILTINS LZ4)
add_subdirectory(builtins/lz4)
endif()
#---Check for X11 which is mandatory lib on Unix--------------------------------------
if(x11)
message(STATUS "Looking for X11")
if(X11_X11_INCLUDE_PATH)
set(X11_FIND_QUIETLY 1)
endif()
find_package(X11 REQUIRED COMPONENTS Xpm Xft Xext)
list(REMOVE_DUPLICATES X11_INCLUDE_DIR)
if(NOT X11_FIND_QUIETLY)
message(STATUS "X11_INCLUDE_DIR: ${X11_INCLUDE_DIR}")
message(STATUS "X11_LIBRARIES: ${X11_LIBRARIES}")
message(STATUS "X11_Xpm_INCLUDE_PATH: ${X11_Xpm_INCLUDE_PATH}")
message(STATUS "X11_Xpm_LIB: ${X11_Xpm_LIB}")
message(STATUS "X11_Xft_INCLUDE_PATH: ${X11_Xft_INCLUDE_PATH}")
message(STATUS "X11_Xft_LIB: ${X11_Xft_LIB}")
message(STATUS "X11_Xext_INCLUDE_PATH: ${X11_Xext_INCLUDE_PATH}")
message(STATUS "X11_Xext_LIB: ${X11_Xext_LIB}")
endif()
endif()
#---Check for all kind of graphics includes needed by libAfterImage--------------------
if(asimage)
if(NOT x11 AND NOT cocoa AND NOT WIN32)
message(STATUS "Switching off 'asimage' because neither 'x11' nor 'cocoa' are enabled")
set(asimage OFF CACHE BOOL "Disabled because neither x11 nor cocoa are enabled (${asimage_description})" FORCE)
endif()
endif()
if(asimage)
set(ASEXTRA_LIBRARIES)
find_Package(GIF)
if(GIF_FOUND)
set(ASEXTRA_LIBRARIES ${ASEXTRA_LIBRARIES} ${GIF_LIBRARIES})
endif()
find_Package(TIFF)
if(TIFF_FOUND)
set(ASEXTRA_LIBRARIES ${ASEXTRA_LIBRARIES} ${TIFF_LIBRARIES})
endif()
find_Package(PNG)
if(PNG_FOUND)
set(ASEXTRA_LIBRARIES ${ASEXTRA_LIBRARIES} ${PNG_LIBRARIES})
# Some missing variables needed for external PNG build
set(PNG_LIBRARY_RELEASE ${PNG_LIBRARY})
# apparently there will be two set of includes here (needs to be selected only last that was passed: PNG_INCLUDE_DIR)
list(GET PNG_INCLUDE_DIRS 0 PNG_INCLUDE_DIR)
endif()
find_Package(JPEG)
if(JPEG_FOUND)
set(ASEXTRA_LIBRARIES ${ASEXTRA_LIBRARIES} ${JPEG_LIBRARIES})
endif()
#---AfterImage---------------------------------------------------------------
set(AFTERIMAGE_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libAfterImage${CMAKE_STATIC_LIBRARY_SUFFIX})
if(WIN32)
set(ASTEP_LIB_DIR ".")
if(NOT CMAKE_GENERATOR MATCHES Ninja)
if(winrtdebug)
set(astepbld Debug)
else()
set(astepbld Release)
endif()
set(ASTEP_LIB_DIR "${astepbld}")
set(ASTEP_EXTRA_BUILD_ARGS --config ${astepbld})
endif()
ExternalProject_Add(
AFTERIMAGE
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/graf2d/asimage/src/libAfterImage AFTERIMAGE
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS -G ${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DFREETYPE_INCLUDE_DIR=${FREETYPE_INCLUDE_DIR} -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIR}
BUILD_COMMAND ${CMAKE_COMMAND} --build . ${ASTEP_EXTRA_BUILD_ARGS}
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ASTEP_LIB_DIR}/libAfterImage.lib <INSTALL_DIR>/lib/
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 BUILD_IN_SOURCE 0
BUILD_BYPRODUCTS ${AFTERIMAGE_LIBRARIES}
TIMEOUT 600
)
set(AFTERIMAGE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/AFTERIMAGE-prefix/src/AFTERIMAGE)
else()
if(JPEG_FOUND)
set(_jpeginclude --with-jpeg-includes=${JPEG_INCLUDE_DIR})
else()
set(_jpeginclude --with-builtin-jpeg)
endif()
if(GIF_FOUND)
set(_gifinclude --with-gif --with-gif-includes=${GIF_INCLUDE_DIR} --without-builtin-gif)
else()
set(_gifinclude)
endif()
if(PNG_FOUND)
set(_pnginclude --with-png-includes=${PNG_INCLUDE_DIR})
else()
set(_pnginclude --with-builtin-png)
endif()
if(TIFF_FOUND)
set(_tiffinclude --with-tiff-includes=${TIFF_INCLUDE_DIR})
else()
set(_tiffinclude --with-tiff=no)
endif()
if(cocoa)
set(_jpeginclude --without-x --with-builtin-jpeg)
set(_gifinclude --with-builtin-ungif)
set(_pnginclude --with-builtin-png)
set(_tiffinclude --with-tiff=no)
endif()
if(builtin_freetype)
set(_ttf_include --with-ttf-includes=-I${FREETYPE_INCLUDE_DIR})
set(_after_cflags "${_after_cflags} -DHAVE_FREETYPE_FREETYPE -DPNG_ARM_NEON_OPT=0")
endif()
if(CMAKE_OSX_SYSROOT)
set(_after_cflags "${_after_cflags} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
if(builtin_zlib)
set(_after_cflags "${_after_cflags} -I${ZLIB_INCLUDE_DIR}")
endif()
ExternalProject_Add(
AFTERIMAGE
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/graf2d/asimage/src/libAfterImage AFTERIMAGE
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND ./configure --prefix <INSTALL_DIR>
--libdir=<INSTALL_DIR>/lib
--with-ttf ${_ttf_include} --with-afterbase=no
--without-svg --disable-glx ${_after_mmx}
${_gifinclude} --with-jpeg ${_jpeginclude}
--with-png ${_pnginclude} ${_tiffinclude}
CC=${CMAKE_C_COMPILER} CFLAGS=${_after_cflags}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${AFTERIMAGE_LIBRARIES}
TIMEOUT 600
)
set(AFTERIMAGE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/libAfterImage)
endif()
if(builtin_freetype)
add_dependencies(AFTERIMAGE FREETYPE)
endif()
set(AFTERIMAGE_TARGET AFTERIMAGE)
endif()
#---Check for GSL library---------------------------------------------------------------
if(mathmore OR builtin_gsl)
if(builtin_gsl)
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_gsl")
endif()
message(STATUS "Looking for GSL")
if(NOT builtin_gsl)
find_package(GSL 1.10)
if(NOT GSL_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "GSL package not found and 'mathmore' component if required ('fail-on-missing' enabled). "
"Alternatively, you can enable the option 'builtin_gsl' to build the GSL libraries internally.")
else()
message(STATUS "GSL not found. Set variable GSL_ROOT_DIR to point to your GSL installation")
message(STATUS " Alternatively, you can also enable the option 'builtin_gsl' to build the GSL libraries internally'")
message(STATUS " For the time being switching OFF 'mathmore' option")
set(mathmore OFF CACHE BOOL "Disable because builtin_gsl disabled and external GSL not found (${mathmore_description})" FORCE)
endif()
endif()
else()
set(gsl_version 2.5)
message(STATUS "Downloading and building GSL version ${gsl_version}")
foreach(l gsl gslcblas)
list(APPEND GSL_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${l}${CMAKE_STATIC_LIBRARY_SUFFIX})
endforeach()
set(GSL_CBLAS_LIBRARY ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX})
if(CMAKE_OSX_SYSROOT)
set(_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT}")
set(_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT}")
endif()
ExternalProject_Add(
GSL
# http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz
URL ${lcgpackages}/gsl-${gsl_version}.tar.gz
URL_HASH SHA256=0460ad7c2542caaddc6729762952d345374784100223995eb14d614861f2258d
SOURCE_DIR GSL-src # prevent "<gsl/...>" vs GSL/ macOS warning
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR>
--libdir=<INSTALL_DIR>/lib
--enable-shared=no --with-pic
CC=${CMAKE_C_COMPILER}
CFLAGS=${CMAKE_C_FLAGS}
CPPFLAGS=${_gsl_cppflags}
LDFLAGS=${_gsl_ldflags}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
BUILD_BYPRODUCTS ${GSL_LIBRARIES}
TIMEOUT 600
)
set(GSL_TARGET GSL)
# FIXME: one need to find better way to extract path with GSL include files
set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build)
set(GSL_FOUND ON)
set(mathmore ON CACHE BOOL "Enabled because builtin_gls requested (${mathmore_description})" FORCE)
endif()
endif()
#---Check for Python installation-------------------------------------------------------
message(STATUS "Looking for Python")
# On macOS, prefer user-provided Pythons.
set(Python3_FIND_FRAMEWORK LAST)
# Even if we don't build PyROOT, one still need python executable to run some scripts
list(APPEND python_components Interpreter)
if(pyroot OR tmva-pymva)
list(APPEND python_components Development)
endif()
if(tmva-pymva)
list(APPEND python_components NumPy)
endif()
find_package(Python3 3.8 COMPONENTS ${python_components})
#---Check for OpenGL installation-------------------------------------------------------
# OpenGL is required by various graf3d features that are enabled with opengl=ON,
# or by the Cocoa-related code that always requires it.
if(opengl OR cocoa)
message(STATUS "Looking for OpenGL")
if(APPLE)
set(CMAKE_FIND_FRAMEWORK FIRST)
find_package(OpenGL)
set(CMAKE_FIND_FRAMEWORK LAST)
else()
find_package(OpenGL)
endif()
if(NOT OPENGL_FOUND OR NOT OPENGL_GLU_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "OpenGL package (with GLU) not found and opengl option required")
elseif(cocoa)
message(FATAL_ERROR "OpenGL package (with GLU) not found and opengl option required for \"cocoa=ON\"")
else()
message(STATUS "OpenGL (with GLU) not found. Switching off opengl option")
set(opengl OFF CACHE BOOL "Disabled because OpenGL (with GLU) not found (${opengl_description})" FORCE)
endif()
endif()
endif()
# OpenGL should be working only with x11 (Linux),
# in case when -Dall=ON -Dx11=OFF, we will just disable opengl.
if(NOT WIN32 AND NOT APPLE)
if(opengl AND NOT x11)
message(STATUS "OpenGL was disabled, since it is requires x11 on Linux")
set(opengl OFF CACHE BOOL "OpenGL requires x11" FORCE)
endif()
endif()
# The opengl flag enables the graf3d features that depend on OpenGL, and these
# features also depend on asimage. Therefore, the configuration will fail if
# asimage is off. See also: https://github.com/root-project/root/issues/16250
if(opengl AND NOT asimage)
message(FATAL_ERROR "OpenGL features enabled with \"opengl=ON\" require \"asimage=ON\"")
endif()
#---Check for GLEW -------------------------------------------------------------------
# Glew is required by various graf3d features that are enabled with opengl=ON,
# or by the Cocoa-related code that always requires it.
if((opengl OR cocoa) AND NOT builtin_glew)
message(STATUS "Looking for GLEW")
if(fail-on-missing)
find_package(GLEW REQUIRED)
else()
find_package(GLEW)
if(GLEW_FOUND AND APPLE AND CMAKE_VERSION VERSION_GREATER 3.15 AND CMAKE_VERSION VERSION_LESS 3.25)
# Bug in CMake on Mac OS X until 3.25:
# https://gitlab.kitware.com/cmake/cmake/-/issues/19662
# https://github.com/microsoft/vcpkg/pull/7967
message(FATAL_ERROR "Please enable builtin Glew due a bug in CMake's FindGlew < v3.25 (use cmake option -Dbuiltin_glew=ON).")
unset(GLEW_FOUND)
elseif(GLEW_FOUND AND NOT TARGET GLEW::GLEW)
add_library(GLEW::GLEW UNKNOWN IMPORTED)
set_target_properties(GLEW::GLEW PROPERTIES
IMPORTED_LOCATION "${GLEW_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
endif()
if(NOT GLEW_FOUND)
message(STATUS "GLEW not found. Switching on builtin_glew option")
set(builtin_glew ON CACHE BOOL "Enabled because opengl requested and GLEW not found (${builtin_glew_description})" FORCE)
endif()
endif()
endif()
if(builtin_glew)
list(APPEND ROOT_BUILTINS GLEW)
add_library(GLEW::GLEW INTERFACE IMPORTED GLOBAL)
add_subdirectory(builtins/glew)
endif()
#---Check for gl2ps ------------------------------------------------------------------
if(opengl AND NOT builtin_gl2ps)
message(STATUS "Looking for gl2ps")
if(fail-on-missing)
find_Package(gl2ps REQUIRED)
else()
find_Package(gl2ps)
if(NOT GL2PS_FOUND)
message(STATUS "gl2ps not found. Switching on builtin_gl2ps option")
set(builtin_gl2ps ON CACHE BOOL "Enabled because opengl requested and gl2ps not found (${builtin_gl2ps_description})" FORCE)
endif()
endif()
endif()
#---Check for Graphviz installation-------------------------------------------------------
if(gviz)
message(STATUS "Looking for Graphviz")
find_package(Graphviz)
if(NOT GRAPHVIZ_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "Graphviz package not found and gviz option required")
else()
message(STATUS "Graphviz not found. Switching off gviz option")
set(gviz OFF CACHE BOOL "Disabled because Graphviz not found (${gviz_description})" FORCE)
endif()
endif()
endif()
#---Check for XML Parser Support-----------------------------------------------------------
if(xml)
message(STATUS "Looking for LibXml2")
find_package(LibXml2)
if(NOT LIBXML2_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "LibXml2 libraries not found and they are required (xml option enabled)")
else()
message(STATUS "LibXml2 not found. Switching off xml option")
set(xml OFF CACHE BOOL "Disabled because LibXml2 not found (${xml_description})" FORCE)
endif()
endif()
endif()
#---Check for OpenSSL------------------------------------------------------------------
foreach(suffix FOUND INCLUDE_DIR INCLUDE_DIRS LIBRARY LIBRARIES VERSION)
unset(OPENSSL_${suffix} CACHE)
endforeach()
if(ssl AND NOT builtin_openssl)
if(fail-on-missing)
find_package(OpenSSL REQUIRED)
else()
find_package(OpenSSL COMPONENTS SSL)
if(NOT OPENSSL_FOUND)
if(NOT APPLE) # builtin OpenSSL is only supported on macOS
message(STATUS "Switching OFF 'ssl' option.")
set(ssl OFF CACHE BOOL "Disabled because OpenSSL not found and builtin version only works on macOS (${ssl_description})" FORCE)
else()
ROOT_CHECK_CONNECTION("ssl=OFF")
if(NO_CONNECTION)
message(STATUS "OpenSSL not found, and no internet connection. Disabling the 'ssl' option.")
set(ssl OFF CACHE BOOL "Disabled because ssl requested and OpenSSL not found (${builtin_openssl_description}) and there is no internet connection" FORCE)
else()
message(STATUS "OpenSSL not found, switching ON 'builtin_openssl' option.")
set(builtin_openssl ON CACHE BOOL "Enabled because ssl requested and OpenSSL not found (${builtin_openssl_description})" FORCE)
endif()
endif()
endif()
endif()
endif()
if(builtin_openssl)
ROOT_CHECK_CONNECTION("builtin_openssl=OFF")
if(NO_CONNECTION)
message(STATUS "No internet connection, disabling the 'ssl' and 'builtin_openssl' options")
set(builtin_openssl OFF CACHE BOOL "Disabled because there is no internet connection" FORCE)
set(ssl OFF CACHE BOOL "Disabled because there is no internet connection" FORCE)
else()
list(APPEND ROOT_BUILTINS OpenSSL)
add_subdirectory(builtins/openssl)
endif()
endif()
#---Check for MySQL-------------------------------------------------------------------
if(mysql)
message(STATUS "Looking for MySQL")
find_package(MySQL)
if(NOT MYSQL_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "MySQL libraries not found and they are required (mysql option enabled)")
else()
message(STATUS "MySQL not found. Switching off mysql option")
set(mysql OFF CACHE BOOL "Disabled because MySQL not found (${mysql_description})" FORCE)
endif()
endif()
endif()
#---Check for FastCGI-----------------------------------------------------------
if(fcgi)
message(STATUS "Looking for FastCGI")
find_package(FastCGI)
if(NOT FASTCGI_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "FastCGI library not found and they are required (fcgi option enabled)")
else()
message(STATUS "FastCGI not found. Switching off fcgi option")
set(fcgi OFF CACHE BOOL "Disabled because FastCGI not found" FORCE)
endif()
endif()
endif()
#---Check for ODBC-------------------------------------------------------------------
if(odbc)
message(STATUS "Looking for ODBC")
find_package(ODBC)
if(NOT ODBC_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "ODBC libraries not found and they are required (odbc option enabled)")
else()
message(STATUS "ODBC not found. Switching off odbc option")
set(odbc OFF CACHE BOOL "Disabled because ODBC not found (${odbc_description})" FORCE)
endif()
endif()
endif()
#---Check for PostgreSQL-------------------------------------------------------------------
if(pgsql)
message(STATUS "Looking for PostgreSQL")
find_package(PostgreSQL)
if(NOT PostgreSQL_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "PostgreSQL libraries not found and they are required (pgsql option enabled)")
else()
message(STATUS "PostgreSQL not found. Switching off pgsql option")
set(pgsql OFF CACHE BOOL "Disabled because PostgreSQL not found (${pgsql_description})" FORCE)
endif()
endif()
endif()
#---Check for SQLite-------------------------------------------------------------------
if(sqlite)
message(STATUS "Looking for SQLite")
find_package(Sqlite)
if(NOT SQLITE_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "SQLite libraries not found and they are required (sqlite option enabled)")
else()
message(STATUS "SQLite not found. Switching off sqlite option")
set(sqlite OFF CACHE BOOL "Disabled because SQLite not found (${sqlite_description})" FORCE)
endif()
endif()
endif()
#---Check for Pythia8-------------------------------------------------------------------
if(pythia8)
message(STATUS "Looking for Pythia8")
find_package(Pythia8)
if(NOT PYTHIA8_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "Pythia8 libraries not found and they are required (pythia8 option enabled)")
else()
message(STATUS "Pythia8 not found. Switching off pythia8 option")
set(pythia8 OFF CACHE BOOL "Disabled because Pythia8 not found (${pythia8_description})" FORCE)
endif()
endif()
endif()
if(builtin_fftw3)
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_fftw3")
endif()
#---Check for FFTW3-------------------------------------------------------------------
if(fftw3)
if(NOT builtin_fftw3)
message(STATUS "Looking for FFTW3")
find_package(FFTW)
if(NOT FFTW_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "FFTW3 libraries not found and they are required (fftw3 option enabled)")
else()
message(STATUS "FFTW3 not found. Set [environment] variable FFTW_DIR to point to your FFTW3 installation")
message(STATUS " Alternatively, you can also enable the option 'builtin_fftw3' to build FFTW3 internally'")
message(STATUS " For the time being switching OFF 'fftw3' option")
set(fftw3 OFF CACHE BOOL "Disabled because FFTW3 not found and builtin_fftw3 disabled (${fftw3_description})" FORCE)
endif()
endif()
endif()
endif()
if(builtin_fftw3)
set(FFTW_VERSION 3.3.8)
message(STATUS "Downloading and building FFTW version ${FFTW_VERSION}")
set(FFTW_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libfftw3.a)
ExternalProject_Add(
FFTW3
URL ${lcgpackages}/fftw-${FFTW_VERSION}.tar.gz
URL_HASH SHA256=6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR>
BUILD_COMMAND make CFLAGS=-fPIC
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${FFTW_LIBRARIES}
TIMEOUT 600
)
set(FFTW_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
set(FFTW3_TARGET FFTW3)
set(fftw3 ON CACHE BOOL "Enabled because builtin_fftw3 requested (${fftw3_description})" FORCE)
endif()
#---Check for fitsio-------------------------------------------------------------------
if(fitsio OR builtin_cfitsio)
if(builtin_cfitsio)
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_cfitsio")
endif()
if(builtin_cfitsio)
add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL)
add_subdirectory(builtins/cfitsio)
set(fitsio ON CACHE BOOL "Enabled because builtin_cfitsio requested (${fitsio_description})" FORCE)
else()
message(STATUS "Looking for CFITSIO")
if(fail-on-missing)
find_package(CFITSIO REQUIRED)
else()
find_package(CFITSIO)
if(NOT CFITSIO_FOUND)
message(STATUS "CFITSIO not found. You can enable the option 'builtin_cfitsio' to build the library internally'")
message(STATUS " For the time being switching off 'fitsio' option")
set(fitsio OFF CACHE BOOL "Disabled because CFITSIO not found and builtin_cfitsio disabled (${fitsio_description})" FORCE)
endif()
endif()
endif()
endif()
#---Check Shadow password support----------------------------------------------------
if(shadowpw)
if(NOT EXISTS /etc/shadow) #---TODO--The test always succeeds because the actual file is protected
if(NOT CMAKE_SYSTEM_NAME MATCHES Linux)
message(STATUS "Support Shadow password not found. Switching off shadowpw option")
set(shadowpw OFF CACHE BOOL "Disabled because /etc/shadow not found (${shadowpw_description})" FORCE)
endif()
endif()
endif()
#---Configure Xrootd support---------------------------------------------------------
foreach(suffix FOUND INCLUDE_DIR INCLUDE_DIRS LIBRARY LIBRARIES)
unset(XROOTD_${suffix} CACHE)
endforeach()
if(xrootd OR builtin_xrootd)
# This is the target that ROOT will use, irrespective of whether XRootD is a builtin or in the system.
# All targets should only link to ROOT::XRootD. Refrain from using XRootD variables.
add_library(XRootD INTERFACE IMPORTED GLOBAL)
add_library(ROOT::XRootD ALIAS XRootD)
endif()
if(xrootd AND NOT builtin_xrootd)
message(STATUS "Looking for XROOTD")
find_package(XRootD)
if(NOT XROOTD_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "XROOTD not found. Set environment variable XRDSYS to point to your XROOTD installation, "
"or include the installation of XROOTD in the CMAKE_PREFIX_PATH. "
"Alternatively, you can also enable the option 'builtin_xrootd' to build XROOTD internally")
else()
ROOT_CHECK_CONNECTION("xrootd=OFF")
if(NO_CONNECTION)
message(FATAL_ERROR "No internet connection. Please check your connection, or either disable the 'builtin_xrootd'"
" option or the 'fail-on-missing' to automatically disable options requiring internet access")
else()
message(STATUS "XROOTD not found, enabling 'builtin_xrootd' option")
set(builtin_xrootd ON CACHE BOOL "Enabled because xrootd is enabled, but external xrootd was not found (${xrootd_description})" FORCE)
endif()
endif()
endif()
endif()
if(builtin_xrootd)
ROOT_CHECK_CONNECTION("builtin_xrootd=OFF")
if(NO_CONNECTION)
message(FATAL_ERROR "No internet connection. Please check your connection, or either disable the 'builtin_xrootd'"
" option or the 'fail-on-missing' to automatically disable options requiring internet access")
endif()
list(APPEND ROOT_BUILTINS BUILTIN_XROOTD)
# The builtin XRootD requires OpenSSL.
# We have to find it here, such that OpenSSL is available in this scope to
# finalize the XRootD target configuration.
# See also: https://github.com/root-project/root/issues/16374
find_package(OpenSSL REQUIRED)
add_subdirectory(builtins/xrootd)
set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})" FORCE)
endif()
# Finalise the XRootD target configuration
if(TARGET XRootD)
# The XROOTD_INCLUDE_DIRS provided by XRootD is actually a list with two
# paths, like:
# <xrootd_include_dir>;<xrootd_include_dir>/private
# We don't need the private headers, and we have to exclude this path from
# the build configuration if we don't want it to fail on systems were the
# private headers are not installed (most linux distributions).
list(GET XROOTD_INCLUDE_DIRS 0 XROOTD_INCLUDE_DIR_PRIMARY)
target_include_directories(XRootD SYSTEM INTERFACE "$<BUILD_INTERFACE:${XROOTD_INCLUDE_DIR_PRIMARY}>")
target_link_libraries(XRootD INTERFACE $<BUILD_INTERFACE:${XROOTD_CLIENT_LIBRARIES}>)
target_link_libraries(XRootD INTERFACE $<BUILD_INTERFACE:${XROOTD_UTILS_LIBRARIES}>)
endif()