3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 09:35:32 +00:00

Implement a CMake build system.

This is a large rework of my first attempt at this (#459).

This implementation calls into the recently implemented python scripts
to generate the necessary generated ``.h`` and ``.cpp`` files but is
independent from Python building system otherwise.  Unlike the Python
build system, the generated files are emitted into the build tree to
avoid polluting the source tree. The build system is setup to refuse to
configure if it detects generated files in the source tree. If your
source tree is dirty you can run ``git clean -fx`` to clean your working
directory.

Currently the build succeeds on Linux using CMake 3.4.3 using
the "Unix Makefiles" generator with gcc or clang.

The following notable features are implemented:

* Building of the C and C++ examples and the ``test-z3`` executable.
  These are included from the ``all`` target so you have to tell the
  build system (e.g. make) to build them manually.

* Install (``make install``) and uninstall (``make uninstall``) of libz3
  and its header files. This supports ``DESTDIR`` out of the box because
  CMake supports it.

* An option (``BUILD_LIBZ3_SHARED``) to build libz3 as a static or dynamic library.

* Support for using/not using OpenMP (``USE_OPENMP``)

* Support for using/not using libgmp (``USE_LIB_GMP``)

* Setting the SOVERSION for libz3. I'm not sure if I'm setting the
* number correctly though. This is required by Linux distrubtions that
  wills ship libz3. This needs discussion.

The following notable features are currently not implemented
and are left for future work.

* Support for ARM.
* Support for the foci2 library.
* Support for creating/installing/uninstalling the dotnet, java, python and ml
  bindings.
* Full support for MSVC. Although I've tried to write the CMake code
  with MSVC in mind not all the correct flags are passed to it.
* Support for using the git hash.

This new build system has several advantages other the old build system.

* It is easier for outside contributors to contribute to Z3 when the
  build system is something more standard.
* Incremental builds work properly. With the old build system when
  new code is pulled down the old build directory would need to thrown
  out and a new fresh build had to be performed because the build system
  didn't know how to correctly rebuild the project (e.g. couldn't handle
  new sources being added/removed, compiler flags changing, generated
  files changing, etc...). This is a MASSIVE boost to productivity!
* We now have access rich array of features that CMake provides for
  building C/C++ projects. This means less time spent implementing
  custom build system logic in Python that is already supported by
  CMake.
* CMake supports many IDEs out of the box so it should be fairly
  straight forward to build Z3 with Visual Studio (once support for MSVC
  is added), Xcode, Eclipse CDT, CLion, ..etc.
This commit is contained in:
Dan Liew 2016-02-20 23:21:00 +00:00
parent db34baa979
commit 251527603d
86 changed files with 2259 additions and 0 deletions

125
src/test/CMakeLists.txt Normal file
View file

@ -0,0 +1,125 @@
add_subdirectory(fuzzing)
################################################################################
# z3-test executable
################################################################################
set(z3_test_deps api fuzzing simplex)
z3_expand_dependencies(z3_test_expanded_deps ${z3_test_deps})
set (z3_test_extra_object_files "")
foreach (component ${z3_test_expanded_deps})
list(APPEND z3_test_extra_object_files $<TARGET_OBJECTS:${component}>)
endforeach()
add_executable(test-z3
EXCLUDE_FROM_ALL
algebraic.cpp
api_bug.cpp
api.cpp
arith_rewriter.cpp
arith_simplifier_plugin.cpp
ast.cpp
bit_blaster.cpp
bits.cpp
bit_vector.cpp
buffer.cpp
bv_simplifier_plugin.cpp
chashtable.cpp
check_assumptions.cpp
datalog_parser.cpp
ddnf.cpp
diff_logic.cpp
dl_context.cpp
dl_product_relation.cpp
dl_query.cpp
dl_relation.cpp
dl_table.cpp
dl_util.cpp
doc.cpp
escaped.cpp
ex.cpp
expr_rand.cpp
expr_substitution.cpp
ext_numeral.cpp
f2n.cpp
factor_rewriter.cpp
fixed_bit_vector.cpp
for_each_file.cpp
get_implied_equalities.cpp
"${CMAKE_CURRENT_BINARY_DIR}/gparams_register_modules.cpp"
hashtable.cpp
heap.cpp
heap_trie.cpp
hilbert_basis.cpp
horn_subsume_model_converter.cpp
hwf.cpp
inf_rational.cpp
"${CMAKE_CURRENT_BINARY_DIR}/install_tactic.cpp"
interval.cpp
karr.cpp
list.cpp
main.cpp
map.cpp
matcher.cpp
"${CMAKE_CURRENT_BINARY_DIR}/mem_initializer.cpp"
memory.cpp
model2expr.cpp
model_retrieval.cpp
mpbq.cpp
mpf.cpp
mpff.cpp
mpfx.cpp
mpq.cpp
mpz.cpp
nlarith_util.cpp
nlsat.cpp
no_overflow.cpp
object_allocator.cpp
old_interval.cpp
optional.cpp
parray.cpp
pdr.cpp
permutation.cpp
polynomial.cpp
polynomial_factorization.cpp
polynorm.cpp
prime_generator.cpp
proof_checker.cpp
qe_arith.cpp
quant_elim.cpp
quant_solve.cpp
random.cpp
rational.cpp
rcf.cpp
region.cpp
sat_user_scope.cpp
simple_parser.cpp
simplex.cpp
simplifier.cpp
small_object_allocator.cpp
smt2print_parse.cpp
smt_context.cpp
sorting_network.cpp
stack.cpp
string_buffer.cpp
substitution.cpp
symbol.cpp
symbol_table.cpp
tbv.cpp
theory_dl.cpp
theory_pb.cpp
timeout.cpp
total_order.cpp
trigo.cpp
udoc_relation.cpp
uint_set.cpp
upolynomial.cpp
var_subst.cpp
vector.cpp
${z3_test_extra_object_files}
)
z3_add_install_tactic_rule(${z3_test_deps})
z3_add_memory_initializer_rule(${z3_test_deps})
z3_add_gparams_register_modules_rule(${z3_test_deps})
target_compile_definitions(test-z3 PRIVATE ${Z3_COMPONENT_CXX_DEFINES})
target_compile_options(test-z3 PRIVATE ${Z3_COMPONENT_CXX_FLAGS})
target_link_libraries(test-z3 PRIVATE ${Z3_DEPENDENT_LIBS})
target_include_directories(shell PRIVATE ${Z3_COMPONENT_EXTRA_INCLUDE_DIRS})
z3_add_component_dependencies_to_target(test-z3 ${z3_test_expanded_deps})

View file

@ -0,0 +1,8 @@
z3_add_component(fuzzing
NOT_LIBZ3_COMPONENT # Don't put this component inside libz3
SOURCES
expr_delta.cpp
expr_rand.cpp
COMPONENT_DEPENDENCIES
ast
)