forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRootMacros.cmake
More file actions
3485 lines (3057 loc) · 136 KB
/
RootMacros.cmake
File metadata and controls
3485 lines (3057 loc) · 136 KB
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-2019, Rene Brun and Fons Rademakers.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.
#---------------------------------------------------------------------------------------------------
# RootMacros.cmake
#---------------------------------------------------------------------------------------------------
if(WIN32)
set(libprefix lib)
set(ld_library_path PATH)
set(libsuffix .dll)
set(localruntimedir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(runtimedir ${CMAKE_INSTALL_BINDIR})
elseif(APPLE)
set(ld_library_path DYLD_LIBRARY_PATH)
set(ld_preload DYLD_INSERT_LIBRARIES)
set(libprefix ${CMAKE_SHARED_LIBRARY_PREFIX})
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
set(libsuffix .so)
else()
set(libsuffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(runtimedir ${CMAKE_INSTALL_PYTHONDIR})
else()
set(ld_library_path LD_LIBRARY_PATH)
set(ld_preload LD_PRELOAD)
set(libprefix ${CMAKE_SHARED_LIBRARY_PREFIX})
set(libsuffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(runtimedir ${CMAKE_INSTALL_PYTHONDIR})
endif()
set(ROOT_LIBRARY_PROPERTIES_NO_VERSION ${ROOT_LIBRARY_PROPERTIES_NO_VERSION}
SUFFIX ${libsuffix}
PREFIX ${libprefix} )
if(soversion)
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} ${ROOT_LIBRARY_PROPERTIES_NO_VERSION}
VERSION ${ROOT_VERSION}
SOVERSION ${ROOT_MAJOR_VERSION}.${ROOT_MINOR_VERSION} )
else()
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} ${ROOT_LIBRARY_PROPERTIES_NO_VERSION} )
endif()
include(CMakeParseArguments)
#---------------------------------------------------------------------------------------------------
#---ROOT_GLOB_FILES( <variable> [REALTIVE path] [FILTER regexp] <sources> ...)
#---------------------------------------------------------------------------------------------------
function(ROOT_GLOB_FILES variable)
CMAKE_PARSE_ARGUMENTS(ARG "RECURSE" "RELATIVE;FILTER" "" ${ARGN})
set(_possibly_recurse "")
if (ARG_RECURSE)
set(_possibly_recurse "_RECURSE")
endif()
if(ARG_RELATIVE)
file(GLOB${_possibly_recurse} _sources RELATIVE ${ARG_RELATIVE} ${ARG_UNPARSED_ARGUMENTS})
else()
file(GLOB${_possibly_recurse} _sources ${ARG_UNPARSED_ARGUMENTS})
endif()
if(ARG_FILTER)
foreach(s ${_sources})
if(s MATCHES ${ARG_FILTER})
list(REMOVE_ITEM _sources ${s})
endif()
endforeach()
endif()
set(${variable} ${_sources} PARENT_SCOPE)
endfunction()
function(ROOT_GLOB_SOURCES variable)
ROOT_GLOB_FILES(_sources FILTER "(^|/)G__" ${ARGN})
set(${variable} ${_sources} PARENT_SCOPE)
endfunction()
function(ROOT_GLOB_HEADERS variable)
ROOT_GLOB_FILES(_sources FILTER "LinkDef" ${ARGN})
set(${variable} ${_sources} PARENT_SCOPE)
endfunction()
#---------------------------------------------------------------------------------------------------
#---ROOT_GET_SOURCES( <variable> cwd <sources> ...)
#---------------------------------------------------------------------------------------------------
function(ROOT_GET_SOURCES variable cwd )
set(sources)
foreach( fp ${ARGN})
if( IS_ABSOLUTE ${fp})
file(GLOB files ${fp})
else()
if(root7)
set(root7glob v7/src/${fp})
endif()
file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${cwd}/${fp} ${root7glob})
endif()
if(files)
foreach(s ${files})
if(fp MATCHES "[*]" AND s MATCHES "(^|/)G__") # Eliminate G__* files
elseif(s MATCHES "${cwd}/G__")
set(sources ${fp} ${sources})
else()
set(sources ${sources} ${s})
endif()
endforeach()
else()
if(fp MATCHES "(^|/)G__")
set(sources ${fp} ${sources})
else()
set(sources ${sources} ${fp})
endif()
endif()
endforeach()
set(${variable} ${sources} PARENT_SCOPE)
endfunction()
#---------------------------------------------------------------------------------------------------
#---REFLEX_GENERATE_DICTIONARY( dictionary headerfiles SELECTION selectionfile OPTIONS opt1 opt2 ...
# DEPENDS dependency1 dependency2 ...
# )
# if dictionary is a TARGET (e.g., created with add_library), we inherit the INCLUDE_DIRECTORES and
# COMPILE_DEFINITIONS properties
#
#---------------------------------------------------------------------------------------------------
function(REFLEX_GENERATE_DICTIONARY dictionary)
CMAKE_PARSE_ARGUMENTS(ARG "" "SELECTION" "OPTIONS;DEPENDS" ${ARGN})
#---Get List of header files---------------
set(headerfiles)
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
file(GLOB files inc/${fp})
if(files)
foreach(f ${files})
if(NOT f MATCHES LinkDef)
set(headerfiles ${headerfiles} ${f})
endif()
endforeach()
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
set(headerfiles ${headerfiles} ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
else()
set(headerfiles ${headerfiles} ${fp})
endif()
endforeach()
#---Get Selection file------------------------------------
if(IS_ABSOLUTE ${ARG_SELECTION})
set(selectionfile ${ARG_SELECTION})
else()
set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION})
endif()
set(gensrcdict ${dictionary}.cxx)
#---roottest compability---------------------------------
if(CMAKE_ROOTTEST_NOROOTMAP)
set(rootmapname )
set(rootmapopts )
elseif(DEFINED CMAKE_ROOTTEST_NOROOTMAP) # Follow the roottest dictionary library naming
set(rootmapname ${dictionary}.rootmap)
set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}_dictrflx)
else()
set(rootmapname ${dictionary}Dict.rootmap)
set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict)
endif()
set(include_dirs ${CMAKE_CURRENT_SOURCE_DIR})
get_directory_property(incdirs INCLUDE_DIRECTORIES)
foreach(d ${incdirs})
if(NOT "${d}" MATCHES "^(AFTER|BEFORE|INTERFACE|PRIVATE|PUBLIC|SYSTEM)$")
list(APPEND include_dirs ${d})
endif()
endforeach()
get_directory_property(defs COMPILE_DEFINITIONS)
foreach( d ${defs})
list(APPEND definitions ${d})
endforeach()
IF(TARGET ${dictionary})
LIST(APPEND include_dirs $<TARGET_PROPERTY:${dictionary},INCLUDE_DIRECTORIES>)
# The COMPILE_DEFINITIONS list might contain empty elements. These are
# removed with the FILTER generator expression, excluding elements that
# match the ^$ regexp (only matches empty strings).
LIST(APPEND definitions "$<FILTER:$<TARGET_PROPERTY:${dictionary},COMPILE_DEFINITIONS>,EXCLUDE,^$>")
ENDIF()
add_custom_command(
OUTPUT ${gensrcdict} ${rootmapname}
COMMAND ${ROOT_genreflex_CMD}
ARGS ${headerfiles} -o ${gensrcdict} ${rootmapopts} --select=${selectionfile}
--gccxmlpath=${GCCXML_home}/bin ${ARG_OPTIONS}
"-I$<JOIN:$<REMOVE_DUPLICATES:$<FILTER:${include_dirs},EXCLUDE,^$>>,;-I>"
"$<$<BOOL:$<JOIN:${definitions},>>:-D$<JOIN:${definitions},;-D>>"
DEPENDS ${headerfiles} ${selectionfile} ${ARG_DEPENDS}
COMMAND_EXPAND_LISTS
)
IF(TARGET ${dictionary})
target_sources(${dictionary} PRIVATE ${gensrcdict})
ENDIF()
#---roottest compability---------------------------------
if(CMAKE_ROOTTEST_DICT)
ROOTTEST_TARGETNAME_FROM_FILE(targetname ${dictionary})
set(targetname "${targetname}-dictgen")
add_custom_target(${targetname} DEPENDS ${gensrcdict} ${ROOT_LIBRARIES})
else()
set(targetname "${dictionary}-dictgen")
# Creating this target at ALL level enables the possibility to generate dictionaries (genreflex step)
# well before the dependent libraries of the dictionary are build
add_custom_target(${targetname} ALL DEPENDS ${gensrcdict})
endif()
# FIXME: Do not set gensrcdict variable to the outer scope but use an argument to
# REFLEX_GENERATE_DICTIONARY passed from the outside. Note this would be a
# breaking change for roottest and other external users.
set(gensrcdict ${dictionary}.cxx PARENT_SCOPE)
endfunction()
#---------------------------------------------------------------------------------------------------
#---ROOT_GET_LIBRARY_OUTPUT_DIR( result_var )
# Returns the path to the .so file or .dll file. In the latter case Windows defines the dll files as
# executables and puts them in the $ROOTSYS/bin folder.
function(ROOT_GET_LIBRARY_OUTPUT_DIR result)
set(library_output_dir)
if(MSVC)
if(DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY AND NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY STREQUAL "")
set(library_output_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
else()
set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
else()
if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY AND NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY STREQUAL "")
set(library_output_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
else()
set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()
SET(${result} "${library_output_dir}" PARENT_SCOPE)
endfunction(ROOT_GET_LIBRARY_OUTPUT_DIR)
#---------------------------------------------------------------------------------------------------
#---ROOT_GET_INSTALL_DIR( result_var )
# Returns the path to the shared libraries installation directory. On Windows the pcms and rootmap
# files must go in the $ROOTSYS/bin folder.
function(ROOT_GET_INSTALL_DIR result)
set(shared_lib_install_dir)
if(MSVC)
set(shared_lib_install_dir ${CMAKE_INSTALL_BINDIR})
else()
set(shared_lib_install_dir ${CMAKE_INSTALL_LIBDIR})
endif()
SET(${result} "${shared_lib_install_dir}" PARENT_SCOPE)
endfunction(ROOT_GET_INSTALL_DIR)
#---------------------------------------------------------------------------------------------------
#---ROOT_REPLACE_BUILD_INTERFACE( include_dir_var include_dir )
# Update the `include_dir` variable after resolve the BUILD_INTERFACE
function(ROOT_REPLACE_BUILD_INTERFACE include_dir_var include_dir)
string(REGEX REPLACE "^[$]<BUILD_INTERFACE:(.+)>" "\\1" include_dir ${include_dir})
# BUILD_INTERFACE might contain space-separated paths. They are split by
# foreach, leaving a trailing 'include/something>'. Remove the trailing '>'.
string(REGEX REPLACE ">$" "" include_dir ${include_dir})
set(${include_dir_var} ${include_dir} PARENT_SCOPE)
endfunction(ROOT_REPLACE_BUILD_INTERFACE)
#---------------------------------------------------------------------------------------------------
#---ROOT_GENERATE_DICTIONARY( dictionary headerfiles NODEPHEADERS ghdr1 ghdr2 ...
# MODULE module DEPENDENCIES dep1 dep2
# BUILTINS dep1 dep2
# STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...)
#
# <dictionary> is the dictionary stem; the macro creates (among other files) the dictionary source as
# <dictionary>.cxx
# <headerfiles> are "as included"; set appropriate INCLUDE_DIRECTORIES property on the directory.
# The dictionary target depends on these headers. These files must exist.
# <NODEPHEADERS> same as <headerfiles>. If these files are not found (given the target include path)
# no error is emitted. The dictionary does not depend on these headers.
#---------------------------------------------------------------------------------------------------
function(ROOT_GENERATE_DICTIONARY dictionary)
CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT;NOINSTALL;NO_CXXMODULE"
"MODULE;LINKDEF" "NODEPHEADERS;OPTIONS;DEPENDENCIES;EXTRA_DEPENDENCIES;BUILTINS" ${ARGN})
# Check if OPTIONS start with a dash.
if (ARG_OPTIONS)
foreach(ARG_O ${ARG_OPTIONS})
if (NOT ARG_O MATCHES "^-*")
message(FATAL_ERROR "Wrong rootcling option: ${ARG_OPTIONS}")
endif()
endforeach()
endif(ARG_OPTIONS)
#---roottest compability---------------------------------
if(CMAKE_ROOTTEST_DICT)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_CURRENT_BINARY_DIR})
set(libprefix "")
endif()
# list of include directories for dictionary generation
set(incdirs)
if((CMAKE_PROJECT_NAME STREQUAL ROOT) AND (TARGET ${ARG_MODULE}))
set(headerdirs)
get_target_property(target_incdirs ${ARG_MODULE} INCLUDE_DIRECTORIES)
if(target_incdirs)
foreach(dir ${target_incdirs})
ROOT_REPLACE_BUILD_INTERFACE(dir ${dir})
# check that dir not a empty dir like $<BUILD_INTERFACE:>
if(NOT ${dir} MATCHES "^[$]")
list(APPEND incdirs ${dir})
string(FIND ${dir} "${CMAKE_SOURCE_DIR}" src_dir_in_dir)
if(${src_dir_in_dir} EQUAL 0)
list(APPEND headerdirs ${dir})
endif()
endif()
endforeach()
endif()
# Comments from Vassil:
# FIXME: We prepend ROOTSYS/include because if we have built a module
# and try to resolve the 'same' header from a different location we will
# get a redefinition error.
# We should remove these lines when the fallback include is removed. Then
# we will need a module.modulemap file per `inc` directory.
# Comments from Sergey:
# Remove all source dirs also while they preserved in root dictionaries and
# ends in the gInterpreter->GetIncludePath()
list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_SOURCE_DIR}")
list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_BINARY_DIR}/ginclude")
list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_BINARY_DIR}/externals")
list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_BINARY_DIR}/builtins")
list(INSERT incdirs 0 ${CMAKE_BINARY_DIR}/include)
# this instruct rootcling do not store such paths in dictionary
set(excludepaths ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/ginclude ${CMAKE_BINARY_DIR}/externals ${CMAKE_BINARY_DIR}/builtins)
set(headerfiles)
set(_list_of_header_dependencies)
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
if(IS_ABSOLUTE ${fp})
set(headerFile ${fp})
else()
find_file(headerFile ${fp}
HINTS ${headerdirs}
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_FIND_ROOT_PATH)
endif()
if(NOT headerFile)
message(FATAL_ERROR "Cannot find header ${fp} to generate dictionary ${dictionary} for. Did you forget to set the INCLUDE_DIRECTORIES property for the current directory?")
endif()
list(APPEND headerfiles ${fp})
list(APPEND _list_of_header_dependencies ${headerFile})
unset(headerFile CACHE) # find_file, forget headerFile!
endforeach()
foreach(fp ${ARG_NODEPHEADERS})
list(APPEND headerfiles ${fp})
# no dependency - think "vector" etc.
endforeach()
if(NOT (headerfiles OR ARG_LINKDEF))
message(FATAL_ERROR "No headers nor LinkDef.h supplied / found for dictionary ${dictionary}!")
endif()
else()
####################### old-style includes/headers generation - starts ##################
#---Get the list of include directories------------------
get_directory_property(incdirs INCLUDE_DIRECTORIES)
# rootcling invoked on foo.h should find foo.h in the current source dir,
# no matter what.
list(APPEND incdirs ${CMAKE_CURRENT_SOURCE_DIR})
if(TARGET ${ARG_MODULE})
get_target_property(target_incdirs ${ARG_MODULE} INCLUDE_DIRECTORIES)
if(target_incdirs)
foreach(dir ${target_incdirs})
ROOT_REPLACE_BUILD_INTERFACE(dir ${dir})
if(NOT ${dir} MATCHES "^[$]")
list(APPEND incdirs ${dir})
endif()
endforeach()
endif()
endif()
set(headerdirs_dflt)
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
list(APPEND headerdirs_dflt ${CMAKE_CURRENT_SOURCE_DIR}/inc)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc)
list(APPEND headerdirs_dflt ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc)
endif()
endif()
#---Get the list of header files-------------------------
# CMake needs dependencies from ${CMAKE_CURRENT_SOURCE_DIR} while rootcling wants
# header files "as included" (and thus as passed as argument to this CMake function).
set(headerfiles)
set(_list_of_header_dependencies)
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
if(${fp} MATCHES "[*?]") # Is this header a globbing expression?
file(GLOB files inc/${fp} ${fp}) # Elements of ${fp} have the complete path.
foreach(f ${files})
if(NOT f MATCHES LinkDef) # skip LinkDefs from globbing result
set(add_inc_as_include On)
string(REGEX REPLACE "^${CMAKE_CURRENT_SOURCE_DIR}/inc/" "" f_no_inc ${f})
list(APPEND headerfiles ${f_no_inc})
list(APPEND _list_of_header_dependencies ${f})
endif()
endforeach()
else()
if(IS_ABSOLUTE ${fp})
set(headerFile ${fp})
else()
set(incdirs_in_build)
set(incdirs_in_prefix ${headerdirs_dflt})
foreach(incdir ${incdirs})
string(FIND ${incdir} "${CMAKE_SOURCE_DIR}" src_dir_in_dir)
string(FIND ${incdir} "${CMAKE_BINARY_DIR}" bin_dir_in_dir)
string(FIND ${incdir} "${CMAKE_CURRENT_BINARY_DIR}" cur_dir_in_dir)
if(NOT IS_ABSOLUTE ${incdir}
OR ${src_dir_in_dir} EQUAL 0
OR ${bin_dir_in_dir} EQUAL 0
OR ${cur_dir_in_dir} EQUAL 0)
list(APPEND incdirs_in_build ${incdir})
else()
list(APPEND incdirs_in_prefix ${incdir})
endif()
endforeach()
if(incdirs_in_build)
find_file(headerFile ${fp}
HINTS ${incdirs_in_build}
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_FIND_ROOT_PATH)
endif()
# Try this even if NOT incdirs_in_prefix: might not need a HINT.
if(NOT headerFile)
find_file(headerFile ${fp}
HINTS ${incdirs_in_prefix}
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH)
endif()
endif()
if(NOT headerFile)
message(FATAL_ERROR "Cannot find header ${fp} to generate dictionary ${dictionary} for. Did you forget to set the INCLUDE_DIRECTORIES property for the current directory?")
endif()
list(APPEND headerfiles ${fp})
list(APPEND _list_of_header_dependencies ${headerFile})
unset(headerFile CACHE) # find_file, forget headerFile!
endif()
endforeach()
foreach(fp ${ARG_NODEPHEADERS})
list(APPEND headerfiles ${fp})
# no dependency - think "vector" etc.
endforeach()
if(NOT (headerfiles OR ARG_LINKDEF))
message(FATAL_ERROR "No headers nor LinkDef.h supplied / found for dictionary ${dictionary}!")
endif()
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
list(APPEND incdirs ${CMAKE_BINARY_DIR}/include)
list(APPEND incdirs ${CMAKE_BINARY_DIR}/etc/cling) # This is for the RuntimeUniverse
# list(APPEND incdirs ${CMAKE_SOURCE_DIR})
set(excludepaths ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
list(APPEND incdirs ${CMAKE_CURRENT_SOURCE_DIR}/inc)
endif()
foreach(dep ${ARG_DEPENDENCIES})
if(TARGET ${dep})
get_target_property(dep_include_dirs ${dep} INTERFACE_INCLUDE_DIRECTORIES)
if (NOT dep_include_dirs)
get_target_property(dep_include_dirs ${dep} INCLUDE_DIRECTORIES)
endif()
if (dep_include_dirs)
foreach(d ${dep_include_dirs})
list(APPEND incdirs ${d})
endforeach()
endif()
endif()
endforeach()
####################### old-style includes/headers generation - end ##################
endif()
#---Get the list of definitions---------------------------
get_directory_property(defs COMPILE_DEFINITIONS)
foreach( d ${defs})
if((NOT d MATCHES "=") AND (NOT d MATCHES "^[$]<.*>$")) # avoid generator expressions
set(definitions ${definitions} -D${d})
endif()
endforeach()
#---Get LinkDef.h file------------------------------------
foreach( f ${ARG_LINKDEF})
if( IS_ABSOLUTE ${f})
set(_linkdef ${_linkdef} ${f})
else()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
else()
set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/${f})
endif()
endif()
endforeach()
#---Build the names for library, pcm and rootmap file ----
set(library_target_name)
if(dictionary MATCHES "^G__")
string(REGEX REPLACE "^G__(.*)" "\\1" library_target_name ${dictionary})
if (ARG_MULTIDICT)
string(REGEX REPLACE "(.*)32$" "\\1" library_target_name ${library_target_name})
endif (ARG_MULTIDICT)
else()
get_filename_component(library_target_name ${dictionary} NAME_WE)
endif()
if (ARG_MODULE)
if (NOT ${ARG_MODULE} STREQUAL ${library_target_name})
# message(AUTHOR_WARNING "The MODULE argument ${ARG_MODULE} and the deduced library name "
# "${library_target_name} mismatch. Deduction stem: ${dictionary}.")
set(library_target_name ${ARG_MODULE})
endif()
endif(ARG_MODULE)
#---Set the library output directory-----------------------
ROOT_GET_LIBRARY_OUTPUT_DIR(library_output_dir)
set(runtime_cxxmodule_dependencies )
set(cpp_module)
set(library_name ${libprefix}${library_target_name}${libsuffix})
set(newargs -s ${library_output_dir}/${library_name})
set(rootmap_name ${library_output_dir}/${libprefix}${library_target_name}.rootmap)
set(pcm_name ${library_output_dir}/${libprefix}${library_target_name}_rdict.pcm)
if(ARG_MODULE)
if(ARG_MULTIDICT)
set(newargs ${newargs} -multiDict)
set(pcm_name ${library_output_dir}/${libprefix}${library_target_name}_${dictionary}_rdict.pcm)
set(rootmap_name ${library_output_dir}/${libprefix}${library_target_name}32.rootmap)
else()
set(cpp_module ${library_target_name})
endif(ARG_MULTIDICT)
if(runtime_cxxmodules)
# If we specify NO_CXXMODULE we should be able to still install the produced _rdict.pcm file.
if(NOT ARG_NO_CXXMODULE)
set(pcm_name)
endif()
if(cpp_module)
set(cpp_module_file ${library_output_dir}/${cpp_module}.pcm)
# The module depends on its modulemap file.
if (cpp_module_file AND CMAKE_PROJECT_NAME STREQUAL ROOT)
set (runtime_cxxmodule_dependencies "${CMAKE_BINARY_DIR}/include/ROOT.modulemap")
endif()
endif(cpp_module)
endif()
endif()
# modules.idx deps
get_property(local_modules_idx_deps GLOBAL PROPERTY modules_idx_deps_property)
get_property(local_no_cxxmodules GLOBAL PROPERTY no_cxxmodules_property)
if (ARG_NO_CXXMODULE)
list(APPEND local_no_cxxmodules ${cpp_module})
set_property(GLOBAL PROPERTY no_cxxmodules_property "${local_no_cxxmodules}")
unset(cpp_module)
unset(cpp_module_file)
else()
list(APPEND local_modules_idx_deps ${cpp_module})
set_property(GLOBAL PROPERTY modules_idx_deps_property "${local_modules_idx_deps}")
endif(ARG_NO_CXXMODULE)
if(CMAKE_ROOTTEST_NOROOTMAP OR cpp_module_file)
set(rootmap_name)
set(rootmapargs)
else()
set(rootmapargs -rml ${library_name} -rmf ${rootmap_name})
endif()
#---Get the library and module dependencies-----------------
if(ARG_DEPENDENCIES)
foreach(dep ${ARG_DEPENDENCIES})
if(NOT TARGET G__${dep})
# This is a library that doesn't come with dictionary/pcm
continue()
endif()
set(dependent_pcm ${libprefix}${dep}_rdict.pcm)
if (runtime_cxxmodules AND NOT dep IN_LIST local_no_cxxmodules)
set(dependent_pcm ${dep}.pcm)
if(TARGET ${dep})
get_target_property(_dep_pcm_filename ${dep} ROOT_PCM_FILENAME)
if(_dep_pcm_filename)
list(APPEND pcm_dependencies ${_dep_pcm_filename})
endif()
endif()
endif()
set(newargs ${newargs} -m ${dependent_pcm})
endforeach()
endif()
if(cpp_module_file)
set(newargs -cxxmodule ${newargs})
endif()
#---what rootcling command to use--------------------------
if(ARG_STAGE1)
set(command $<TARGET_FILE:rootcling_stage1>)
set(ROOTCINTDEP rconfigure)
set(pcm_name)
else()
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
if(MSVC AND CMAKE_ROOTTEST_DICT)
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe -rootbuild)
else()
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" $<TARGET_FILE:rootcling> -rootbuild)
# Modules need RConfigure.h copied into include/.
set(ROOTCINTDEP rootcling rconfigure)
endif()
elseif(TARGET ROOT::rootcling)
set(command $<TARGET_FILE:ROOT::rootcling>)
else()
set(command rootcling)
endif()
endif()
#---build the path exclusion switches----------------------
set(excludepathsargs "")
foreach(excludepath ${excludepaths})
set(excludepathsargs ${excludepathsargs} -excludePath ${excludepath})
endforeach()
#---build the implicit dependencies arguments
# NOTE: only the Makefile generator respects this!
foreach(_dep ${_linkdef} ${_list_of_header_dependencies})
list(APPEND _implicitdeps CXX ${_dep})
endforeach()
if(ARG_MODULE)
set(MODULE_LIB_DEPENDENCY ${ARG_DEPENDENCIES})
# get target properties added after call to ROOT_GENERATE_DICTIONARY()
if(TARGET ${ARG_MODULE})
# NOTE that module_sysincs is already part of ${module_sysincs}. But -isystem "wins",
# and list exclusion for generator expressions is too complex.
set(module_incs $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${ARG_MODULE},INCLUDE_DIRECTORIES>>)
set(module_sysincs $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${ARG_MODULE},INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>>)
# The COMPILE_DEFINITIONS list might contain empty elements. These are
# removed with the FILTER generator expression, excluding elements that
# match the ^$ regexp (only matches empty strings).
set(module_defs "$<FILTER:$<TARGET_PROPERTY:${ARG_MODULE},COMPILE_DEFINITIONS>,EXCLUDE,^$>")
endif()
endif()
# provide list of includes for dictionary
set(includedirs)
if(incdirs)
list(REMOVE_DUPLICATES incdirs)
foreach(dir ${incdirs})
if (NOT ${dir} MATCHES "^\\$<INSTALL_INTERFACE:")
list(APPEND includedirs -I${dir})
endif()
endforeach()
endif()
set(compIncPaths)
foreach(implinc IN LISTS CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)
list(APPEND compIncPaths "-compilerI${implinc}")
endforeach()
if(cpp_module_file AND TARGET ${ARG_MODULE})
set_target_properties(${ARG_MODULE} PROPERTIES
ROOT_PCM_FILENAME "${cpp_module_file}")
endif()
#---call rootcint------------------------------------------
add_custom_command(
OUTPUT ${dictionary}.cxx ${pcm_name} ${rootmap_name} ${cpp_module_file}
COMMAND ${command} -v2 -f ${dictionary}.cxx ${newargs} ${excludepathsargs} ${rootmapargs}
${ARG_OPTIONS}
${definitions} "$<$<BOOL:${module_defs}>:-D$<JOIN:${module_defs},;-D>>"
${compIncPaths}
"$<$<BOOL:${module_sysincs}>:-isystem;$<JOIN:${module_sysincs},;-isystem;>>"
${includedirs} "$<$<BOOL:${module_incs}>:-I$<JOIN:${module_incs},;-I>>"
${headerfiles} ${_linkdef}
# Add random dummy macro including the CMAKE_CXX_STANDARD variable. This the easiest way to
# make the dictionary generation command depend on the C++ standard, ensuring that the
# dictionaries will be rebuilt if the C++ standard is changed in an incremental build.
-DR__DUMMY_CXX_STANDARD_${CMAKE_CXX_STANDARD}
IMPLICIT_DEPENDS ${_implicitdeps}
DEPENDS ${_list_of_header_dependencies} ${_linkdef} ${ROOTCINTDEP}
${pcm_dependencies}
${MODULE_LIB_DEPENDENCY} ${ARG_EXTRA_DEPENDENCIES}
${runtime_cxxmodule_dependencies}
${cxx_std_stamp}
COMMAND_EXPAND_LISTS
)
# If we are adding to an existing target and it's not the dictionary itself,
# we make an object library and add its output object file as source to the target.
# This works around bug https://cmake.org/Bug/view.php?id=14633 in CMake by keeping
# the generated source at the same scope level as its owning target, something that
# would not happen if we used target_sources() directly with the dictionary source.
if(TARGET "${ARG_MODULE}" AND NOT "${ARG_MODULE}" STREQUAL "${dictionary}")
add_library(${dictionary} OBJECT ${dictionary}.cxx)
set_target_properties(${dictionary} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
target_link_libraries(${ARG_MODULE} PRIVATE ${dictionary})
target_compile_options(${dictionary} PRIVATE
$<TARGET_PROPERTY:${ARG_MODULE},COMPILE_OPTIONS>)
target_compile_definitions(${dictionary} PRIVATE
${definitions} $<TARGET_PROPERTY:${ARG_MODULE},COMPILE_DEFINITIONS>)
target_compile_features(${dictionary} PRIVATE
$<TARGET_PROPERTY:${ARG_MODULE},COMPILE_FEATURES>)
target_include_directories(${dictionary} PRIVATE ${incdirs} $<TARGET_PROPERTY:${ARG_MODULE},INCLUDE_DIRECTORIES>)
# Above we are copying all include directories of the module, irrespective of whether they are system includes.
# CMake copies them as -I even when they should be -isystem.
# We can fix this for INTERFACE includes by also copying the respective property.
# For PRIVATE includes this doesn't work. In that case, one needs to link both the library as well as the dictionary explicitly:
# target_link_libraries(MODULE PRIVATE dependency)
# target_link_libraries(G__MODULE PRIVATE dependency)
set_property(TARGET ${dictionary} APPEND PROPERTY
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:${ARG_MODULE},INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>)
else()
get_filename_component(dictionary_name ${dictionary} NAME)
add_custom_target(${dictionary_name} DEPENDS ${dictionary}.cxx ${pcm_name} ${rootmap_name} ${cpp_module_file})
endif()
if(PROJECT_NAME STREQUAL "ROOT")
set_property(GLOBAL APPEND PROPERTY ROOT_PCH_DEPENDENCIES ${dictionary})
set_property(GLOBAL APPEND PROPERTY ROOT_PCH_DICTIONARIES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cxx)
endif()
if(ARG_MULTIDICT)
if(NOT TARGET "G__${ARG_MODULE}")
message(FATAL_ERROR
" Target G__${ARG_MODULE} not found!\n"
" Please create target G__${ARG_MODULE} before using MULTIDICT.")
endif()
add_dependencies(G__${ARG_MODULE} ${dictionary})
endif()
if(NOT ARG_NOINSTALL AND NOT CMAKE_ROOTTEST_DICT AND DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
ROOT_GET_INSTALL_DIR(shared_lib_install_dir)
# Install the C++ module if we generated one.
if (cpp_module_file)
install(FILES ${cpp_module_file}
DESTINATION ${shared_lib_install_dir} COMPONENT libraries)
endif()
if(ARG_STAGE1)
install(FILES ${rootmap_name}
DESTINATION ${shared_lib_install_dir} COMPONENT libraries)
else()
install(FILES ${pcm_name} ${rootmap_name}
DESTINATION ${shared_lib_install_dir} COMPONENT libraries)
endif()
endif()
if(ARG_BUILTINS)
foreach(arg1 ${ARG_BUILTINS})
if(TARGET ${${arg1}_TARGET})
add_dependencies(${dictionary} ${${arg1}_TARGET})
endif()
endforeach()
endif()
# FIXME: Support mulptiple dictionaries. In some cases (libSMatrix and
# libGenVector) we have to have two or more dictionaries (eg. for math,
# we need the two for double vs Double32_t template specializations).
# In some other cases, eg. libTreePlayer.so we add in a separate dictionary
# files which for some reason (temporarily?) cannot be put in the PCH. Eg.
# all rest of the first dict is in the PCH but this file is not and it
# cannot be present in the original dictionary.
if(cpp_module)
ROOT_CXXMODULES_APPEND_TO_MODULEMAP("${cpp_module}" "${headerfiles}")
endif()
endfunction(ROOT_GENERATE_DICTIONARY)
#---------------------------------------------------------------------------------------------------
#---ROOT_CXXMODULES_APPEND_TO_MODULEMAP( library library_headers )
#---------------------------------------------------------------------------------------------------
function (ROOT_CXXMODULES_APPEND_TO_MODULEMAP library library_headers)
ROOT_FIND_DIRS_WITH_HEADERS(dirs)
set(found_headers "")
set(dir_headers "")
foreach(d ${dirs})
ROOT_GLOB_FILES(dir_headers
RECURSE
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${d}
FILTER "LinkDef" ${d}/*)
list(APPEND found_headers "${dir_headers}")
endforeach()
set(excluded_headers RConfig.h RVersion.h core/foundation/inc/ROOT/RVersion.hxx RtypesImp.h
RtypesCore.h TClassEdit.h
TIsAProxy.h TVirtualIsAProxy.h
DllImport.h ESTLType.h Varargs.h
ThreadLocalStorage.h
TBranchProxyTemplate.h TGLWSIncludes.h
snprintf.h strlcpy.h)
# Deprecated header files.
set (excluded_headers "${excluded_headers}")
set(modulemap_entry "module \"${library}\" {")
# Add a `use` directive to Core/Thread to signal that they use some
# split out submodules and we pass the rootcling integrity check.
if ("${library}" STREQUAL Core)
set (modulemap_entry "${modulemap_entry}\n use ROOT_Foundation_Stage1_NoRTTI\n")
set (modulemap_entry "${modulemap_entry}\n use ROOT_Foundation_C\n")
elseif ("${library}" STREQUAL Thread)
set (modulemap_entry "${modulemap_entry}\n use ROOT_Foundation_C\n")
endif()
# For modules GCocoa and GQuartz we need objc and cplusplus context.
if (NOT ${library} MATCHES "GCocoa")
set (modulemap_entry "${modulemap_entry}\n requires cplusplus\n")
endif()
if (library_headers)
set(found_headers ${library_headers})
endif()
foreach(header ${found_headers})
set(textual_header "")
if (${header} MATCHES ".*\\.icc$")
set(textual_header "textual ")
endif()
# Check if header is in included header list
set(is_excluded NO)
foreach(excluded_header ${excluded_headers})
if(${header} MATCHES ${excluded_header})
set(is_excluded YES)
break()
endif()
endforeach()
if(NOT is_excluded)
set(modulemap_entry "${modulemap_entry} module \"${header}\" { ${textual_header}header \"${header}\" export * }\n")
endif()
endforeach()
set(modulemap_entry "${modulemap_entry} link \"${libprefix}${library}${libsuffix}\"\n")
set(modulemap_entry "${modulemap_entry} export *\n}\n\n")
# Non ROOT projects need a modulemap generated for them in the current
# directory. The same happens with test dictionaries in ROOT which are not
# exposed via the main modulemap. This is exposed by setting the
# ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR.
if (NOT "${CMAKE_PROJECT_NAME}" STREQUAL ROOT OR ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR)
set(modulemap_output_file "${CMAKE_CURRENT_BINARY_DIR}/module.modulemap")
# It's possible that multiple modulemaps are needed in the current
# directory and we need to merge them. As we don't want to have multiple
# modules in the same moduluemap when rerunning CMake, we do a quick
# check if the current module is already in the modulemap (in which case
# we know we rerun CMake at the moment and start writing a new modulemap
# instead of appending new modules).
# The string we use to identify if the current module is already in the
# modulemap.
set(modulemap_needle "module \"${library}\"")
# Check if the needle is in the modulemap. If the file doesn't exist
# we just pretend we didn't found the string in the modulemap.
set(match_result -1)
if (EXISTS "${modulemap_output_file}")
file(READ "${modulemap_output_file}" existing_contents)
string(FIND "${existing_contents}" "${modulemap_needle}" match_result)
endif()
# Append our new module to the existing modulemap containing other modules.
if(${match_result} EQUAL -1)
file(APPEND "${modulemap_output_file}" "${modulemap_entry}")
else()
file(WRITE "${modulemap_output_file}" "${modulemap_entry}")
endif()
# Sanity check that the string we're looking for is actually in the content
# we're writing to this file.
string(FIND "${modulemap_entry}" "${modulemap_needle}" match_result)
if(${match_result} EQUAL -1)
message(AUTHOR_WARNING "Couldn't find module declaration in modulemap file."
"This would break the modulemap generation when "
" rerunning CMake. Module needle was "
"'${modulemap_needle}' and the content was '${modulemap_entry}'")
endif()
else()
set_property(GLOBAL APPEND PROPERTY ROOT_CXXMODULES_EXTRA_MODULEMAP_CONTENT ${modulemap_entry})
endif()
endfunction()
#---------------------------------------------------------------------------------------------------
#---ROOT_LINKER_LIBRARY( <name> source1 source2 ...[TYPE STATIC|SHARED] [DLLEXPORT]
# [NOINSTALL]
# LIBRARIES library1 library2 ... # PRIVATE link dependencies
# DEPENDENCIES dep1 dep2 # PUBLIC link dependencies
# BUILTINS dep1 dep2 # dependencies to builtins)
#---------------------------------------------------------------------------------------------------
function(ROOT_LINKER_LIBRARY library)
CMAKE_PARSE_ARGUMENTS(ARG "DLLEXPORT;CMAKENOEXPORT;TEST;NOINSTALL" "TYPE" "LIBRARIES;DEPENDENCIES;BUILTINS" ${ARGN})
ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS})
if(NOT ARG_TYPE)
set(ARG_TYPE SHARED)
endif()
if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL
set(_all EXCLUDE_FROM_ALL)
endif()
if(TARGET ${library})
message(FATAL_ERROR "Target ${library} already exists.")
endif()
if(WIN32 AND ARG_TYPE STREQUAL SHARED AND NOT ARG_DLLEXPORT)
#---create a shared library with the .def file------------------------
add_library(${library} ${_all} SHARED ${lib_srcs})
else()
add_library( ${library} ${_all} ${ARG_TYPE} ${lib_srcs})
if(ARG_TYPE STREQUAL SHARED)
set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} )
endif()
endif()
set_target_properties(${library} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
if(DEFINED CMAKE_CXX_STANDARD)
target_compile_features(${library} INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
endif()
# Add dependencies passed via LIBRARIES or DEPENDENCIES argument:
target_link_libraries(${library} PUBLIC ${ARG_DEPENDENCIES})
target_link_libraries(${library} PRIVATE ${ARG_LIBRARIES})
if(TARGET G__${library})
add_dependencies(${library} G__${library})
endif()
set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library})
ROOT_ADD_INCLUDE_DIRECTORIES(${library})
if(PROJECT_NAME STREQUAL "ROOT")
add_dependencies(${library} move_headers)
if(NOT TARGET ROOT::${library})
add_library(ROOT::${library} ALIAS ${library})
endif()
endif()
set_target_properties(${library} PROPERTIES
PREFIX ${libprefix}
IMPORT_PREFIX ${libprefix} # affects the .lib import library (MSVC)
)
target_include_directories(${library} INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# Do not add -Dname_EXPORTS to the command-line when building files in this
# target. Doing so is actively harmful for the modules build because it
# creates extra module variants, and not useful because we don't use these
# macros.
set_target_properties(${library} PROPERTIES DEFINE_SYMBOL "")
if(ARG_BUILTINS)
foreach(arg1 ${ARG_BUILTINS})
if(${arg1}_TARGET)
add_dependencies(${library} ${${arg1}_TARGET})
endif()
endforeach()
endif()
#----Installation details-------------------------------------------------------
if(NOT ARG_TEST AND NOT ARG_NOINSTALL AND CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(NOT MSVC)
ROOT_APPEND_LIBDIR_TO_INSTALL_RPATH(${library} ${CMAKE_INSTALL_LIBDIR})
endif()
if(ARG_CMAKENOEXPORT)
install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
else()
install(TARGETS ${library} EXPORT ${CMAKE_PROJECT_NAME}Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
if(WIN32 AND ARG_TYPE STREQUAL SHARED)
install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib${library}.pdb
CONFIGURATIONS Debug RelWithDebInfo
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT libraries)
endif()
else()
# If the target is not installed, it doesn't make sense to build it with the INSTALL_RPATH
set_property(TARGET ${library} PROPERTY BUILD_WITH_INSTALL_RPATH OFF)
endif()
endfunction()
#---------------------------------------------------------------------------------------------------