File: dcmtkPatchScript.cmake

package info (click to toggle)
insighttoolkit4 4.13.3withdata-dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 491,256 kB
  • sloc: cpp: 557,600; ansic: 180,546; fortran: 34,788; python: 16,572; sh: 2,187; lisp: 2,070; tcl: 993; java: 362; perl: 200; makefile: 133; csh: 81; pascal: 69; xml: 19; ruby: 10
file content (77 lines) | stat: -rw-r--r-- 2,303 bytes parent folder | download | duplicates (6)
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
set(dcmtk3rdParty ${dcmtkSource}/CMake/3rdparty.cmake)

#
# Newer versions of TIFF depend on JPEG
file(READ ${dcmtk3rdParty} code)
string(REPLACE "SET(LIBTIFF_LIBS \${TIFF_LIBRARY})
"
"SET(LIBTIFF_LIBS \${TIFF_LIBRARY})
    list(APPEND LIBTIFF_LIBS \${JPEG_LIBRARY})
" code "${code}")
#
# we pass in the TIFF and ZLIB library stuff,
# running find_package for those libraries
# screws up using the ITK versions
if(NOT ITK_USE_SYSTEM_TIFF)
  string(REPLACE "FIND_PACKAGE(TIFF)
" "" code "${code}")
endif()

if(NOT ITK_USE_SYSTEM_ZLIB)
string(REPLACE "FIND_PACKAGE(ZLIB)
" "" code "${code}")
endif()

file(WRITE ${dcmtk3rdParty} "${code}")

#
# in order to use the ITK versions of ZLIB and TIFF
# it is necessary to use the ITK symbol-mangled versions
file(GLOB_RECURSE dcmtk_src RELATIVE ${dcmtkSource} "*.cc" "*.h")

foreach (filename ${dcmtk_src})
  set(_filename ${dcmtkSource}/${filename})
  #  message("patching ${_filename}")
  file(READ ${_filename} sourcecode)
  if(NOT ITK_USE_SYSTEM_ZLIB)
    string(REPLACE "<zlib.h>"
      "\"itk_zlib.h\"" sourcecode "${sourcecode}")
  endif()
  if(NOT ITK_USE_SYSTEM_TIFF)
    string(REPLACE "<tiffio.h>"
      "\"itk_tiff.h\"" sourcecode "${sourcecode}")
  endif()
  file(WRITE ${_filename} "${sourcecode}")
endforeach(filename)

#
# suppress building the applications
file(GLOB_RECURSE dcmtk_cmakelists RELATIVE ${dcmtkSource} "CMakeLists.txt")

foreach(cmakelists ${dcmtk_cmakelists})
  set(_cmakelists ${dcmtkSource}/${cmakelists})
  message("CMakeLists ${_cmakelists}")
  file(READ ${_cmakelists} source)
  string(REGEX REPLACE
    "SUBDIRS\\((.*) apps "
    "SUBDIRS(\\1 "
    source
    "${source}")
  file(WRITE ${_cmakelists} "${source}")
endforeach(cmakelists)

#
# To get libraries to be built in the ITK lib directory,
# have to kill the stuff in the main CMakeLists.txt that
# changes target destinations
set(dcmtkCmakeLists_txt ${dcmtkSource}/CMakeLists.txt)

file(READ ${dcmtkCmakeLists_txt} cmakelists)

string(REPLACE "# build output files in these directories
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"\${CMAKE_BINARY_DIR}/lib\")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY \"\${CMAKE_BINARY_DIR}/lib\")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_BINARY_DIR}/bin\")
"
"" cmakelists "${cmakelists}")
file(WRITE ${dcmtkCmakeLists_txt} "${cmakelists}")