许多实用cmake的开源项目在移植到其他平台时,还是比较麻烦的。
这里以jsoncpp为例。
首先,我本机的交叉编译工具及目录是:
# which arm-linux-gnueabihf-gcc
/root/board/tools/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin/arm-linux-gnueabihf-gcc
从github上clone代码:
# git clone https://github.com/open-source-parsers/jsoncpp.git
编写tool chain file,可以参考这个:
根据自己的配置改下如下:
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER /root/board/tools/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /root/board/tools/gcc-linaro-arm-linux-gnueabihf-4.7-