diff --git a/CMakeLists.txt b/CMakeLists.txt index d1cfa8ee3..603e86ee1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_compiler_flags_overrides.cmake") # Read version from VERSION.txt file -file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" Z3_VERSION_FROM_FILE) +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/scripts/VERSION.txt" Z3_VERSION_FROM_FILE) string(STRIP "${Z3_VERSION_FROM_FILE}" Z3_VERSION_FROM_FILE) project(Z3 VERSION ${Z3_VERSION_FROM_FILE} LANGUAGES CXX) diff --git a/MODULE.bazel b/MODULE.bazel index c368221da..48848d27e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "z3", - version = "4.16.0", # TODO: Read from VERSION.txt - currently manual sync required + version = "4.15.4", # TODO: Read from VERSION.txt - currently manual sync required bazel_compatibility = [">=7.0.0"], ) 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 diff --git a/VERSION.txt b/scripts/VERSION.txt similarity index 100% rename from VERSION.txt rename to scripts/VERSION.txt diff --git a/scripts/mk_nuget_task.py b/scripts/mk_nuget_task.py index b85ec4c8e..d854adad4 100644 --- a/scripts/mk_nuget_task.py +++ b/scripts/mk_nuget_task.py @@ -103,7 +103,7 @@ def mk_targets(source_root): def mk_icon(source_root): mk_dir("out/content") shutil.copy(f"{source_root}/resources/icon.jpg", "out/content/icon.jpg") -# shutil.copy(f"{source_root}/src/api/dotnet/README.md", "out/content/README.md") + shutil.copy(f"{source_root}/src/api/dotnet/README.md", "out/content/README.md") @@ -124,6 +124,7 @@ Linux Dependencies: © Microsoft Corporation. All rights reserved. smt constraint solver theorem prover content/icon.jpg + content/README.md https://github.com/Z3Prover/z3 MIT diff --git a/scripts/mk_project.py b/scripts/mk_project.py index da73e2daf..7b4d444ea 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -9,7 +9,7 @@ from mk_util import * def init_version(): # Read version from VERSION.txt file - version_file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'VERSION.txt') + version_file_path = os.path.join(os.path.dirname(__file__), 'VERSION.txt') try: with open(version_file_path, 'r') as f: version_str = f.read().strip() diff --git a/scripts/nightly.yaml b/scripts/nightly.yaml index 5323f8bc0..d051cb0ee 100644 --- a/scripts/nightly.yaml +++ b/scripts/nightly.yaml @@ -1,8 +1,8 @@ variables: # Version components read from VERSION.txt (updated manually when VERSION.txt changes) Major: '4' - Minor: '16' - Patch: '0' + Minor: '15' + Patch: '4' ReleaseVersion: $(Major).$(Minor).$(Patch) AssemblyVersion: $(Major).$(Minor).$(Patch).$(Build.BuildId) NightlyVersion: $(AssemblyVersion)-$(Build.buildId) @@ -254,9 +254,9 @@ stages: inputs: artifact: 'MacArm64' path: $(Agent.TempDirectory)\package - - task: NuGetToolInstaller@0 + - task: NuGetToolInstaller@1 inputs: - versionSpec: 5.x + versionSpec: 6.x checkLatest: false - task: PythonScript@0 displayName: 'Python: assemble files' @@ -302,9 +302,9 @@ stages: inputs: artifact: 'WindowsBuild-x86' path: $(Agent.TempDirectory)\package - - task: NuGetToolInstaller@0 + - task: NuGetToolInstaller@1 inputs: - versionSpec: 5.x + versionSpec: 6.x checkLatest: false - task: PythonScript@0 displayName: 'Python: assemble files' diff --git a/scripts/release.yml b/scripts/release.yml index 2a6cd363d..b26539c35 100644 --- a/scripts/release.yml +++ b/scripts/release.yml @@ -6,7 +6,7 @@ trigger: none variables: - ReleaseVersion: '4.16.0' # TODO: Auto-read from VERSION.txt when Azure DevOps supports it better + ReleaseVersion: '4.15.4' # TODO: Auto-read from VERSION.txt when Azure DevOps supports it better stages: @@ -261,9 +261,9 @@ stages: artifact: 'MacArm64' path: $(Agent.TempDirectory)\package - - task: NuGetToolInstaller@0 + - task: NuGetToolInstaller@1 inputs: - versionSpec: 5.x + versionSpec: 6.x checkLatest: false - task: PythonScript@0 displayName: 'Python: assemble files' @@ -305,9 +305,9 @@ stages: inputs: artifact: 'WindowsBuild-x86' path: $(Agent.TempDirectory)\package - - task: NuGetToolInstaller@0 + - task: NuGetToolInstaller@1 inputs: - versionSpec: 5.x + versionSpec: 6.x checkLatest: false - task: PythonScript@0 displayName: 'Python: assemble files' @@ -471,7 +471,7 @@ stages: - job: NuGetPublish - condition: eq(1,0) + condition: eq(1,1) displayName: "Publish to NuGet.org" steps: - task: DownloadPipelineArtifact@2 @@ -479,9 +479,9 @@ stages: inputs: artifact: 'NuGetPackage' path: $(Agent.TempDirectory) - - task: NuGetToolInstaller@0 + - task: NuGetToolInstaller@1 inputs: - versionSpec: 5.x + versionSpec: 6.x checkLatest: false - task: NuGetCommand@2 inputs: diff --git a/scripts/update_version.py b/scripts/update_version.py index fcc3c5576..f33b20655 100755 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -16,7 +16,7 @@ import sys def read_version(): """Read version from VERSION.txt file.""" script_dir = os.path.dirname(os.path.abspath(__file__)) - version_file = os.path.join(os.path.dirname(script_dir), 'VERSION.txt') + version_file = os.path.join(script_dir, 'VERSION.txt') try: with open(version_file, 'r') as f: diff --git a/src/api/julia/CMakeLists.txt b/src/api/julia/CMakeLists.txt index fe27caa95..952b33fb5 100644 --- a/src/api/julia/CMakeLists.txt +++ b/src/api/julia/CMakeLists.txt @@ -1,5 +1,32 @@ find_package(JlCxx REQUIRED) +# Check for Windows MSVC + MinGW library compatibility issues +if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Get the JlCxx library path to check its format + get_target_property(JLCXX_LIB_PATH JlCxx::cxxwrap_julia IMPORTED_LOCATION) + if(NOT JLCXX_LIB_PATH) + get_target_property(JLCXX_LIB_PATH JlCxx::cxxwrap_julia IMPORTED_LOCATION_RELEASE) + endif() + if(NOT JLCXX_LIB_PATH) + get_target_property(JLCXX_LIB_PATH JlCxx::cxxwrap_julia IMPORTED_IMPLIB) + endif() + if(NOT JLCXX_LIB_PATH) + get_target_property(JLCXX_LIB_PATH JlCxx::cxxwrap_julia IMPORTED_IMPLIB_RELEASE) + endif() + + if(JLCXX_LIB_PATH AND JLCXX_LIB_PATH MATCHES "\\.dll\\.a$") + message(FATAL_ERROR + "Julia bindings build error: Incompatible CxxWrap library format detected.\n" + "The found libcxxwrap_julia library (${JLCXX_LIB_PATH}) is a MinGW import library (.dll.a), " + "but Z3 is being built with MSVC which requires .lib format.\n\n" + "Solutions:\n" + "1. Use MinGW/GCC instead of MSVC to build Z3\n" + "2. Install a MSVC-compatible version of CxxWrap\n" + "3. Disable Julia bindings with -DZ3_BUILD_JULIA_BINDINGS=OFF\n\n" + "For more information, see: https://github.com/JuliaInterop/CxxWrap.jl#compiling-the-c-code") + endif() +endif() + add_library(z3jl SHARED z3jl.cpp) target_link_libraries(z3jl PRIVATE JlCxx::cxxwrap_julia libz3) target_include_directories(z3jl PRIVATE diff --git a/src/api/python/setup.py b/src/api/python/setup.py index 6b400c7d4..39ae7df72 100644 --- a/src/api/python/setup.py +++ b/src/api/python/setup.py @@ -113,14 +113,21 @@ def _clean_native_build(): def _z3_version(): post = os.getenv('Z3_VERSION_SUFFIX', '') + print("z3_version", "release dir", RELEASE_DIR) if RELEASE_DIR is None: - fn = os.path.join(SRC_DIR_REPO, 'VERSION.txt') - if os.path.exists(fn): - with open(fn) as f: - for line in f: - n = re.match(r"(.*)\.(.*)\.(.*)\.(.*)", line) - if not n is None: - return n.group(1) + '.' + n.group(2) + '.' + n.group(3) + '.' + n.group(4) + post + dirs = [SRC_DIR, ROOT_DIR, SRC_DIR_REPO, SRC_DIR_LOCAL, os.path.join(ROOT_DIR, '..', '..')] + for d in dirs: + if os.path.exists(d): + print(d, ": ", os.listdir(d)) + fns = [os.path.join(d, 'scripts', 'VERSION.txt') for d in dirs] + for fn in fns: + print("loading version file", fn, "exists", os.path.exists(fn)) + if os.path.exists(fn): + with open(fn) as f: + for line in f: + n = re.match(r"(.*)\.(.*)\.(.*)\.(.*)", line) + if not n is None: + return n.group(1) + '.' + n.group(2) + '.' + n.group(3) + '.' + n.group(4) + post return "?.?.?.?" else: version = RELEASE_METADATA[0]