我对cmake很新。 我想在我的项目中添加eclipse paho,因此我使用" ExternalProject_add"。这是我的CMakeLists.txt的摘录:
ExternalProject_add(
libressl
URL ${CMAKE_SOURCE_DIR}/externals/libressl-2.5.0.tar.gz
CONFIGURE_COMMAND ./configure --disable-hardening --prefix=${CMAKE_BINARY_DIR}
BUILD_IN_SOURCE 1)
ExternalProject_add(
paho
DEPENDS libressl
URL ${CMAKE_SOURCE_DIR}/externals/eclipse-paho-mqtt-c-src-1.1.0.tar.gz
CMAKE_ARGS -DPAHO_WITH_SSL -DOPENSSL_INC_SEARCH_PATH=${CMAKE_SOURCE_DIR}/include -DOPENSSL_LIB_SEARCH_PATH=${CMAKE_SOURCE_DIR}/lib
BUILD_COMMAND make
BUILD_IN_SOURCE 1)
事情是libressl建设得很好。如您所见,它使用autoconf工具。
我的问题是paho在"配置步骤"中抛出错误。
~/projects/cmake_test/CL_Test/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /projects/cmake_test/CL_Test/build
:~/projects/cmake_test/CL_Test/build$ make
[ 50%] Built target libressl
[ 56%] Performing configure step for 'paho'
CMake Error at /projects/cmake_test/CL_Test/build/paho-prefix/src/paho-stamp/paho-configure-.cmake:16 (message):
Command failed: 1
'/usr/bin/cmake' '-DPAHO_WITH_SSL' '-DOPENSSL_INC_SEARCH_PATH=/home/hbaumann/projects/cmake_test/CL_Test/include' '-DOPENSSL_LIB_SEARCH_PATH=/home/hbaumann/projects/cmake_test/CL_Test/lib' '-GUnix Makefiles' '/projects/cmake_test/CL_Test/build/paho-prefix/src/paho'
CMakeFiles/paho.dir/build.make:107: recipe for target 'paho-prefix/src/paho-stamp/paho-configure' failed
make[2]: *** [paho-prefix/src/paho-stamp/paho-configure] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/paho.dir/all' failed
make[1]: *** [CMakeFiles/paho.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
我想,由于paho是默认使用CMake构建的,所以我真的不需要添加。在这里你可以看到,我对CMake的了解非常少。
让我想知道的是,在paho tar-ball中,主文件夹中只有一个Makefile而不是CMakeLists.txt。
我想念的是什么......我需要设置一个特殊的配置命令吗?
事先提前答案 0 :(得分:2)
您可以使用GIT存储库,它有一个CMakeList.txt。
ExternalProject_add(
paho
DEPENDS libressl
GIT_REPOSITORY "https://github.com/eclipse/paho.mqtt.c.git"
GIT_TAG "master"
UPDATE_COMMAND ""
PATCH_COMMAND ""
SOURCE_DIR "${CMAKE_BINARY_DIR}/paho_sourcedir"
CMAKE_ARGS -DPAHO_WITH_SSL=TRUE -DOPENSSL_INC_SEARCH_PATH=${CMAKE_BINARY_DIR}/include -DOPENSSL_LIB_SEARCH_PATH=${CMAKE_BINARY_DIR}/lib -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/paho_prefix
)