3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 17:44:08 +00:00

Fix cmake build to work with the new system

This commit is contained in:
Andrew Dutcher 2016-09-15 00:28:19 -07:00
parent 02217d048b
commit 9e498536b6
3 changed files with 56 additions and 18 deletions

View file

@ -1,3 +1,4 @@
add_subdirectory(c)
add_subdirectory(c++)
add_subdirectory(tptp)
add_subdirectory(python)

View file

@ -0,0 +1,24 @@
set(python_example_files
example.py
visitor.py
)
set(z3py_bindings_build_dest "${CMAKE_BINARY_DIR}/python")
set(build_z3_python_examples_target_depends "")
foreach (example_file ${python_example_files})
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/${example_file}"
COMMAND "${CMAKE_COMMAND}" "-E" "copy"
"${CMAKE_CURRENT_SOURCE_DIR}/${example_file}"
"${z3py_bindings_build_dest}/${example_file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${example_file}"
COMMENT "Copying \"${example_file}\" to ${z3py_bindings_build_dest}/${example_file}"
)
list(APPEND build_z3_python_examples_target_depends "${z3py_bindings_build_dest}/${example_file}")
endforeach()
add_custom_target(build_z3_python_examples
ALL
DEPENDS
${build_z3_python_examples_target_depends}
)

View file

@ -4,31 +4,34 @@ message(STATUS "Emitting rules to build Z3 python bindings")
###############################################################################
# This allows the python bindings to be used directly from the build directory
set(z3py_files
z3.py
z3num.py
z3poly.py
z3printer.py
z3rcf.py
z3types.py
z3util.py
z3/__init__.py
z3/z3.py
z3/z3num.py
z3/z3poly.py
z3/z3printer.py
z3/z3rcf.py
z3/z3types.py
z3/z3util.py
)
set(z3py_bindings_build_dest "${CMAKE_BINARY_DIR}")
set(z3py_bindings_build_dest "${CMAKE_BINARY_DIR}/python")
file(MAKE_DIRECTORY "${z3py_bindings_build_dest}")
file(MAKE_DIRECTORY "${z3py_bindings_build_dest}/z3")
set(build_z3_python_bindings_target_depends "")
foreach (z3py_file ${z3py_files})
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3/${z3py_file}"
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/${z3py_file}"
COMMAND "${CMAKE_COMMAND}" "-E" "copy"
"${CMAKE_CURRENT_SOURCE_DIR}/z3/${z3py_file}"
"${z3py_bindings_build_dest}/z3.py"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/z3/${z3py_file}"
COMMENT "Copying \"${z3py_file}\" to ${z3py_bindings_build_dest}/z3.py/${z3py_file}"
"${CMAKE_CURRENT_SOURCE_DIR}/${z3py_file}"
"${z3py_bindings_build_dest}/${z3py_file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${z3py_file}"
COMMENT "Copying \"${z3py_file}\" to ${z3py_bindings_build_dest}/${z3py_file}"
)
list(APPEND build_z3_python_bindings_target_depends "${z3py_bindings_build_dest}/${z3py_file}")
endforeach()
# Generate z3core.py
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3core.py"
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3/z3core.py"
COMMAND "${PYTHON_EXECUTABLE}"
"${CMAKE_SOURCE_DIR}/scripts/update_api.py"
${Z3_FULL_PATH_API_HEADER_FILES_TO_SCAN}
@ -43,10 +46,10 @@ add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3core.py"
COMMENT "Generating z3core.py"
${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG}
)
list(APPEND build_z3_python_bindings_target_depends "${z3py_bindings_build_dest}/z3core.py")
list(APPEND build_z3_python_bindings_target_depends "${z3py_bindings_build_dest}/z3/z3core.py")
# Generate z3consts.py
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3consts.py"
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3/z3consts.py"
COMMAND "${PYTHON_EXECUTABLE}"
"${CMAKE_SOURCE_DIR}/scripts/mk_consts_files.py"
${Z3_FULL_PATH_API_HEADER_FILES_TO_SCAN}
@ -59,13 +62,23 @@ add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3consts.py"
COMMENT "Generating z3consts.py"
${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG}
)
list(APPEND build_z3_python_bindings_target_depends "${z3py_bindings_build_dest}/z3consts.py")
list(APPEND build_z3_python_bindings_target_depends "${z3py_bindings_build_dest}/z3/z3consts.py")
# Link libz3 into the python directory so bindings work out of the box
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/libz3${CMAKE_SHARED_MODULE_SUFFIX}"
COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink"
"${CMAKE_BINARY_DIR}/libz3${CMAKE_SHARED_MODULE_SUFFIX}"
"${z3py_bindings_build_dest}/libz3${CMAKE_SHARED_MODULE_SUFFIX}"
DEPENDS libz3
COMMENT "Linking libz3 into python directory"
)
# Convenient top-level target
add_custom_target(build_z3_python_bindings
ALL
DEPENDS
${build_z3_python_bindings_target_depends}
"${z3py_bindings_build_dest}/libz3${CMAKE_SHARED_MODULE_SUFFIX}"
)
###############################################################################
@ -116,7 +129,7 @@ if (INSTALL_PYTHON_BINDINGS)
# Using DESTDIR still seems to work even if we use an absolute path
message(STATUS "Python bindings will be installed to \"${CMAKE_INSTALL_PYTHON_PKG_DIR}\"")
install(FILES ${build_z3_python_bindings_target_depends}
DESTINATION "${CMAKE_INSTALL_PYTHON_PKG_DIR}"
DESTINATION "${CMAKE_INSTALL_PYTHON_PKG_DIR}/z3"
)
else()
message(STATUS "Not emitting rules to install Z3 python bindings")