mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 00:55:31 +00:00
[CMake] Implement generation of Z3Config.cmake
and Z3Target.cmake
file for the build and install tree. These files allow users of CMake to use Z3 via a CMake config package. Clients can do `find_package(Z3 CONFIG)` to get use the package from their projects. When generating the files for the install tree we try to generate the files so that they are relocatable so that it shouldn't matter if the installed files aren't in the CMAKE_INSTALL_PREFIX when a user consumes them. As long as the relative locations of the files aren't changed things should still work. A new CMake cache variable `CMAKE_INSTALL_Z3_CMAKE_PACKAGE_DIR` has been added so that the install location of the Z3 CMake package files can be controlled. This addresses #915 .
This commit is contained in:
parent
e2933350b2
commit
73614abf37
4 changed files with 110 additions and 0 deletions
30
contrib/cmake/cmake/Z3Config.cmake.in
Normal file
30
contrib/cmake/cmake/Z3Config.cmake.in
Normal file
|
@ -0,0 +1,30 @@
|
|||
################################################################################
|
||||
# @AUTO_GEN_MSG@
|
||||
#
|
||||
# This file is intended to be consumed by clients who wish to use Z3 from CMake.
|
||||
# It can be use by doing `find_package(Z3 config)` from within a
|
||||
# `CMakeLists.txt` file. If CMake doesn't find this package automatically you
|
||||
# can give it a hint by passing `-DZ3_DIR=<path>` to the CMake invocation where
|
||||
# `<path>` is the path to the directory containing this file.
|
||||
#
|
||||
# This file was built for the @CONFIG_FILE_TYPE@.
|
||||
################################################################################
|
||||
|
||||
# Exported targets
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/Z3Targets.cmake")
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
# Version information
|
||||
set(Z3_VERSION_MAJOR @Z3_VERSION_MAJOR@)
|
||||
set(Z3_VERSION_MINOR @Z3_VERSION_MINOR@)
|
||||
set(Z3_VERSION_PATCH @Z3_VERSION_PATCH@)
|
||||
set(Z3_VERSION_TWEAK @Z3_VERSION_TWEAK@)
|
||||
set(Z3_VERSION_STRING "${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}.${Z3_VERSION_TWEAK}")
|
||||
|
||||
# NOTE: We can't use `set_and_check()` here because this a list of paths.
|
||||
# List of include directories
|
||||
set(Z3_C_INCLUDE_DIRS @PACKAGE_Z3_FIRST_PACKAGE_INCLUDE_DIR@ @PACKAGE_Z3_SECOND_PACKAGE_INCLUDE_DIR@)
|
||||
set(Z3_CXX_INCLUDE_DIRS @PACKAGE_Z3_CXX_PACKAGE_INCLUDE_DIR@ ${Z3_C_INCLUDE_DIRS})
|
||||
# List of libraries to link against
|
||||
set(Z3_LIBRARIES "z3::libz3")
|
|
@ -168,6 +168,7 @@ foreach (header ${libz3_public_headers})
|
|||
endforeach()
|
||||
|
||||
install(TARGETS libz3
|
||||
EXPORT Z3_EXPORTED_TARGETS
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" # On Windows this installs ``libz3.lib`` which CMake calls the "corresponding import library". Do we want this installed?
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}" # For Windows. DLLs are runtime targets for CMake
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue