Skip to content

Commit 60bbc16

Browse files
authored
Merge pull request #153 from melrobin/build_fix
Attempt to fix USE_SYSTEM_ITK
2 parents d045766 + 5e3a8f2 commit 60bbc16

8 files changed

Lines changed: 119 additions & 45 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
set(ITK_OLDEST_VALIDATED_POLICIES_VERSION "3.16.3")
2-
set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.19.7")
1+
set(ITK_OLDEST_VALIDATED_POLICIES_VERSION "3.22.1")
2+
set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.29.0")
33
cmake_minimum_required(VERSION ${ITK_OLDEST_VALIDATED_POLICIES_VERSION}...${ITK_NEWEST_VALIDATED_POLICIES_VERSION} FATAL_ERROR)
44

55
set(PRIMARY_PROJECT_NAME ITKSoftwareGuide)

Latex/Insight.sty

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%
2-
% Insight.sty for the Insight documentation [works only with with Latex2e]
2+
% Insight.sty for the Insight documentation [works only with Latex2e]
33
%
44

55
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
@@ -1079,7 +1079,7 @@
10791079

10801080

10811081
% Definition lists; requested by AMK for HOWTO documents. Probably useful
1082-
% elsewhere as well, so keep in in the general style support.
1082+
% elsewhere as well, so keep in the general style support.
10831083
%
10841084
\newenvironment{definitions}{%
10851085
\begin{description}%

Latex/doubleWordCheck.pl

Lines changed: 0 additions & 17 deletions
This file was deleted.

Latex/doubleWordCheck.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Search for doubled words in text
4+
5+
Behavior:
6+
- Reads one or more files (or stdin if none).
7+
- Processes input in "records" delimited by ".\n" (Perl: $/ = ".\n").
8+
- In each record, highlights a repeated word (case-insensitive) where the two
9+
occurrences are separated by whitespace and/or simple HTML tags.
10+
- Removes any leading lines that contain no escape characters.
11+
- Prefixes each remaining line with "<filename>: ".
12+
"""
13+
14+
from __future__ import annotations
15+
16+
import argparse
17+
import re
18+
import sys
19+
from pathlib import Path
20+
21+
22+
ESC = "\x1b"
23+
24+
# Perl: s/\b([a-z]+)((\s|<[^>]+>)+)(\1\b)/\e[7m$1\e[m$2\e[7m$4\e[m/ig
25+
DOUBLE_WORD_RE = re.compile(
26+
r"\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)",
27+
re.IGNORECASE,
28+
)
29+
30+
# Perl: s/^([^\e]*\n)+//mg
31+
# Interpreted as: drop initial consecutive lines that contain no ESC.
32+
LEADING_NO_ESC_LINES_RE = re.compile(r"^(?:[^\x1b]*\n)+", re.MULTILINE)
33+
34+
35+
def highlight_double_words(record: str) -> str | None:
36+
"""
37+
Return transformed record if a double-word pattern is found; otherwise None.
38+
"""
39+
40+
def repl(m: re.Match[str]) -> str:
41+
w1 = m.group(1)
42+
sep = m.group(2)
43+
w2 = m.group(3) # same text as group(1) as matched
44+
return f"{ESC}[7m{w1}{ESC}[m{sep}{ESC}[7m{w2}{ESC}[m"
45+
46+
new_record, n = DOUBLE_WORD_RE.subn(repl, record, count=1)
47+
if n == 0:
48+
return None
49+
50+
new_record = LEADING_NO_ESC_LINES_RE.sub("", new_record, count=1)
51+
return new_record
52+
53+
54+
def iter_records(text: str, sep: str = ".\n"):
55+
"""
56+
Yield records split by the exact separator, including the separator (like Perl $/).
57+
"""
58+
start = 0
59+
while True:
60+
idx = text.find(sep, start)
61+
if idx == -1:
62+
if start < len(text):
63+
yield text[start:]
64+
break
65+
end = idx + len(sep)
66+
yield text[start:end]
67+
start = end
68+
69+
70+
def process_stream(name: str, data: str, out) -> None:
71+
for record in iter_records(data, sep=".\n"):
72+
transformed = highlight_double_words(record)
73+
if transformed is None:
74+
continue
75+
76+
# Perl: s/^/$ARGV: /mg => prefix each line
77+
prefixed = re.sub(r"^", f"{name}: ", transformed, flags=re.MULTILINE)
78+
out.write(prefixed)
79+
80+
81+
def main() -> int:
82+
ap = argparse.ArgumentParser()
83+
ap.add_argument("files", nargs="*", help="Files to scan; if empty, read stdin.")
84+
args = ap.parse_args()
85+
86+
if not args.files:
87+
data = sys.stdin.read()
88+
process_stream("<stdin>", data, sys.stdout)
89+
return 0
90+
91+
for f in args.files:
92+
p = Path(f)
93+
data = p.read_text(encoding="utf-8", errors="replace")
94+
process_stream(f, data, sys.stdout)
95+
96+
return 0
97+
98+
99+
if __name__ == "__main__":
100+
raise SystemExit(main())

SoftwareGuide/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
# images, if not the images are expected to be present in the Art/ folder
2525
# in PNG/XFIG/JPEG/EPS format.
2626
#
27-
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
28-
cmake_policy(VERSION 3.10.2)
27+
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
28+
cmake_policy(VERSION 3.22.1)
2929

3030
project(SoftwareGuide C)
3131

3232
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH})
3333

34-
find_package(ITK 4 REQUIRED)
34+
find_package(ITK 5 REQUIRED)
3535
include(${ITK_USE_FILE})
3636

3737
set(PDF_QUALITY_LEVEL "Screen" CACHE STRING "PDF Quality. Options are: Screen, Printer, PrePress")

SoftwareGuide/Examples/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
2-
cmake_policy(VERSION 3.10.2)
1+
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
2+
cmake_policy(VERSION 3.22.1)
33

44
project(Examples C)
55

SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ \subsection{CMakeLists.txt}
6464
contain
6565

6666
\begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cmake}
67-
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
68-
cmake_policy(VERSION 3.10.2)
67+
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
68+
cmake_policy(VERSION 3.22.1)
6969

7070
project(MyModule)
7171

@@ -1293,16 +1293,16 @@ \subsection{CMakeList.txt}
12931293
12941294
\begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cmake}
12951295
# When this module is loaded by an app, load OpenCV too.
1296-
set(ITKVideoBridgeOpenCV_EXPORT_CODE_INSTALL "
1297-
set(OpenCV_DIR \"${OpenCV_DIR}\")
1298-
find_package(OpenCV REQUIRED)
1299-
")
1300-
set(ITKVideoBridgeOpenCV_EXPORT_CODE_BUILD "
1301-
if(NOT ITK_BINARY_DIR)
1296+
set(ITKVideoBridgeOpenCV_EXPORT_CODE_INSTALL \"
13021297
set(OpenCV_DIR \"${OpenCV_DIR}\")
13031298
find_package(OpenCV REQUIRED)
1304-
endif()
1305-
")
1299+
\")
1300+
set(ITKVideoBridgeOpenCV_EXPORT_CODE_BUILD \"
1301+
if(NOT ITK_BINARY_DIR)
1302+
set(OpenCV_DIR \"${OpenCV_DIR}\")
1303+
find_package(OpenCV REQUIRED)
1304+
endif()
1305+
\")
13061306
\end{minted}
13071307
13081308
Finally, set the \code{<module-name>\_SYSTEM\_INCLUDE\_DIRS} and

TODO

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
Remove all references to perl PERL
21
Get output images only produced in BINARY_DIR.
32

4-
-- (DONE) Have python code line extractor throw warning when lines are too long to print.
5-
-- Reduce line length in ITK proper
63
-- Figure out which pictures need "flipping" and how to do that with imagemagik.
74
-- Order all tex files in SoftwareGuide/Latex/*.tex to be ordered when listed with a ##-${filename} prefix.
8-
-- Re-order chapters
95
-- Add "Remote Module documentation"
106
-- Remove "CenteredTransforms" from all examples in book.
11-
-- Remove redundant information.
12-
-- Describe Modularization as part of a ITKv3->ITKv4 transition appendix
13-
-- Update Acknowledgments
14-
-- Test clean builds
15-
-- Support "USE_SYSTEM_ITK"
167

178
==========================================================
189
This is a list of potential topics to be added to the Software Guide.

0 commit comments

Comments
 (0)