File: igc_pch_reuse.cmake

package info (click to toggle)
intel-graphics-compiler2 2.16.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 106,644 kB
  • sloc: cpp: 805,640; lisp: 287,672; ansic: 16,414; python: 3,952; yacc: 2,588; lex: 1,666; pascal: 313; sh: 186; makefile: 35
file content (116 lines) | stat: -rw-r--r-- 4,259 bytes parent folder | download | duplicates (2)
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
#=========================== begin_copyright_notice ============================
#
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
#============================ end_copyright_notice =============================
# Set precompiled header files for Windows builds
if(MSVC)
message(STATUS "Using precompiled headers")
  set(PCHTargets
    PCH             #0
    Compiler        #1
    AdaptorOCL      #2
    igc_metric      #6
    zebinlib        #7
    VISALinkerDriver#8
    BiFMangler      #9
    Probe           #11
    GenISAIntrinsics#12
    GenX_IR         #13
    GenXDebugInfo   #14
    ${IGC_BUILD__PROJ__igc_lib} #15
    BiFManager #16
  )

  if(IGC_BUILD__VC_ENABLED)
    list(APPEND PCHTargets VCIGCDeps)   #17
  endif()

  if(IGC_BUILD__VULKAN_FRONTEND_ENABLED)
    list(APPEND PCHTargets VulkanFrontend)  #18
  endif()

  #setting reuse indexs
  set(index 0)
  set(reuse_ind 1 2 3 4 5 6 7 8 9 10 14 16)
  #collecting options and definitions pools
  set(opt_list  "")
  set(def_list  "")
  foreach(_target ${PCHTargets})
    # matching reuse index
    set(ind_found FALSE)
    foreach(elem ${reuse_ind})
      if(${elem} EQUAL ${index})
        set(ind_found TRUE)
      endif()
    endforeach()
    # append to list if it is our reuse target
    if(${ind_found})
      get_target_property(OPTIONS ${_target} COMPILE_OPTIONS)
      get_target_property(DEFINITIONS ${_target} COMPILE_DEFINITIONS)
      list(APPEND opt_list ${OPTIONS})
      list(APPEND def_list ${DEFINITIONS})
    endif()
    math(EXPR index "${index} + 1")
  endforeach()

  #remove redundent ones
  list(REMOVE_DUPLICATES opt_list)
  list(REMOVE_DUPLICATES def_list)
  list(REMOVE_ITEM def_list "DEFINITIONS-NOTFOUND")

  #remove redundent ones
  set(index 0) #reinitialize index
  foreach(_target ${PCHTargets})
    add_dependencies(${_target}
      intrinsics_gen # generate *inc files for llvm/IR/Attributes.h
      IntrinsicDefintionGenerator # generate IntrinsicGenISA.gen for GenIntrinsicEnum.h
    )
    # matching reuse index
    set(ind_found FALSE)
    foreach(elem ${reuse_ind})
      if(${elem} EQUAL ${index})
        set(ind_found TRUE)
      endif()
    endforeach()
    if(NOT ${ind_found}) # building PCH
        # setting up for target PCH
        if(index EQUAL 0)
          # matching definitions
          set(diff_defs ${def_list})
          get_target_property(TARGET_COMPILE_DEFINITIONS ${_target} COMPILE_DEFINITIONS) # get current target definition list
          list(REMOVE_ITEM diff_defs ${TARGET_COMPILE_DEFINITIONS}) # remove common ones
          target_compile_definitions(${_target} PUBLIC ${diff_defs})   # apply different ones

          # matching options
          set(diff_opts ${opt_list}) #  copy a opt_list for different list
          get_target_property(TARGET_COMPILE_OPTIONS ${_target} COMPILE_OPTIONS) # get current target option list
          list(REMOVE_ITEM diff_opts ${TARGET_COMPILE_OPTIONS}) # remove common ones
          target_compile_options(${_target} PUBLIC ${diff_opts})   # apply different ones
        endif()
        #building PCH for not reuse targets
        target_precompile_headers(${_target}
          PRIVATE
          "$<$<COMPILE_LANGUAGE:CXX>:${IGC_BUILD__IGC_SRC_DIR}/PCH/llvm.h>"
          "$<$<COMPILE_LANGUAGE:CXX>:${IGC_BUILD__IGC_SRC_DIR}/PCH/common.h>"
        )
    else() # reuse PCH
      # matching definitions for reuse targets
      set(diff_defs ${def_list})
      get_target_property(TARGET_COMPILE_DEFINITIONS ${_target} COMPILE_DEFINITIONS) # get current target definition list
      list(REMOVE_ITEM diff_defs ${TARGET_COMPILE_DEFINITIONS}) # remove common ones
      target_compile_definitions(${_target} PUBLIC ${diff_defs})   # apply different ones

      set(diff_opts ${opt_list}) #  copy a opt_list for different list
      get_target_property(TARGET_COMPILE_OPTIONS ${_target} COMPILE_OPTIONS) # get current target option list
      list(REMOVE_ITEM diff_opts ${TARGET_COMPILE_OPTIONS}) # remove common ones
      target_compile_options(${_target} PUBLIC ${diff_opts})   # apply different ones

      target_precompile_headers(${_target} REUSE_FROM PCH)  # reuse PCH
    endif()
    math(EXPR index "${index} + 1") #update index
  endforeach()
endif()