CMakeLists:找不到Z3Config.cmake

时间:2019-07-11 09:40:56

标签: cmake z3 configuration-files

我已经使用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. 

我很高兴知道如何解决此问题。

谢谢!

0 个答案:

没有答案