File: CMakeLists.txt

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (120 lines) | stat: -rw-r--r-- 4,587 bytes parent folder | download | duplicates (3)
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
#-----------------------------------------------------------------------------
# DICOM dictionary stuff

#-----------------------------------------------------------------------------
# Generate our own 'DICOM' dictionary, based on the following dictionaries:
SET(ALL_DICTS
  dicomV3.dic
  Papyrus.dic
  NIH.dic     #the forbidden one...
  SPI.dic
  #  PHILIPS-Intera.dic # uncomment me if you want
  )

# Better solution
SET(TEST_DICT_BODY)
FOREACH(dict ${ALL_DICTS})
  # Properly set dependencies, therefore `touch Philips-Intera.dic` does not rebuild
  # but adding/removing a line in Philips-Intera.dic rebuild as expected
  CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/${dict}"
       "${GDCM_BINARY_DIR}/Dicts/${dict}" COPYONLY IMMEDIATE)
  FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
  SET(TEST_DICT_BODY "${TEST_DICT_BODY}\n${dict_append}")
ENDFOREACH(dict)
CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/gdcm.dic.in"
  "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" @ONLY IMMEDIATE)

#-----------------------------------------------------------------------------
# Nice trick to avoid creating a .h file each time we compile gdcm
# Since CONFIGURE_FILE do a 'copy if different'
# We have to write the file here since is contains 'DICOM_DICTIONARY'
# Which is a variable afterward...

# Following code contributing by Andy Cedilnik (Kitware)
FILE(READ "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ENT)
STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
SET(DICOM_DATA_DICTIONARY "")

FOREACH(line ${ENT})
  STRING(REGEX REPLACE
    "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([A-Z]+) ([1-9n-]+) (.*)$"
    "   {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
  SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
ENDFOREACH(line)

SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n {0,0,0,0,0}")

#-----------------------------------------------------------------------------
# ... for DicomTS file
FILE(READ "dicomTS.dic" ENT_TS)
STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
SET(DICOM_TS_DICTIONARY "")

FOREACH(line ${ENT_TS})
  STRING(REGEX REPLACE
    "^([0-9.]+) +(.*)$"
    "  ts[\"\\1\"] = \"\\2\"; " nline "${line}")
  SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
ENDFOREACH(line)

#-----------------------------------------------------------------------------
# ... for DicomVR file
FILE(READ "dicomVR.dic" ENT_VR)
STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
STRING(REGEX REPLACE "\r?\n" ";" ENT_VR "${ENT_VR}")
SET(DICOM_VR_DICTIONARY "")

FOREACH(line ${ENT_VR})
  STRING(REGEX REPLACE
    "^([A-Z][A-Z]) (.*)/ +//.*$"
    "  vr[\"\\1\"] = \"\\2\"; " nline "${line}")
  SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
ENDFOREACH(line)

#-----------------------------------------------------------------------------
# ... for DictGroupName file
FILE(READ "DictGroupName.dic" ENT_TS)
STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
SET(DICT_GROUP_NAME_DICTIONARY "")

FOREACH(line ${ENT_TS})
  STRING(REGEX REPLACE
    "^([0-9a-f]+) +(.*)$"
    "  groupName[0x\\1] = \\2; " nline "${line}")
  SET(DICT_GROUP_NAME_DICTIONARY "${DICT_GROUP_NAME_DICTIONARY}\n${nline}")
ENDFOREACH(line)

#-----------------------------------------------------------------------------
# ... for DicomDir file
FILE(READ "DicomDir.dic" ENT_DIR)
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
STRING(REGEX REPLACE "\r?\n" ";" ENT_DIR "${ENT_DIR}")
SET(DICOM_DIR_DICTIONARY "")

FOREACH(line ${ENT_DIR})
  STRING(REGEX REPLACE
    "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"](.*)$"
    "  {\"\\1\" , 0x\\2 , 0x\\3 , \"\\4\"}, \\5" nline "${line}")
  SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
ENDFOREACH(line)

#-----------------------------------------------------------------------------
# ... Set the dictionnary
SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n {0,0,0,0}")

CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in"
  "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)

#-----------------------------------------------------------------------------
INSTALL(FILES
  ${GDCM_BINARY_DIR}/Dicts/dicomV3.dic
  ${GDCM_SOURCE_DIR}/Dicts/dicomVR.dic
  ${GDCM_SOURCE_DIR}/Dicts/dicomTS.dic
  ${GDCM_SOURCE_DIR}/Dicts/DicomDir.dic
  ${GDCM_SOURCE_DIR}/Dicts/DictGroupName.dic
  ${GDCM_BINARY_DIR}/Dicts/gdcm.dic
  DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/gdcm/Dicts
  COMPONENT RuntimeLibraries
  )