使用CMake根据Swiften XMPP库构建项目

时间:2018-11-30 16:27:07

标签: c++ cmake swiften

我目前正在尝试使用CMake设置我的C ++项目,我成功包含了OpenMPI之类的依赖项,但是当转到Swiften时,这变得很复杂。这不是以包的形式提供的,而是如链接到那里的git存储库中所示。构建不是问题,但是我花了很多时间,却没有找到任何方法来包含不提供.so且没有主标头的库。 这是我当前的CMakeLists.txt,仅供测试使用。

cmake_minimum_required (VERSION 3.0.0)

#set the executable 
project (mtest)
set(EXECUTABLE_OUTPUT_PATH .)
add_executable (mtest main.cpp)

#defines libs
find_package(MPI REQUIRED)
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
include_directories(SYSTEM Swiften)
target_link_libraries(mtest ${MPI_LIBRARIES}) 

add_library(swiften SHARED IMPORTED) 
set_target_properties(swiften PROPERTIES
  IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/Swiften/libSwiften.a"
  INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/Swiften"
)
target_link_libraries(mtest swiften)

当尝试运行make时,会出现以下错误:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Documents/CTests/build
[ 50%] Building CXX object CMakeFiles/mtest.dir/main.cpp.o
/home/user/Documents/CTests/main.cpp:12:10: fatal error: Swiften/Client/Client.h: No such file or directory
 #include <Swiften/Client/Client.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/mtest.dir/build.make:62: recipe for target 'CMakeFiles/mtest.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/mtest.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mtest.dir/all' failed
make[1]: *** [CMakeFiles/mtest.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

顺便说一句,如果目录结构可以帮助您,则这是树状输出:​​https://pastebin.com/giPb9229

0 个答案:

没有答案