3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 03:15:50 +00:00

api: dotnet: install nuget package and register local repo; xplat native assembly detection

This commit is contained in:
Yatao Li 2018-09-10 13:19:48 +08:00
parent 90890e46a9
commit 969a922145
3 changed files with 37 additions and 18 deletions

View file

@ -137,21 +137,34 @@ endforeach()
# FindDotnet.cmake forwards CMake build type to MSBuild.
# And thus we can put the conditional properties in the project file.
# Note, nuget package file names do not have the ${VER_REV} part.
set(Z3_DOTNET_NUPKG_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.csproj.in ${CMAKE_CURRENT_BINARY_DIR}/build/Microsoft.Z3.csproj)
ADD_DOTNET(${CMAKE_CURRENT_BINARY_DIR}/build/Microsoft.Z3.csproj
# note, nuget package file names do not have the ${VER_REV} part.
VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}"
VERSION ${Z3_DOTNET_NUPKG_VERSION}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.csproj.in
PACKAGE Microsoft.Z3)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/buildtimestamp
DEPENDS ${Z3_DOTNET_ASSEMBLY_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.csproj.in
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/buildtimestamp)
add_custom_target(Z3_DOTNET_BUILD_DUMMY ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/buildtimestamp)
add_dependencies(BUILD_Microsoft.Z3 Z3_DOTNET_BUILD_DUMMY libz3)
add_dependencies(BUILD_Microsoft.Z3 libz3)
# Convenient top-level target
add_custom_target(build_z3_dotnet_bindings ALL DEPENDS BUILD_Microsoft.Z3)
#TODO install
###############################################################################
# Install: register a local nuget repo and install our package.
# the build step depends on the 'purge' target, making sure that
# a user will always restore the freshly-built package.
###############################################################################
option(INSTALL_DOTNET_BINDINGS "Install .NET bindings when invoking install target" ON)
if(INSTALL_DOTNET_BINDINGS)
install(FILES "${CMAKE_BINARY_DIR}/Microsoft.Z3.${Z3_DOTNET_NUPKG_VERSION}.nupkg" DESTINATION "${CMAKE_INSTALL_LIBDIR}/z3.nuget")
install(CODE "include(${CMAKE_CURRENT_LIST_DIR}/../../../cmake/modules/FindDotnet.cmake)\n DOTNET_REGISTER_LOCAL_REPOSITORY(Microsoft.Z3.LocalBuild ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/z3.nuget)")
# TODO docs?
# install(FILES "${Z3_DOTNET_ASSEMBLY_DLL_DOC}" DESTINATION "${CMAKE_INSTALL_LIBDIR}")
# TODO GAC?
# set(GAC_PKG_NAME "Microsoft.Z3.Sharp")
# set(PREFIX "${CMAKE_INSTALL_PREFIX}")
# set(VERSION "${Z3_VERSION}")
endif()

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Net.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<!-- Package metadata properties -->
<PropertyGroup>
@ -58,11 +58,13 @@ ${Z3_DOTNET_COMPILE_ITEMS}
<!-- Native binaries -->
<ItemGroup>
<!-- FIXME configuration fixed to Release -->
<Content Include="${CMAKE_BINARY_DIR}/Release/libz3.dll" Condition="Exists('${CMAKE_BINARY_DIR}/Release/libz3.dll')">
<!--TODO detect if we're building x86.-->
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.dll" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.dll')">
<PackagePath>runtimes\win-x64\native</PackagePath>
</Content>
<!-- TODO XPlat support -->
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.so" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.so')">
<PackagePath>runtimes\linux-x64\native</PackagePath>
</Content>
</ItemGroup>
<!-- NuGet package references -->