mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 19:35:50 +00:00
[CMake] Implement support for building the .NET bindings.
When using Mono support for installing/uninstalling the bindings is also implemented. For Windows install/uninstall is not implemented because the python build system does not implement it and Microsoft's documentation (https://msdn.microsoft.com/en-us/library/dkkx7f79.aspx) says that the gacutil should only be used for development and not for production. For now a warning is just emitted if ``INSTALL_DOTNET_BINDINGS`` is enabled and the .NET toolchain is native Windows. Someone with better knowledge of how to correctly install assemblies under Windows should implement this or remove this message. A notable difference from the Python build system is the ``/linkresource:`` flag is not passed to the C# compiler. This means a user of the .NET bindings will have to copy the Z3 library (i.e. ``libz3.dll``) to their application directory manually. The reason for this difference is that using this flag requires the working directory to be the directory containing the Z3 library (i.e. ``libz3.dll``) but setting this up with multi-configuration generators doesn't currently seem possible.
This commit is contained in:
parent
6a2a8e06d7
commit
20d3bf4d0c
8 changed files with 390 additions and 0 deletions
53
contrib/cmake/cmake/modules/FindDotNetToolchain.cmake
Normal file
53
contrib/cmake/cmake/modules/FindDotNetToolchain.cmake
Normal file
|
@ -0,0 +1,53 @@
|
|||
# Tries to find a working .NET tool chain
|
||||
#
|
||||
# Once complete this will define
|
||||
# DOTNET_TOOLCHAIN_FOUND : BOOL : System has a .NET toolchain
|
||||
# DOTNET_CSC_EXECUTABLE - STRING : Path to C# compiler
|
||||
# DOTNET_GACUTIL_EXECUTABLE - STRING : Path to gacutil
|
||||
# DOTNET_TOOLCHAIN_IS_MONO : BOOL : True if detected .NET toolchain is Mono
|
||||
# DOTNET_TOOLCHAIN_IS_WINDOWS : BOOL : True if detected .NET toolchain is native Windows
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_program(
|
||||
DOTNET_CSC_EXECUTABLE
|
||||
NAMES "csc.exe" "mcs" "dmcs"
|
||||
)
|
||||
message(STATUS "DOTNET_CSC_EXECUTABLE: \"${DOTNET_CSC_EXECUTABLE}\"")
|
||||
|
||||
find_program(
|
||||
DOTNET_GACUTIL_EXECUTABLE
|
||||
NAMES "gacutil.exe" "gacutil"
|
||||
)
|
||||
message(STATUS "DOTNET_GACUTIL_EXECUTABLE: \"${DOTNET_GACUTIL_EXECUTABLE}\"")
|
||||
|
||||
# Try to determine the tool chain vendor
|
||||
set(DOTNET_DETERMINED_VENDOR FALSE)
|
||||
if (DOTNET_CSC_EXECUTABLE)
|
||||
execute_process(COMMAND "${DOTNET_CSC_EXECUTABLE}" "/help"
|
||||
RESULT_VARIABLE CSC_EXIT_CODE
|
||||
OUTPUT_VARIABLE CSC_STD_OUT
|
||||
)
|
||||
if (${CSC_EXIT_CODE} EQUAL 0)
|
||||
if ("${CSC_STD_OUT}" MATCHES "^Mono[ ]+C#")
|
||||
set(DOTNET_DETERMINED_VENDOR TRUE)
|
||||
set(DOTNET_TOOLCHAIN_IS_MONO TRUE)
|
||||
set(DOTNET_TOOLCHAIN_IS_WINDOWS FALSE)
|
||||
message(STATUS ".NET toolchain is Mono")
|
||||
elseif ("${CSC_STD_OUT}" MATCHES "^Microsoft.+Visual[ ]+C#")
|
||||
set(DOTNET_DETERMINED_VENDOR TRUE)
|
||||
set(DOTNET_TOOLCHAIN_IS_MONO FALSE)
|
||||
set(DOTNET_TOOLCHAIN_IS_WINDOWS TRUE)
|
||||
message(STATUS ".NET toolchain is Windows native")
|
||||
else()
|
||||
message(STATUS ".NET toolchain is unknown")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# TODO: Check C# compiler works
|
||||
|
||||
find_package_handle_standard_args(DotNetToolChain DEFAULT_MSG
|
||||
DOTNET_CSC_EXECUTABLE
|
||||
DOTNET_GACUTIL_EXECUTABLE
|
||||
DOTNET_DETERMINED_VENDOR
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue