From 7cedf79b38ddfec21e8be0786cf2b558f0684d5f Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 26 Apr 2016 00:06:36 +0100 Subject: [PATCH 1/3] [CMake] When building the ".NET" bindings emit ``Microsoft.Z3.dll`` and ``Microsoft.Z3.xml`` to the root build directory rather than ``/src/api/dotnet``. This fixes #573 which makes the behaviour consistent with the Python build system. --- contrib/cmake/src/api/dotnet/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/cmake/src/api/dotnet/CMakeLists.txt b/contrib/cmake/src/api/dotnet/CMakeLists.txt index f077b57ce..fdde298a0 100644 --- a/contrib/cmake/src/api/dotnet/CMakeLists.txt +++ b/contrib/cmake/src/api/dotnet/CMakeLists.txt @@ -206,9 +206,9 @@ endif() # FIXME: The get_property() command only works correctly for single configuration generators # so we can't use it. We also can't use ``$`` because the ``OUTPUT`` # argument to ``add_custom_commands()`` won't accept it. For now just output file to the -# current binary directory. +# root binary directory like the Python build system does. # get_property(Z3_DOTNET_ASSEMBLY_OUTPUT_DIR TARGET libz3 PROPERTY LIBRARY_OUTPUT_DIRECTORY) -set(Z3_DOTNET_ASSEMBLY_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") +set(Z3_DOTNET_ASSEMBLY_OUTPUT_DIR "${CMAKE_BINARY_DIR}") set(Z3_DOTNET_ASSEMBLY_NAME "Microsoft.Z3.dll") set(Z3_DOTNET_ASSEMBLY_DLL "${Z3_DOTNET_ASSEMBLY_OUTPUT_DIR}/${Z3_DOTNET_ASSEMBLY_NAME}") # csc.exe doesn't work with UNIX style paths so convert to native path From 7213280d9b5544bf82888a8266699d70d55e28f7 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 26 Apr 2016 00:22:39 +0100 Subject: [PATCH 2/3] [CMake] Emit a warning when configuring to build the ``.NET`` bindings under a multi-configuration generator (e.g. Visual Studio). The warning concerns different generated files clobbering each other. Unfortunately there isn't a clean way to fix this right now. See http://public.kitware.com/pipermail/cmake/2016-March/063101.html --- contrib/cmake/src/api/dotnet/CMakeLists.txt | 26 ++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/contrib/cmake/src/api/dotnet/CMakeLists.txt b/contrib/cmake/src/api/dotnet/CMakeLists.txt index fdde298a0..e8fa12292 100644 --- a/contrib/cmake/src/api/dotnet/CMakeLists.txt +++ b/contrib/cmake/src/api/dotnet/CMakeLists.txt @@ -203,11 +203,23 @@ if (DOTNET_TOOLCHAIN_IS_WINDOWS) endif() endif() -# FIXME: The get_property() command only works correctly for single configuration generators -# so we can't use it. We also can't use ``$`` because the ``OUTPUT`` -# argument to ``add_custom_commands()`` won't accept it. For now just output file to the -# root binary directory like the Python build system does. -# get_property(Z3_DOTNET_ASSEMBLY_OUTPUT_DIR TARGET libz3 PROPERTY LIBRARY_OUTPUT_DIRECTORY) +# FIXME: Ideally we should emit files into a configuration specific directory +# when using multi-configuration generators so that the files generated by each +# configuration don't clobber each other. Unfortunately the ``get_property()`` +# command only works correctly for single configuration generators so we can't +# use it. We also can't use ``$`` because the ``OUTPUT`` +# argument to ``add_custom_commands()`` won't accept it. +# See http://public.kitware.com/pipermail/cmake/2016-March/063101.html +# +# For now just output file to the root binary directory like the Python build +# system does and emit a warning when appropriate. +if (DEFINED CMAKE_CONFIGURATION_TYPES) + # Multi-configuration build (e.g. Visual Studio and Xcode). + message(WARNING "You are using a multi-configuration generator. The build rules for" + " the \".NET\" bindings currently do not emit files per configuration so previously" + " generated files for other configurations will be overwritten.") +endif() + set(Z3_DOTNET_ASSEMBLY_OUTPUT_DIR "${CMAKE_BINARY_DIR}") set(Z3_DOTNET_ASSEMBLY_NAME "Microsoft.Z3.dll") set(Z3_DOTNET_ASSEMBLY_DLL "${Z3_DOTNET_ASSEMBLY_OUTPUT_DIR}/${Z3_DOTNET_ASSEMBLY_NAME}") @@ -252,7 +264,9 @@ if (DOTNET_TOOLCHAIN_IS_MONO) # to find the assembly install(FILES "${Z3_DOTNET_PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_PKGCONFIGDIR}") - # Configure the install and uninstall scripts + # Configure the install and uninstall scripts. + # Note: If multi-configuration generator support is ever fixed then these + # scripts will be broken. configure_file(cmake_install_gac.cmake.in cmake_install_gac.cmake @ONLY) configure_file(cmake_uninstall_gac.cmake.in cmake_uninstall_gac.cmake @ONLY) From 626e0736d23df44b591c08edc7c77268292c3b0e Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 26 Apr 2016 08:47:52 +0100 Subject: [PATCH 3/3] [CMake] Implement installation of ".NET" bindings on Windows. We don't install Z3_DOTNET_ASSEMBLY_DLL into the gac. Instead we just copy into installation directory. There are several reasons for this: * We can't install the Z3_DOTNET_ASSEMBLY_DLL into the gac in a portable way like we can with mono (i.e. the ``-root`` flag). * It isn't best practice to use ``gacutil.exe`` on Windows to install into the GAC, see https://msdn.microsoft.com/en-us/library/yf1d93sz(v=vs.110).aspx . Taking this approach should be sufficient because we can now do something like this ``` mkdir build cmake -G Ninja -DCMAKE_INSTALL_PREFIX= ../ ninja mkdir ninja install ``` and then put the contents of into a zip file which creates a redistributable zip file for Windows. --- contrib/cmake/src/api/dotnet/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/cmake/src/api/dotnet/CMakeLists.txt b/contrib/cmake/src/api/dotnet/CMakeLists.txt index e8fa12292..7440f021b 100644 --- a/contrib/cmake/src/api/dotnet/CMakeLists.txt +++ b/contrib/cmake/src/api/dotnet/CMakeLists.txt @@ -282,9 +282,10 @@ if (DOTNET_TOOLCHAIN_IS_MONO) add_dependencies(uninstall remove_dotnet_dll_from_gac) elseif(DOTNET_TOOLCHAIN_IS_WINDOWS) - # FIXME: This isn't implemented because I'm not sure how/if the assembly should - # be installed to the GAC. - message(WARNING "Install of .NET bindings is not implemented for Windows") + # Don't install Z3_DOTNET_ASSEMBLY_DLL into the gac. Instead just copy into + # installation directory. + install(FILES "${Z3_DOTNET_ASSEMBLY_DLL}" DESTINATION "${CMAKE_INSTALL_LIBDIR}") + install(FILES "${Z3_DOTNET_ASSEMBLY_DLL_DOC}" DESTINATION "${CMAKE_INSTALL_LIBDIR}") else() message(FATAL_ERROR "Unknown .NET toolchain") endif()