我正在爲在pi項目中需要的庫設置交叉編譯項目。我想穿過最新的蚊子圖書館,我已經想出了我需要通過什麼來使它正確地建立。不幸的是,當我定義我的BUILD_COMMAND時,我似乎無法正確設置變量,使其在調用之前。cmake:如何在外部項目中正確設置變量前面的make?
這裏是我的CMakeLists.txt定義的外部項目:
ExternalProject_Add(mosquitto
URL ${SRC_URL} URL_MD5 ${SRC_MD5}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND echo "No configuration necessary."
BUILD_COMMAND cd <SOURCE_DIR>/lib && export CC=gcc && export CXX=g++ && export CROSS_COMPILE=${CROSS_COMPILE_TRIPLE} && export CFLAGS=--sysroot=${CMAKE_SYSROOT} && export LDFLAGS="--sysroot=${CMAKE_SYSROOT} -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf -L${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf" && make --trace
下面是步驟的化妝輸出失敗:
arm-linux-gnueabihf-gcc -shared "--sysroot=/home/heardg/pi/system/devroot -Wl,-rpath-link,/home/heardg/pi/system/devroot/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/heardg/pi/system/devroot/usr/lib/arm-linux-gnueabihf -L/home/heardg/pi/system/devroot/usr/lib/arm-linux-gnueabihf" -Wl,--version-script=linker.version -Wl,-soname,libmosquitto.so.1 mosquitto.o logging_mosq.o memory_mosq.o messages_mosq.o net_mosq.o read_handle.o read_handle_client.o read_handle_shared.o send_mosq.o send_client_mosq.o socks_mosq.o srv_mosq.o thread_mosq.o time_mosq.o tls_mosq.o util_mosq.o will_mosq.o -o libmosquitto.so.1 -lrt -lssl -lcrypto -lpthread -lcares /home/heardg/pi/linaro/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.4/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory /home/heardg/pi/linaro/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.4/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lrt /home/heardg/pi/linaro/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.4/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lssl /home/heardg/pi/linaro/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.4/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lcrypto /home/heardg/pi/linaro/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.4/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lpthread /home/heardg/pi/linaro/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.4/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lcares collect2: error: ld returned 1 exit status Makefile:46: recipe for target 'libmosquitto.so.1' failed
我發現,它是圍繞LDFLAGS引起問題的引號。
"--sysroot=/home/heardg/pi/system/devroot -Wl,-rpath-link,/home/heardg/pi/system/devroot/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/heardg/pi/system/devroot/usr/lib/arm-linux-gnueabihf -L/home/heardg/pi/system/devroot/usr/lib/arm-linux-gnueabihf"
如果我跑手的鏈接命令和刪除雙引號上述成功爲止。
如何更好地形成BUILD_COMMAND中的參數以擺脫引號?
謝謝!