Add CMake build instructions.

This commit is contained in:
Bob Friesenhahn 2015-08-29 15:30:11 +00:00
parent 0d55e7db1b
commit 036132130d

View File

@ -10,11 +10,12 @@
"images/cramps.gif" width="159" height="203" align="left" border=
"1" hspace="6"> Building the Software Distribution</font></h1>
<ul>
<li><a href="#UNIX">Building on a UNIX system</a>.</li>
<li><a href="#PC">Building on an MS-DOS or Windows system</a>.</li>
<li><a href="#CMAKE">Building on all systems with CMake</a>.</li>
<li><a href="#UNIX">Building on a UNIX system with Autoconf</a>.</li>
<li><a href="#PC">Building on an MS-DOS or Windows system with nmake</a>.</li>
<li><a href="#VMS">Building on a VMS system</a>.</li>
<li><a href="#Other">Building the Software on Other
Systems</a></li>
Systems.</a></li>
</ul>
<br clear="left">
This chapter contains step-by-step instructions on how to configure
@ -22,8 +23,216 @@ and build the TIFF software distribution. The software is most
easily built on a UNIX system, but with a little bit of work it can
easily be built and used on other non-UNIX platforms.
<hr>
<a name="CMake" id="CMAKE"></a>
<h2>Building on all systems with CMake</h2> CMake may be used to
generate build files for most common build systems and IDEs, and
supports all UNIX-like systems as well as Windows. See
the <a href="http://www.cmake.org/">CMake website</a> for further
details. To build the software on you need to first run
<tt>cmake</tt> to configure the build and generate the system-specific
build files. This reads the top-level <tt>CMakeLists.txt</tt> file,
which probes the target system for necessary tools and functions,
checks any options you specified to configure the build, and then
outputs build files configured for your system. If using <tt>Unix
Makefiles</tt>, once configuration is done, you simply
run <tt>make</tt> (or <tt>gmake</tt>) to build the software and
then <tt>make install</tt> to do the installation. For other build
systems, you do the equivalent steps with the tool for that system.
For example, on any UNIX system:
<div style="margin-left: 2em">
<pre>
% <b>cd ./tiff-4.0.5</b>
% <b>cmake</b>
<i>...lots of messages...</i>
% <b>make</b>
<i>...lots of messages...</i>
% <b>make test</b>
<i>...lots of messages...</i>
# <b>make install</b>
</pre></div>
Building is dependent on a <tt>make</tt> utility and a C
(and optionally a C++ compiler), so you will need these tools.
<p>In general, the software is designed such that the following
targets will always be available</p>
<div style="margin-left: 2em">
<pre>
make [all] build stuff
make test run the test suite
make install build and install stuff
make clean remove object files, executables and cruft
</pre></div>
<a name="CMakeBuildTrees" id= "CMakeBuildTrees"></a>
<hr width="65%" align="right">
<h3>Build Trees</h3>
There are two schemes for configuring and building the software. If
you intend to build the software for only one target system, you
can configure the software so that it is built in the same
directories as the source code.
<div style="margin-left: 2em">
<pre>
% <b>gzip -dc tiff-4.0.5.tar.gz | tar -xf -</b>
% <b>cd ./tiff-4.0.5</b>
% <b>cmake</b>
% <b>make</b>
% <b>make test</b>
% <b>make install</b>
</pre></div>
<p>Otherwise, you can configure a build tree that is parallel to
the source tree hierarchy (or in some completely different place)
but which contains only configured files and files created during
the build procedure.</p>
<div style="margin-left: 2em">
<pre>
% <b>gzip -dc tiff-4.0.5.tar.gz | tar -xf -</b>
% <b>mkdir tiff-4.0.5-build</b>
% <b>cd ./tiff-4.0.5-build</b>
% <b>cmake ../tiff-4.0.5</b>
% <b>make</b>
% <b>make test</b>
% <b>make install</b>
</pre></div>
This second scheme is useful for:
<ul>
<li>building multiple targets from a single source tree</li>
<li>building from a read-only source tree (e.g. if you receive the
distribution on CD-ROM)</li>
<li>sharing the source files via a network, but building on
multiple systems</li>
<li>keeping the source tree clean
(unlike <tt>autoconf</tt>, <tt>cmake</tt> does not provide
a <tt>distclean</tt> target, so out of source builds are
recommended)</li>
</ul>
<a name="CMakeGenerators" id= "CMakeGenerators"></a>
<hr width="65%" align="right">
<h3>Generators</h3> The default generator for UNIX is <tt>Unix
Makefiles</tt>, and on Windows is <tt>NMake Makefiles</tt> or MSBuild
depending upon the setup. Run <b>cmake --help</b> to list all the
generators available for your platform. For example, to use the Ninja
<a href="https://martine.github.io/ninja/">build system</a> on UNIX or
Windows:
<pre>
<b>cmake -G Ninja</b>
<b>cmake --build .</b>
<b>ctest -V</b>
<b>cmake --build . --target install</b>
</pre>
<p>Note that <b>cmake --build .</b> is a build-system-independent way
of building a target; you can always use the build system directly.</p>
<p>Alternatively, using the MSBuild system on Windows (64-bit Release
build with VS2013):
</p>
<pre>
<b>cmake -G "Visual Studio 12 2013 Win64"</b>
<b>cmake --build . --config Release</b>
<b>ctest -V -C Release</b>
<b>cmake --build . --config Release --target install</b>
</pre>
With the above configuration, it's also possible to open the generated
solution file with the Visual Studio IDE as well as building on the
command-line.
<a name="CMakeConfigOptions" id="CMakeConfigOptions"></a>
<hr width="65%" align="right">
<h3>Configuration Options</h3>
The configuration process is critical to the proper compilation,
installation, and operation of the
software. The <tt>CMakeLists.txt</tt> script runs a series of tests to
decide whether or not the target system supports required
functionality and, if it does not, whether it can emulate or
workaround the missing functions. After running <tt>cmake</tt>, check
the <tt>CMakeCache.txt</tt> file; this contains all the results of the
checks performed and the options set by the user. If <tt>cmake</tt>
failed to run, check <tt>CMakeFiles/CMakeOutput.log</tt>
and <tt>CMakeFiles/CMakeError.log</tt>; these should record the error
which caused the failure.
<p>A second function of the configure script is to set the default
configuration parameters for the software. Of particular note are the
directories where the software is to be installed. By default the
software is installed in the <b>/usr/local</b> hierarchy. To change
this behaviour the appropriate parameters can be specified on the
command line. Run <b>cmake --help</b> to get a full list of possible
options, and <b>cmake -LH</b> to list all the configurable options for
this software package, or <b>cmake -LAH</b> to show all advanced
options in addition. Standard installation related options are shown
below.</p>
<pre>
<tt>
Installation directories:
CMAKE_INSTALL_PREFIX
Fine tuning of the installation directories:
CMAKE_INSTALL_BINDIR user executables [PREFIX/bin]
CMAKE_INSTALL_SBINDIR system admin executables [PREFIX/sbin]
CMAKE_INSTALL_LIBEXECDIR program executables [PREFIX/libexec]
CMAKE_INSTALL_SYSCONFDIR read-only single-machine data [PREFIX/etc]
CMAKE_INSTALL_SHAREDSTATEDIR modifiable architecture-independent data [PREFIX/com]
CMAKE_INSTALL_LOCALSTATEDIR modifiable single-machine data [PREFIX/var]
CMAKE_INSTALL_LIBDIR object code libraries [PREFIX/lib]
CMAKE_INSTALL_INCLUDEDIR C header files [PREFIX/include]
CMAKE_INSTALL_OLDINCLUDEDIR C header files for non-gcc [/usr/include]
CMAKE_INSTALL_DATAROOTDIR read-only arch.-independent data root [PREFIX/share]
CMAKE_INSTALL_DATADIR read-only architecture-independent data [DATAROOTDIR]
CMAKE_INSTALL_LOCALEDIR locale-dependent data [DATAROOTDIR/locale]
CMAKE_INSTALL_MANDIR man documentation [DATAROOTDIR/man]
CMAKE_INSTALL_DOCDIR documentation root [DATAROOTDIR/doc/tiff]
</tt>
</pre>
Also see the
CMake <a href="http://www.cmake.org/cmake/help/v3.3/">documentation</a>
for <a href="http://www.cmake.org/cmake/help/v3.3/manual/cmake-variables.7.html"
>additional variables</a> which may be set.
<a name="CMakePackages" id="CMakePackages"></a>
<hr width="65%" align="right">
<h3>Configuring Optional Packages/Support</h3>
The TIFF software comes with several packages that are installed
only as needed, or only if specifically configured at the time the
configure script is run. Packages can be configured via the
<b>cmake</b> commandline parameters.
<dl>
<dt><i>Static/Shared Objects Support</i></dt>
<dd><tt>BUILD_SHARED_LIBS[=ON|OFF]&nbsp;&nbsp;&nbsp;&nbsp;build shared
libraries [default=ON]</tt><br>
<p>This option controls whether or not to configure the software
to build a shared and static binaries for the TIFF library. Use of
shared libraries can significantly reduce the disk space needed for
users of the TIFF software. If shared libraries are not used then
the code is statically linked into each application that uses it.
</p>
<p><tt>ld-version-script[=ON|OFF]&nbsp;&nbsp;Enable linker version
script (default is ON)</tt></p>
<p>Add shared library symbol versioning on ELF-based systems (e.g.
Linux and FreeBSD) which use the GNU linker. This is needed if
several major versions of libtiff might be loaded at once into the
same program.</p>
</dd>
<dt><i>JPEG Support</i></dt>
<dd><tt>jpeg[=ON|OFF]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enable IJG JPEG
library usage (required for JPEG compression, enabled by default)<br>
JPEG_INCLUDE_DIR=DIR&nbsp;location of IJG
JPEG library headers<br>
JPEG_LIBRARY=DIR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location of IJG JPEG
library binary)</tt></dd>
<dd>The <tt>JPEG</tt> package enables support for the handling of
TIFF images with JPEG-encoded data. Support for JPEG-encoded data
requires the Independent JPEG Group (IJG) <tt>libjpeg</tt>
distribution; this software is available at <a href=
"http://www.ijg.org/">http://www.ijg.org/</a>. <b>cmake</b>
script automatically tries to search for a working IJG JPEG
installation. If it fails to find library, JPEG support will be
automatically disabled. If you want specify the exact paths to
library binary and headers, use above options for that.</dd>
<dt><i>ZIP Support</i></dt>
<dd>The <tt>ZIP</tt> support enables support for the handling of TIFF
images with deflate-encoded data (enabled by default if
available). Support for deflate-encoded data requires the freely
available <tt>zlib</tt> distribution written by Jean-loup Gailly and
Mark Adler; this software is available at <a href=
"http://www.zlib.org/">http://www.zlib.org/</a>.</dd>
</dl>
<a name="Sample" id="Sample"></a>
<hr width="65%" align="right">
<a name="UNIX" id="UNIX"></a>
<h2>Building on a UNIX System</h2>
<h2>Building on a UNIX System with Autoconf</h2>
To build the software on a UNIX system you need to first run the
configure shell script that is located in the top level of the
source directory. This script probes the target system for
@ -33,14 +242,14 @@ simply run <tt>make</tt> (or <tt>gmake</tt>) to build the software
and then <tt>make install</tt> to do the installation; for example:
<div style="margin-left: 2em">
<pre>
hyla% <b>cd ./tiff-4.0.0</b>
hyla% <b>./configure</b>
% <b>cd ./tiff-4.0.5</b>
% <b>./configure</b>
<i>...lots of messages...</i>
hyla% <b>make</b>
% <b>make</b>
<i>...lots of messages...</i>
hyla% <b>make check</b>
% <b>make check</b>
<i>...lots of messages...</i>
hyla# <b>make install</b>
# <b>make install</b>
</pre></div>
Supplied makefiles are dependent on a <tt>make</tt> utility and a C
(and optionally a C++ compiler), so you will need these tools.
@ -50,8 +259,8 @@ should be ``<i>make-able</i>'' in each directory:</p>
<pre>
make [all] build stuff
make check run the test suite
make install build&amp;install stuff
make clean remove .o files, executables and cruft
make install build and install stuff
make clean remove object files, executables and cruft
make distclean remove everything, that can be recreated
</pre></div>
Note that after running "<tt>make distclean</tt>" the
@ -66,12 +275,12 @@ can configure the software so that it is built in the same
directories as the source code.
<div style="margin-left: 2em">
<pre>
hyla% <b>gzip -dc tiff-4.0.0.tar.gz | tar -xf -</b>
hyla% <b>cd ./tiff-4.0.0</b>
hyla% <b>./configure</b>
hyla% <b>make</b>
hyla% <b>make check</b>
hyla% <b>make install</b>
% <b>gzip -dc tiff-4.0.5.tar.gz | tar -xf -</b>
% <b>cd ./tiff-4.0.5</b>
% <b>./configure</b>
% <b>make</b>
% <b>make check</b>
% <b>make install</b>
</pre></div>
<p>Otherwise, you can configure a build tree that is parallel to
the source tree hierarchy (or in some completely different place)
@ -79,13 +288,13 @@ but which contains only configured files and files created during
the build procedure.</p>
<div style="margin-left: 2em">
<pre>
hyla% <b>gzip -dc tiff-4.0.0.tar.gz | tar -xf -</b>
hyla% <b>mkdir tiff-4.0.0-build</b>
hyla% <b>cd ./tiff-4.0.0-build</b>
hyla% <b>../tiff-4.0.0/configure</b>
hyla% <b>make</b>
hyla% <b>make check</b>
hyla% <b>make install</b>
% <b>gzip -dc tiff-4.0.5.tar.gz | tar -xf -</b>
% <b>mkdir tiff-4.0.5-build</b>
% <b>cd ./tiff-4.0.5-build</b>
% <b>../tiff-4.0.5/configure</b>
% <b>make</b>
% <b>make check</b>
% <b>make install</b>
</pre></div>
This second scheme is useful for:
<ul>
@ -170,7 +379,7 @@ libraries [default=yes]</tt>
<p>These options control whether or not to configure the software
to build a shared and static binaries for the TIFF library. Use of
shared libraries can significantly reduce the disk space needed for
users of the TIFF software. If shared libarries are not used then
users of the TIFF software. If shared libraries are not used then
the code is statically linked into each application that uses it.
By default both types of binaries is configured.</p>
<p>
@ -199,7 +408,7 @@ distribution; this software is available at <a href=
"http://www.ijg.org/">http://www.ijg.org/</a>. <b>configure</b>
script automatically tries to search for a working IJG JPEG
installation. If it fails to find library, JPEG support will be
automatically disabled.If you want specify the exact paths to
automatically disabled. If you want specify the exact paths to
library binary and headers, use above switches for that.</dd>
<dt><i>ZIP Support</i></dt>
<dd>The <tt>ZIP</tt> support enables support for the handling of
@ -215,8 +424,7 @@ configured.</dd>
<a name="Sample" id="Sample"></a>
<hr width="65%" align="right">
<a name="PC" id="PC"></a>
<h2>Building the Software under Windows 2000/XP/7/8/10 with MS
VC++</h2>
<h2>Building the Software under Windows 2000/XP/7/8/10 with nmake</h2>
With Microsoft Visual C++ installed, and properly configured for
commandline use (you will likely need to source VCVARS32.BAT in
AUTOEXEC.bAT or somewhere similar) you should be able to use the
@ -228,7 +436,7 @@ conventions, which work with MSVC but do not work with Windows
can extract the files using Windows normal line termination
conventions with a command similar to:</p>
<pre>
unzip -aa -a tiff-4.0.0.zip
unzip -aa -a tiff-4.0.5.zip
</pre>
<p>By default the nmake-based libtiff build does not depend on any
additional libraries. Normally libtiff should be built with at least
@ -249,20 +457,20 @@ tif_config.vc.h to tif_config.h, overwriting any files which may be
present. Likewise, the 'nmake clean' step removes those files.</p>
<p>To build using the provided makefile.vc you may use:</p>
<pre>
C:\tiff-4.0.0&gt; nmake /f makefile.vc clean
C:\tiff-4.0.0&gt; nmake /f makefile.vc
C:\tiff-4.0.5&gt; nmake /f makefile.vc clean
C:\tiff-4.0.5&gt; nmake /f makefile.vc
or (the hard way)
C:\tiff-4.0.0&gt; cd port
C:\tiff-4.0.0\port&gt; nmake /f makefile.vc clean
C:\tiff-4.0.0\port&gt; nmake /f makefile.vc
C:\tiff-4.0.0&gt; cd ../libtiff
C:\tiff-4.0.0\libtiff&gt; nmake /f makefile.vc clean
C:\tiff-4.0.0\libtiff&gt; nmake /f makefile.vc
C:\tiff-4.0.0\libtiff&gt; cd ..\tools
C:\tiff-4.0.0\tools&gt; nmake /f makefile.vc clean
C:\tiff-4.0.0\tools&gt; nmake /f makefile.vc
C:\tiff-4.0.5&gt; cd port
C:\tiff-4.0.5\port&gt; nmake /f makefile.vc clean
C:\tiff-4.0.5\port&gt; nmake /f makefile.vc
C:\tiff-4.0.5&gt; cd ../libtiff
C:\tiff-4.0.5\libtiff&gt; nmake /f makefile.vc clean
C:\tiff-4.0.5\libtiff&gt; nmake /f makefile.vc
C:\tiff-4.0.5\libtiff&gt; cd ..\tools
C:\tiff-4.0.5\tools&gt; nmake /f makefile.vc clean
C:\tiff-4.0.5\tools&gt; nmake /f makefile.vc
</pre>
<p>This will build the library
file <tt>libtiff\libtiff\libtiff.lib</tt>.</p>
@ -524,6 +732,6 @@ libtiff/mkspans.c program to generate black-white span tables
libtiff/mkversion.c program to generate libtiff/version.h.
</pre>
<hr>
Last updated: $Date: 2015-06-21 18:21:28 $
Last updated: $Date: 2015-08-29 15:30:11 $
</body>
</html>