cmake - CMakeLists:未找到 Z3Config.cmake
问题描述
我使用 make 和 GCC 构建了最新版本的 Z3 ( https://github.com/Z3Prover/z3 ),在 Ubuntu 系统中没有任何问题。
但是,在尝试构建使用 Z3 api 的小型 C 项目时,我收到以下消息错误:
CMake Error at CMakeLists.txt:9 (find_package):
By not providing "FindZ3.cmake" in CMAKE_MODULE_PATH this project has asked
CMake to find a package configuration file provided by "Z3", but CMake did
not find one.
Could not find a package configuration file provided by "Z3" with any of
the following names:
Z3Config.cmake
z3-config.cmake
Add the installation prefix of "Z3" to CMAKE_PREFIX_PATH or set "Z3_DIR" to
a directory containing one of the above files. If "Z3" provides a separate
development package or SDK, be sure it has been installed.
CMakeLists.txt 文件如下所示:
cmake_minimum_required(VERSION 3.14)
project(Z3APITest C CXX)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
find_package(Z3 REQUIRED CONFIG /home/roscai/Documents/Tools/Z3/cmake)
message(STATUS "Z3_FOUND: ${Z3_FOUND}")
message(STATUS "Found Z3 ${Z3_VERSION_STRING}")
message(STATUS "Z3_DIR: ${Z3_DIR}")
add_executable(Z3APITest EXCLUDE_FROM ALL main.c)
option(FORCE_CXX_LINKER "Force linker with C++ linker" OFF)
if (FORCE_CXX_LINKER)
# This is a hack for avoiding UBSan linking errors
message(STATUS "Forcing use of C++ linker")
set_target_properties(c_example
PROPERTIES
LINKER_LANGUAGE CXX
)
endif()
include_directories("${Z3_C_INCLUDE_DIR}")
include_directories("${Z3_INCLUDE_DIR}")
target_link_libraries(c_example PRIVATE ${Z3_LIBRARIES})
target_include_directories(c_example PRIVATE ${Z3_C_INCLUDE_DIRS})
更新:
修复代码中的类型后,出现以下错误:
CMake Error at CMakeLists.txt:9 (find_package):
find_package called with invalid argument
"/home/roscai/Documents/Tools/Z3/cmake"
-- Z3_FOUND:
-- Found Z3
-- Z3_DIR: Z3_DIR-NOTFOUND
CMake Error at CMakeLists.txt:31 (target_link_libraries):
Cannot specify link libraries for target "c_example" which is not built by
this project.
我很感激任何想法如何解决这个问题。
谢谢!
解决方案
推荐阅读
- r - 使用包“fruclimadapt”的 mutate() 输入出现错误问题
- gps - gpsd 用什么格式喂食?
- amazon-web-services - 我可以将一个 AWS 账户用于需要 SES 的多个网站吗?
- sql - 存储过程:从表“A”中选择数据并在表“B”中插入数据
- javascript - 为什么我的环境变量在反应中未定义?
- android - 如何在 adnroid 中更新 Room 版本?
- python - 为什么我得到不同的 roc_auc_scores?
- javascript - AG Grid 在初始化时展开行
- excel - @ 运算符在不需要时出现
- jsf-2.2 - Mojarra 2.2 中与 Flash 相关的 cookie 问题