移植ubux、libubox

https://cmake.org/cmake/help/v3.12/manual/cmake-toolchains.7.html   //cmake官方学习网站

 

1. download

git clone https://github.com/json-c/json-c.git
git clone http://git.openwrt.org/project/libubox.git
git clone http://nbd.name/gitweb.cgi?p=luci2/ubus.git
git clone https://git.openwrt.org/project/ubus.git

2. build

- ubus
cmake -DBUILD_LUA=OFF -DCMAKE_INSTALL_PREFIX=../install/ -DCMAKE_TOOLCHAIN_FILE=../toolChain_ubus.cmake .
make

- libubox
cmake -DBUILD_LUA=OFF -DCMAKE_INSTALL_PREFIX=../install/ -DCMAKE_TOOLCHAIN_FILE=../toolChain_libubox.cmake .
make

- json
cmake -DCMAKE_INSTALL_PREFIX=../install/ -DCMAKE_TOOLCHAIN_FILE=../toolChain_json.cmake .
make

下面是几个cmake文件,把编译器路径,和json、libubox、ubux路径换成自己的就可以了

3. toolChain_json.cmake

set(CMAKE_SYSTEM_NAME Linux)

SET(TOOLCHAIN_DIR "/home/chen/ws/cs/1903_new/toolchain/gcc-linaro-4.8-2015.06-x86_64_aarch64-linux-gnu")
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-g++)

set(CMAKE_FIND_ROOT_PATH $(TOOLCHAIN_DIR))
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

4. toolChain_libubox.cmake

 

set(CMAKE_SYSTEM_NAME Linux)

SET(TOOLCHAIN_DIR "/home/chen/ws/cs/1903_new/toolchain/gcc-linaro-4.8-2015.06-x86_64_aarch64-linux-gnu")
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-g++)


set(INSTALL_PATH "/home/chen/package/opensrc/openwrt/install")
include_directories(${INSTALL_PATH}/include)
include_directories(${INSTALL_PATH}/include/json-c)

set(CMAKE_FIND_ROOT_PATH $(TOOLCHAIN_DIR) $(INSTALL_PATH))
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(json "/home/chen/package/opensrc/openwrt/install/lib/libjson-c.so")

5. toolChain_ubus.cmake

set(CMAKE_SYSTEM_NAME Linux)

SET(TOOLCHAIN_DIR "/home/chen/ws/cs/1903_new/toolchain/gcc-linaro-4.8-2015.06-x86_64_aarch64-linux-gnu")
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-g++)


set(INSTALL_PATH "/home/chen/package/opensrc/openwrt/install")
include_directories(${INSTALL_PATH}/include)

set(CMAKE_FIND_ROOT_PATH $(TOOLCHAIN_DIR) $(INSTALL_PATH))
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(blob_library "/home/chen/package/opensrc/openwrt/install/lib/libblobmsg_json.so")
set(json "/home/chen/package/opensrc/openwrt/install/lib/libjson-c.so")
set(ubox_include_dir "/home/chen/package/opensrc/openwrt/install/include")
set(ubox_library "/home/chen/package/opensrc/openwrt/install/lib/libubox.so")

 

你可能感兴趣的:(移植ubux、libubox)