3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-05-15 22:55:33 +00:00
z3/examples/dotnet/CMakeLists.txt
Copilot bed73a3f43
Bump dotnet example target framework from netcoreapp2.0 to net8.0 (#9531)
- [x] Update `examples/dotnet/dotnet.csproj` target framework from
`netcoreapp2.0` to `net8.0`
- [x] Update `cmake/modules/FindDotnet.cmake`: replace all
`netcoreapp2.0` references (build options, pack options, dll path, test
framework args) with `net8.0`
- [x] Update `examples/dotnet/CMakeLists.txt`: fix hardcoded output path
from `netcoreapp2.0` to `net8.0`
- [x] Update `scripts/mk_util.py`: fix generated `.csproj` template from
`netcoreapp2.0` to `net8.0`

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-05-14 15:17:41 -07:00

34 lines
1.3 KiB
CMake

find_package(Dotnet REQUIRED)
if(TARGET_ARCHITECTURE STREQUAL "i686")
set(Z3_DOTNET_PLATFORM "x86")
else()
set(Z3_DOTNET_PLATFORM "AnyCPU")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dotnet.csproj dotnet.csproj COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Program.cs Program.cs COPYONLY)
ADD_DOTNET(${CMAKE_CURRENT_BINARY_DIR}/dotnet.csproj
PLATFORM ${Z3_DOTNET_PLATFORM}
NETCOREAPP
CUSTOM_BUILDPROPS "<Z3_VERSION>${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}</Z3_VERSION>"
DEPENDS Microsoft.Z3)
if(UNIX AND NOT APPLE)
set(z3_dotnet_native_lib ${PROJECT_BINARY_DIR}/libz3.so)
set(z3_dotnet_test_manual_copy_deps
${PROJECT_BINARY_DIR}/Microsoft.Z3/netstandard2.0/Microsoft.Z3.dll
${z3_dotnet_native_lib}
)
add_custom_target(
z3_dotnet_test_manual_copy_assembly_hack ALL
COMMAND ${CMAKE_COMMAND} -E copy ${z3_dotnet_test_manual_copy_deps} ${PROJECT_BINARY_DIR}/dotnet/net8.0/
# hack the libz3 entry in deps so it's easy enough for dotnet to reach it...
COMMAND sed \"s/runtimes\\/.*libz3\\.so/libz3.so/\" -i ${PROJECT_BINARY_DIR}/dotnet/net8.0/dotnet.deps.json
)
add_dependencies(z3_dotnet_test_manual_copy_assembly_hack BUILD_dotnet)
endif()