未能在CMAKE项目中使用XercesC

时间:2019-01-28 10:32:40

标签: c++ cmake xerces xerces-c

我正在尝试创建一个CMAKE项目,该项目链接到Windows上的xerces-c。 Xerces-C是使用cmake构建的,并安装在文件夹中。这是安装的布局:

/root/home/.profile

这是我的CMakeFile.txt

xercesc/3.2.2
  |
  |-bin
  |  |-xerces-c_3_2.dll
  |  |-xerces-c_3_2D.dll
  |  |-(many executables)
  |
  |-cmake
  |  |-XercesCConfig.cmake
  |  |-XercesCConfigInterna.cmale
  |  |-(other .cmake)
  |
  |-include
  |  |-xercesc
  |     |-dom
  |     |-framework
  |     |-internal
  |     |-parsers
  |     |-util
  |     |-(other folders)
  |
  |-lib
  |  |-xerces-c_3.lib
  |  |-xerces-c_3D.lib
  |
  |-share
     |-doc
        |-(documentation

cmake_minimum_required (VERSION 3.10.0) project (myproject) set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${XERCES_ROOT}) message (STATUS "CMAKE_INCLUDE_PATH is ${CMAKE_INCLUDE_PATH}") find_package (XercesC REQUIRED) set (CMAKE_INCLUDE_CURRENT_DIR ON) include_directories (${CMAKE_CURRENT_SOURCE_DIR}/..) include_directories (${XercesC_INCLUDE_DIR}) set (PROJECT_SRC Dummy.cpp ) add_library (${PROJECT_NAME} SHARED ${PROJECT_SRC}) 是在我的主CMakeLists.txt中定义的变量

XERCES_ROOT

我使用以下命令执行cmake:

set (XERCES_ROOT "" CACHE FILEPATH "Root directory of the Xerces-C installation")

执行cmake时,我将打印 cmake -DBOOST_ROOT=D:\lib\Boost\1.69.0\ -DXERCES_ROOT=d:\lib\xercesc\3.2.2\ -G "Visual Studio 15 2017 Win64" ../ 的内容:

CMAKE_INCLUDE_PATH

那是正确的位置。我在-- CMAKE_INCLUDE_PATH is D:/lib/xercesc/3.2.2 行的前面设置了此变量。

但是找不到包。这是错误消息:

find_package(XercesC REQUIRED)

我做错了什么?我该怎么做才能告诉CMAKE在哪里可以找到Xerces?也许CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Failed to find XercesC (missing: XercesC_LIBRARY XercesC_INCLUDE_DIR XercesC_VERSION) Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) C:/Program Files/CMake/share/cmake-3.13/Modules/FindXercesC.cmake:98 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) src/myproject/CMakeLists.txt:7 (find_package) -- Configuring incomplete, errors occurred! 的用法有误?

1 个答案:

答案 0 :(得分:1)

对于在项目中使用的有关外部软件包根目录的提示CMake,可以在.value(function(d){return d.value["suicides_no"]}); 变量中提示该根目录:

CMAKE_PREFIX_PATH

这样,您的cmake -DCMAKE_PREFIX_PATH=d:\lib\xercesc\3.2.2\ <other-options> 根本不需要理会这些提示:它只使用CMakeLists.txt并期望一切正常。

另请参阅that my answer,以了解使用find_package()变量的其他方式以及该变量的其他功能。