-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
106 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
macro(p4tools_obtain_z3) | ||
option(TOOLS_USE_PREINSTALLED_Z3 "Look for a preinstalled version of Z3 instead of installing a prebuilt binary using FetchContent." OFF) | ||
|
||
if(TOOLS_USE_PREINSTALLED_Z3) | ||
# We need a fairly recent version of Z3. | ||
set(Z3_MIN_VERSION "4.8.14") | ||
# But 4.12+ is currently broken with libGC | ||
set(Z3_MAX_VERSION_EXCL "4.12") | ||
find_package(Z3 ${Z3_MIN_VERSION} REQUIRED) | ||
|
||
if(NOT DEFINED Z3_VERSION_STRING OR ${Z3_VERSION_STRING} VERSION_LESS ${Z3_MIN_VERSION}) | ||
message(FATAL_ERROR "The minimum required Z3 version is ${Z3_MIN_VERSION}. Has ${Z3_VERSION_STRING}.") | ||
endif() | ||
if(${Z3_VERSION_STRING} VERSION_GREATER_EQUAL ${Z3_MAX_VERSION_EXCL}) | ||
message(FATAL_ERROR "The Z3 version has to be lower than ${Z3_MAX_VERSION_EXCL} (the latter currently does no work with libGC). Has ${Z3_VERSION_STRING}.") | ||
endif() | ||
# Set variables for later consumption. | ||
set(P4TOOLS_Z3_LIB z3::z3) | ||
set(P4TOOLS_Z3_INCLUDE_DIR ${Z3_INCLUDE_DIR}) | ||
else() | ||
# Pull in a specific version of Z3 and link against it. | ||
set(P4TOOLS_Z3_VERSION "4.13.0") | ||
message(STATUS "Fetching Z3 version ${P4TOOLS_Z3_VERSION} for P4Tools...") | ||
|
||
# Unity builds do not work for Protobuf... | ||
set(CMAKE_UNITY_BUILD_PREV ${CMAKE_UNITY_BUILD}) | ||
set(CMAKE_UNITY_BUILD OFF) | ||
# Print out download state while setting up Z3. | ||
set(FETCHCONTENT_QUIET_PREV ${FETCHCONTENT_QUIET}) | ||
set(FETCHCONTENT_QUIET OFF) | ||
|
||
set(Z3_BUILD_LIBZ3_SHARED OFF CACHE BOOL "Build libz3 as a shared library if true, otherwise build a static library") | ||
set(Z3_INCLUDE_GIT_HASH OFF CACHE BOOL "Include git hash in version output") | ||
set(Z3_INCLUDE_GIT_DESCRIBE OFF CACHE BOOL "Include git describe output in version output") | ||
fetchcontent_declare( | ||
z3 | ||
GIT_REPOSITORY https://github.com/Z3Prover/z3.git | ||
GIT_TAG z3-${P4TOOLS_Z3_VERSION} # 4.13.0 | ||
GIT_PROGRESS TRUE | ||
GIT_SHALLOW TRUE | ||
# We need to patch because the Z3 CMakeLists.txt also adds an uinstall target. | ||
# This leads to a namespace clash. | ||
PATCH_COMMAND | ||
git apply ${P4TOOLS_SOURCE_DIR}/cmake/z3.patch || git apply | ||
${P4TOOLS_SOURCE_DIR}/cmake/z3.patch -R --check && echo | ||
"Patch does not apply because the patch was already applied." | ||
) | ||
fetchcontent_makeavailable_but_exclude_install(z3) | ||
|
||
# Suppress warnings for all Z3 targets. | ||
get_all_targets(Z3_BUILD_TARGETS ${z3_SOURCE_DIR}) | ||
foreach(target ${Z3_BUILD_TARGETS}) | ||
# Do not suppress warnings for Z3 library targets that are aliased. | ||
get_target_property(target_type ${target} TYPE) | ||
if (NOT ${target_type} STREQUAL "INTERFACE_LIBRARY") | ||
target_compile_options(${target} PRIVATE "-Wno-error" "-w") | ||
endif() | ||
endforeach() | ||
|
||
# Reset temporary variable modifications. | ||
set(CMAKE_UNITY_BUILD ${CMAKE_UNITY_BUILD_PREV}) | ||
set(FETCHCONTENT_QUIET ${FETCHCONTENT_QUIET_PREV}) | ||
|
||
# Other projects may also pull in Z3. | ||
# We have to make sure we only include our local version with P4Tools. | ||
set(P4TOOLS_Z3_LIB libz3) | ||
set(P4TOOLS_Z3_INCLUDE_DIR ${z3_SOURCE_DIR}/src/api ${z3_SOURCE_DIR}/src/api/c++) | ||
endif() | ||
|
||
message(STATUS "Done with setting up Z3 for P4Tools.") | ||
endmacro(p4tools_obtain_z3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index ba3ec7bce..7ca1894fd 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -446,13 +446,13 @@ configure_file( | ||
|
||
# Target needs to be declared before the components so that they can add | ||
# dependencies to this target so they can run their own custom uninstall rules. | ||
-add_custom_target(uninstall | ||
- COMMAND | ||
- "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | ||
- COMMENT "Uninstalling..." | ||
- USES_TERMINAL | ||
- VERBATIM | ||
-) | ||
+# add_custom_target(uninstall | ||
+# COMMAND | ||
+# "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | ||
+# COMMENT "Uninstalling..." | ||
+# USES_TERMINAL | ||
+# VERBATIM | ||
+# ) | ||
|
||
################################################################################ | ||
# CMake build file locations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters