mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 11:55:51 +00:00
Move CMakeLists.txt files (other than the one in the repository root)
and the cmake directory into a new directory ``contrib/cmake`` that mirrors the directory structure of the root. This is a comprimise between me and Christoph Wintersteiger that was suggested by Arie Gurfinkel that allows the CMake build system to live in the Z3 repository but not impact the Z3 developers that want to avoid the CMake build system. The build system will not work in its new location and a bootstrap script will soon be provided that allows a developer to copy the files back to their correct location.
This commit is contained in:
parent
d54d6b50f0
commit
a3e0eae9ec
82 changed files with 0 additions and 0 deletions
107
contrib/cmake/src/api/python/CMakeLists.txt
Normal file
107
contrib/cmake/src/api/python/CMakeLists.txt
Normal file
|
@ -0,0 +1,107 @@
|
|||
message(STATUS "Emitting rules to build Z3 python bindings")
|
||||
###############################################################################
|
||||
# Add target to build python bindings for the build directory
|
||||
###############################################################################
|
||||
# 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
|
||||
z3test.py
|
||||
z3types.py
|
||||
z3util.py
|
||||
)
|
||||
|
||||
set(z3py_bindings_build_dest "${CMAKE_BINARY_DIR}")
|
||||
|
||||
set(build_z3_python_bindings_target_depends "")
|
||||
foreach (z3py_file ${z3py_files})
|
||||
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/${z3py_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" "-E" "copy"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${z3py_file}"
|
||||
"${z3py_bindings_build_dest}"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${z3py_file}"
|
||||
COMMENT "Copying \"${z3py_file}\" to ${z3py_bindings_build_dest}"
|
||||
)
|
||||
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"
|
||||
COMMAND "${PYTHON_EXECUTABLE}"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/update_api.py"
|
||||
${Z3_FULL_PATH_API_HEADER_FILES_TO_SCAN}
|
||||
"--z3py-output-dir"
|
||||
"${z3py_bindings_build_dest}"
|
||||
DEPENDS
|
||||
${Z3_FULL_PATH_API_HEADER_FILES_TO_SCAN}
|
||||
"${CMAKE_SOURCE_DIR}/scripts/update_api.py"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/mk_util.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")
|
||||
|
||||
# Generate z3consts.py
|
||||
add_custom_command(OUTPUT "${z3py_bindings_build_dest}/z3consts.py"
|
||||
COMMAND "${PYTHON_EXECUTABLE}"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/mk_consts_files.py"
|
||||
${Z3_FULL_PATH_API_HEADER_FILES_TO_SCAN}
|
||||
"--z3py-output-dir"
|
||||
"${z3py_bindings_build_dest}"
|
||||
DEPENDS
|
||||
${Z3_FULL_PATH_API_HEADER_FILES_TO_SCAN}
|
||||
"${CMAKE_SOURCE_DIR}/scripts/mk_consts_files.py"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/mk_util.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")
|
||||
|
||||
# Convenient top-level target
|
||||
add_custom_target(build_z3_python_bindings
|
||||
ALL
|
||||
DEPENDS
|
||||
${build_z3_python_bindings_target_depends}
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# Install
|
||||
###############################################################################
|
||||
option(INSTALL_PYTHON_BINDINGS "Install Python bindings when invoking install target" ON)
|
||||
if (INSTALL_PYTHON_BINDINGS)
|
||||
# Determine the installation path for the bindings
|
||||
message(STATUS "Emitting rules to install Z3 python bindings")
|
||||
execute_process(
|
||||
COMMAND "${PYTHON_EXECUTABLE}" "-c"
|
||||
"import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())"
|
||||
RESULT_VARIABLE exit_code
|
||||
OUTPUT_VARIABLE python_pkg_dir
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if (NOT ("${exit_code}" EQUAL 0))
|
||||
message(FATAL_ERROR "Failed to determine your Python package directory")
|
||||
endif()
|
||||
message(STATUS "Detected Python package directory: \"${python_pkg_dir}\"")
|
||||
|
||||
# Check if path exists under the install prefix
|
||||
set(python_install_dir "")
|
||||
string(FIND "${python_pkg_dir}" "${CMAKE_INSTALL_PREFIX}" position)
|
||||
if (NOT ("${position}" EQUAL 0))
|
||||
message(WARNING "The detected Python package directory \"${python_pkg_dir}\" "
|
||||
"does not exist under the install prefix \"${CMAKE_INSTALL_PREFIX}\"."
|
||||
" Running the install target may lead to a broken installation."
|
||||
)
|
||||
endif()
|
||||
# Using DESTDIR still seems to work even if we use an absolute path
|
||||
set(python_install_dir "${python_pkg_dir}")
|
||||
message(STATUS "Python bindings will be installed to \"${python_install_dir}\"")
|
||||
install(FILES ${build_z3_python_bindings_target_depends}
|
||||
DESTINATION "${python_install_dir}"
|
||||
)
|
||||
else()
|
||||
message(STATUS "Not emitting rules to install Z3 python bindings")
|
||||
endif()
|
Loading…
Add table
Add a link
Reference in a new issue