2016-10-08 4 views
0

私は、piプロジェクトで必要なライブラリ用のクロスコンパイルプロジェクトを設定しています。私は最新のモスキート図書館を渡りたいと思っています。私はそれが正しく構築されるために渡す必要があるものを見つけました。残念なことに私がBUILD_COMMANDを定義すると、makeを呼び出す前に変数を正しく設定することができないようです。ここで cmake:外部プロジェクトでmakeに先立って変数を正しく設定するにはどうすればよいですか?

は、外部プロジェクトは、私のCMakeLists.txtに定義されています。

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

私はそれがあることを発見した:ここで

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 

が失敗したステップのメイク出力であります問題の原因となっている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の引数をより適切に作成するにはどうすればよいですか?

ありがとうございます!

答えて

0

ExternalProject_Addのコマンドがたくさんある場合、それらを実行するスクリプトを使用することが賢明かもしれません。

build_mosquitto.sh.in:

# The only argument to the script is mosquitto's source directory. 
source_dir=$1 

exports CC=gcc 
export CXX=g++ 
export [email protected][email protected] 
# ... other exports 

cd ${source_dir}/lib && make 

CMakeLists.txtスクリプトにCMakeの変数を渡すためとして、彼らは、またはスクリプト自体の構成を介して、スクリプトの引数で渡すことができます。

configure_file("build_mosquitto.sh.in" "build_mosquitto.sh" @ONLY) 

ExternalProject_Add(mosquitto 
    URL ${SRC_URL} URL_MD5 ${SRC_MD5} 
    BUILD_IN_SOURCE 1 
    CONFIGURE_COMMAND echo "No configuration necessary." 
    BUILD_COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/build_mosquitto.sh" <SOURCE_DIR> 
) 
関連する問題