about summary refs log tree commit diff homepage
path: root/README-CMake.md
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2016-11-01 22:47:30 +0000
committerDan Liew <delcypher@gmail.com>2016-11-07 22:16:29 +0000
commit7e75b491d389c15d48a5cfc455ba9442d7c108ed (patch)
tree09502118849cb0fc85723d09ceed88ce2ff50fab /README-CMake.md
parent48abc42627315f3435e60ee3d95c1749c667519f (diff)
downloadklee-7e75b491d389c15d48a5cfc455ba9442d7c108ed.tar.gz
Implement a CMake based build system for KLEE.
This is based off intial work by @jirislaby in #481. However it
has been substantially modified.

Notably it includes a separate build sytem to build the runtimes which
is inspired by the old build system. The reason for doing this is
because CMake is not well suited for building the runtime:

* CMake is configured to use the host compiler, not the bitcode
  compiler. These are not the same thing.

* Building the runtime using `add_custom_command()` is flawed
  because we can't automatically get transitive depencies (i.e.
  header file dependencies) unless the CMake generator is makefiles.
  (See `IMPLICIT_DEPENDS` of `add_custom_command()` in CMake).

So for now we have a very simple build system for building the runtimes.
In the future we can replace this with something more sophisticated if
we need it.

Support for all features of the old build system are implemented apart
from recording the git revision and showing it in the output of
`klee --help`.

Another notable change is the CMake build system works much better with
LLVM installs which don't ship with testing tools. The build system
will download the sources for `FileCheck` and `not` tools if the
corresponding binaries aren't available and will build them. However
`lit` (availabe via `pip install lit`) and GTest must already be
installed.

Apart from better support for testing a significant advantage of the
new CMake build system compared to the existing "Autoconf/Makefile"
build system is that it is **not** coupled to LLVM's build system
(unlike the existing build system). This means that LLVM's
autoconf/Makefiles don't need to be installed somewhere on the system.

Currently all tests pass.

Support has been implemented in TravisCI and the Dockerfile for
building with CMake.

The existing "Autoconf/Makefile" build system has been left intact
and so both build systems can coexist for a short while. We should
remove the old build system as soon as possible though because it
creates an unnecessary maintance burden.
Diffstat (limited to 'README-CMake.md')
-rw-r--r--README-CMake.md83
1 files changed, 83 insertions, 0 deletions
diff --git a/README-CMake.md b/README-CMake.md
new file mode 100644
index 00000000..0b9cfd61
--- /dev/null
+++ b/README-CMake.md
@@ -0,0 +1,83 @@
+# CMake build system
+
+KLEE now has a CMake build system which is intended to replace
+its autoconf/Makefile based build system.
+
+## Useful top level targets
+
+* `check` - Build and run all tests.
+* `clean` - Clean the build tree. Note this won't clean the runtime build.
+* `docs` - Build documentation
+* `edit_cache` - Show cmake/ccmake/cmake-gui interface for chaning configure options.
+* `help` - Show list of top level targets
+* `integrationtests` - Run integration tests
+* `unittests` - Build and run unittests
+
+## Useful CMake variables
+
+These can be set by passing `-DVAR_NAME=VALUE` to the CMake invocation.
+
+e.g.
+
+```
+cmake -DCMAKE_BUILD_TYPE=Release /path/to/klee/src
+```
+* `LLVMCC` (STRING) - Path to the LLVM C compiler (e.g. Clang).
+
+* `LLVMCXX` (STRING) - Path to the LLVM C++ compiler (e.g. Clang++).
+
+* `CMAKE_BUILD_TYPE` (STRING) - Build type for KLEE. Can be
+  `Debug`, `Release`, `RelWithDebInfo` or `MinSizeRel`.
+
+* `DOWNLOAD_LLVM_TESTING_TOOLS` (BOOLEAN) - Force downloading
+   of LLVM testing tool sources.
+
+* `ENABLE_DOCS` (BOOLEAN) - Enable building documentation.
+
+* `ENABLE_DOXYGEN` (BOOLEAN) - Enable building doxygen documentation.
+
+* `ENABLE_INTEGRATION_TESTS` (BOOLEAN) - Enable KLEE integration tests.
+
+* `ENABLE_KLEE_ASSERTS` (BOOLEAN) - Enable assertions when building KLEE.
+
+* `ENABLE_KLEE_UCLIBC` (BOOLEAN) - Enable support for klee-uclibc.
+
+* `ENABLE_POSIX_RUNTIME` (BOOLEAN) - Enable POSIX runtime.
+
+* `ENABLE_SOLVER_METASMT` (BOOLEAN) - Enable MetaSMT solver support.
+
+* `ENABLE_SOLVER_STP` (BOOLEAN) - Enable STP solver support.
+
+* `ENABLE_SOLVER_Z3` (BOOLEAN) - Enable Z3 solver support.
+
+* `ENABLE_TCMALLOC` (BOOLEAN) - Enable TCMalloc support.
+
+* `ENABLE_TESTS` (BOOLEAN) - Enable testing.
+
+* `ENABLE_UNIT_TESTS` (BOOLEAN) - Enable KLEE unit tests.
+
+* `GTEST_SRC_DIR` (STRING) - Path to GTest source tree.
+
+* `KLEE_ENABLE_TIMESTAMP` (BOOLEAN) - Enable timestamps in KLEE sources.
+
+* `KLEE_UCLIBC_PATH` (STRING) - Path to klee-uclibc root directory.
+
+* `KLEE_RUNTIME_BUILD_TYPE` (STRING) - Build type for KLEE's runtimes.
+   Can be `Release`, `Release+Asserts`, `Debug` or `Debug+Asserts`.
+
+* `LIT_TOOL` (STRING) - Path to lit testing tool.
+
+* `LIT_ARGS` (STRING) - Semi-colon separated list of lit options.
+
+* `LLVM_CONFIG_BINARY` (STRING) - Path to `llvm-config` binary. This is
+   only relevant if `USE_CMAKE_FIND_PACKAGE_LLVM` is `FALSE`. This is used
+   to detect the LLVM version and find libraries.
+
+* `MAKE_BINARY` (STRING) - Path to `make` binary used to build KLEE's runtime.
+
+* `USE_CMAKE_FIND_PACKAGE_LLVM` (BOOLEAN) - Use `find_package(LLVM CONFIG)`
+   to find LLVM.
+
+* `USE_CXX11` (BOOLEAN) - Use C++11.
+
+* `WARNINGS_AS_ERRORS` (BOOLEAN) - Treat warnings as errors when building KLEE.