Convert several preformatted code block literals that enumerate lists of
options or variables to use reST definition lists instead. Manually
wrap other long lines in code blocks.
There are many style errors in these files. This patch fixes only
the syntactical errors.
The script which ported these to rst tripped on some incorrectly
formatted blocks in the original input documentation. Use a new
script to find problematic code (and then fix them manually):
#!/usr/bin/env python
import os
rootDir = '.'
def checkFile(fname):
f = open(fname)
lines = f.readlines()
started = False
counter = 0
for l in lines:
if "#" in l:
started = True
elif started:
return
lin = l.find("(")
if lin != -1 and l.find(")", lin) == -1 and \
not "(To distribute this file outside of CMake, substitute the full" in l:
for lp in lines[counter+1:]:
if lp == "# ::\n":
print "\n\n######### " + fname + "\n\n"
print ''.join(lines[max(counter-2, 0):counter+6])
break
elif lp == "#\n" :
continue
break
counter += 1
for dirName, subdirList, fileList in os.walk(rootDir):
for fname in fileList:
checkFile(os.path.join(dirName, fname))
This solves a lots of warnings, e.g. in the FindModulesExecuteAll test. If the
installed version on the system is rather old this may even lead to bugs, e.g.
https://bugs.gentoo.org/show_bug.cgi?id=436540
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block. This is no longer the preferred style.
Run the following shell code:
for c in else endif endforeach endfunction endmacro endwhile; do
echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
Add the function cmake_expand_imported_targets() to expand imported
targets in a list of libraries into their on-disk file names for a
particular configuration. Adapt the implementation from KDE's
HANDLE_IMPORTED_TARGETS_IN_CMAKE_REQUIRED_LIBRARIES which has been in
use for over 2 years. Call the function from all the Check*.cmake
macros to handle imported targets named in CMAKE_REQUIRED_LIBRARIES.
Alex