From a239b21e900211a3e8ad5332abe618b7f7bb5846 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 23 Aug 2025 18:18:24 +0000 Subject: [PATCH] Add documentation for using system-installed Z3 with CMake Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --- README-CMake.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README-CMake.md b/README-CMake.md index e182a7f94..bf06116fc 100644 --- a/README-CMake.md +++ b/README-CMake.md @@ -119,6 +119,30 @@ target_link_libraries(yourTarget libz3) ``` Note that this is `libz3` not `z3` (`libz3` refers to the library target from `src/CMakeLists.txt`). +#### Using system-installed Z3 + +If you have Z3 installed on your system (e.g., via package manager or by building and installing Z3 yourself), you can use CMake's `find_package` to locate it: + +```cmake +find_package(Z3 REQUIRED CONFIG) +``` + +Once found, you can use the Z3 include directories and libraries: + +```cmake +# For C projects +target_include_directories(yourTarget PRIVATE ${Z3_C_INCLUDE_DIRS}) +target_link_libraries(yourTarget PRIVATE ${Z3_LIBRARIES}) + +# For C++ projects +target_include_directories(yourTarget PRIVATE ${Z3_CXX_INCLUDE_DIRS}) +target_link_libraries(yourTarget PRIVATE ${Z3_LIBRARIES}) +``` + +The `find_package(Z3 CONFIG)` approach uses Z3's provided `Z3Config.cmake` file, which is installed to a standard location (typically `/lib/cmake/z3/`). If CMake cannot automatically find Z3, you can help it by setting `-DZ3_DIR=` where `` is the directory containing the `Z3Config.cmake` file. + +**Note**: This approach requires that Z3 was built and installed using CMake. Z3 installations from the Python build system may not provide the necessary CMake configuration files. + ### Ninja