ROSE  0.11.145.0

Sawyer can be downloaded from GitHub.

For example:

$ SAWYER_SRC=/directory/in/which/to/store/sources
$ git clone https://github.com/matzke1/sawyer $SAWYER_SRC

Sawyer uses cmake as its configuration and build system and building is typically performed in a separate directory from the source. The author usually creates various "_build-whatever" directories at the top level of the source code directory, but the build directories can be located anywhere. CMake operates in two steps: first one configures the build environment using the "cmake" command, then the library is built and installed. Here is a typical configuration step:

$ SAWYER_BLD=/some/directory/in/which/to/build
$ mkdir $SAWYER_BLD
$ cd $SAWYER_BLD
$ cmake $SAWYER_SRC -DBOOST_ROOT=/location/of/boost -DCMAKE_INSTALL_PREFIX:PATH=/place/to/install/sawyer

The BOOST_ROOT should be the directory containing Boost's "include" and "lib" directories. It's necessary only when Boost isn't installed in a well-known location. In addition to Boost header files, Sawyer also requires these Boost libraries: iostreams, system, filesystem, regex, chrono, and thread. These libraries should have been compiled with the same C++ compiler and switches as Sawyer.

The CMAKE_BUILD_TYPE can be specified to control whether a debug or release version of the library is created. Its value should be the word "Debug" or "Release". The default is "Release". For instance, "-DCMAKE_BUILD_TYPE=Debug".

The CMAKE_INSTALL_PREFIX is the directory that will contain the "include" and "lib" subdirectories where Sawyer is eventually installed. Sawyer is also designed to be used directly from the build directory if desired.

CMake will configure Sawyer to use the system's multi-threading support by default. If you plan to use Sawyer in only single-threaded programs you can avoid the thread dependencies by providing the "-DTHREAD_SAFE:BOOL=no" switch, in which case even those parts of the API that are documented as being thread-safe will probably not be safe. Within a program that uses Sawyer, one can check whether multi-thread support was enabled by checking the SAWYER_MULTI_THREADED C preprocessor symbol; it will be defined as zero if multi-threading is disabled, and non-zero otherwise. The SAWYER_THREAD_TRAITS will point to one of the Sawyer::SynchronizationTraits specializations, and SAWYER_THREAD_TRAITS::SUPPORTED is true or false depending on whether multi-threading is supported.

The next step after configuration is to build the library and tests:

$ cd $SAWYER_BLD
$ make

Parallel building is supported with "make -jN" where N is the maximum number of parallel compile commands to allow. If you need to see the compilation commands that are executed, add "VERBOSE=1" to the "make" command.

Finally, the library can be installed and the build directory can be removed:

$ cd $SAWYER_BLD
$ make install

The current build system makes no attempt to name libraries in ways that distinguish the Boost version, build type, thread-support, compiler version, etc. We recommend that Sawyer be used only in programs that are built with compatible configuration, and the CMAKE_INSTALL_PREFIX can be used to create a naming scheme to install multiple Sawyer configurations on one machine.

Cross compiling on Linux targeting Microsoft Windows

Sawyer is not regularly tested on Microsoft platforms, but the MinGW compiler is supported. On Debian this compiler can be installed with "sudo apt-get install mingw-w64". One also needs cross-compiled Boost libraries, that can be created with these steps:

$ ./bjam --help
$ ./bjam install toolset=gcc-mingw32 \
--prefix=$HOME/lib-mingw32/boost-1.47 \
--layout=versioned \
--with-iostreams --with-system --with-filesystem --with-regex --with-chrono \
-sNO_ZLIB=1 -sNO_BZIP2=1

To compile Sawyer use the same cmake command as for native compiling, but add "-DCMAKE_TOOLCHAIN_FILE=$SAWYER_SRC/Toolchain-cross-mingw32-linux.cmake". Also make sure the BOOST_ROOT parameter points to the cross-compiled version of Boost, which must be installed in a directory that's at or below one of the CMAKE_FIND_ROOT_PATH directories specified in the Toolchain-cross-mingw32-linux.cmake. Then run "make" and "make install" like normal.

Native compiling with Microsoft Visual Studio

Sawyer is seldom tested in this manner, but Microsoft Visual Studio versions 10 2010 and 12 2013 have been tested at time or another. To install Boost, follow the instructions at the Boost web site. The instructions didn't work for my virtual machine with Windows 8.1 Enterprise and Visual Studio 12 2013, so I used precompiled Boost libraries I found at boost.org [Matzke].

Generate a Visual Studio project file with a command like this, and the usual CMake options described above. IIRC, cmake expects Windows-style path names having backslashes instead of POSIX names.

cmake -G "Visual Studio 12 2013" ...

Then fire up the Visual Studio IDE, open the project file, right click on a "solution", and select "Build".

Collaboration diagram for Installation: