Topic: OpenWRT package / "does not appear to contain CMakeLists.txt."

Hi,

I like to create a new OpenWRT package.
So I started out to make a Hello World package:

packages/knode/Makefile
packages/knode/src/CMakeLists.txt
packages/knode/src/main.c


packages/knode/Makefile

include $(TOPDIR)/rules.mk

PKG_NAME:=knode
PKG_RELEASE:=0.1
PKG_RELEASE:=1


include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/knode
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Kademlia DHT implementation
endef


define Package/knode/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/knode $(1)/usr/bin
endef

$(eval $(call BuildPackage,knode))

packages/knode/src/CMakeLists.txt:

cmake_minimum_required(VERSION 2.6)
project(KNode)

add_executable(knode knode.c)

packages/knode/src/main.c

#include <stdio.h>

int main(int argc, char **argv)
{
    printf("Hello World!\n");
}

Building the package results in an error message:

CMake Error: The source directory "/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode" does not appear to contain CMakeLists.txt.

I've already tried to create a CMakeLists.txt in packages/knode/ but with no success.
Can someone point out what I have been doing wrong?

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

You need to define the prepare stage in your package Makefile:

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

3 (edited by mwarning 2013-04-11 03:07:01)

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Thank you for the answer!

I've added the Prepare part and it looks like it progressing slightly further.
But now there is another error:

CMake Error: The source directory "/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
make[3]: *** [/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1/.configured_] Error 1
make[3]: Leaving directory `/home/mwarning/openwrt/package/knode'
make[2]: *** [package/knode/compile] Error 2
make[2]: Leaving directory `/home/mwarning/openwrt'
make[1]: *** [/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/mwarning/openwrt'
make: *** [world] Error 2

The directory knode-0.1 is indeed empty.

This is the Makefile I used this time:

include $(TOPDIR)/rules.mk

PKG_NAME:=knode
PKG_VERSION:=0.1
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/knode
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Kademlia DHT implementation
endef

define Build/knode/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/knode/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/knode $(1)/usr/bin
endef

$(eval $(call BuildPackage,knode))

I have already looked at a few other packages, but they are somewhat different in most cases.

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Well. Here is working Makefile for your knode package

include $(TOPDIR)/rules.mk

PKG_NAME:=knode
PKG_VERSION:=0.1
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk


define Package/knode
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Kademlia DHT implementation
endef

define Package/knode/description
    Kademlia DHT implementation
endef

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/knode/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/knode $(1)/usr/bin/
endef

$(eval $(call BuildPackage,knode))

But you have mistake in source file smile Look attentively

5 (edited by mwarning 2013-04-11 21:47:17)

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Hi rusink,

I tried your Makefile and while the code seems to build successfully, but there is another error:

make[6]: Entering directory `/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1'
[100%] Building C object CMakeFiles/knode.dir/knode.c.o
Linking C executable knode
make[6]: Leaving directory `/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1'
[100%] Built target knode
make[5]: Leaving directory `/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1'
make[4]: Leaving directory `/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1'
CFLAGS="-Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float  -I/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/include -I/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/include -I/home/mwarning/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include -I/home/mwarning/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/include " CXXFLAGS="-Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float  -I/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/include -I/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/include -I/home/mwarning/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include -I/home/mwarning/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/include " LDFLAGS="-L/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib -L/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/lib -L/home/mwarning/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/usr/lib -L/home/mwarning/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/lib " make -C /home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1/. AR=mips-openwrt-linux-uclibc-ar AS="mips-openwrt-linux-uclibc-gcc -c -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float" LD=mips-openwrt-linux-uclibc-ld NM=mips-openwrt-linux-uclibc-nm CC="mips-openwrt-linux-uclibc-gcc" GCC="mips-openwrt-linux-uclibc-gcc" CXX="mips-openwrt-linux-uclibc-g++" RANLIB=mips-openwrt-linux-uclibc-ranlib STRIP=mips-openwrt-linux-uclibc-strip OBJCOPY=mips-openwrt-linux-uclibc-objcopy OBJDUMP=mips-openwrt-linux-uclibc-objdump SIZE=mips-openwrt-linux-uclibc-size CROSS="mips-openwrt-linux-uclibc-" ARCH="mips" DESTDIR="/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1/ipkg-install"  install;
make[4]: Entering directory `/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1'
make[4]: *** No rule to make target `install'.  Stop.
make[4]: Leaving directory `/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1'
make[3]: *** [/home/mwarning/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/knode-0.1/.built] Error 2
make[3]: Leaving directory `/home/mwarning/openwrt/package/knode'
make[2]: *** [package/knode/compile] Error 2
make[2]: Leaving directory `/home/mwarning/openwrt'
make[1]: *** [/home/mwarning/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/mwarning/openwrt'
make: *** [world] Error 2

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Your CMakeList.txt has no install target defined, add something like:

INSTALL(TARGETS knode RUNTIME DESTINATION sbin)

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Thanks a lot. Now it works!

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

I have made an example package on github for everyone to use:

https://github.com/mwarning/openwrt-example-program

9 (edited by rusink 2013-04-14 09:52:44)

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Excellent!

But why do you use differetnt instalation targets? sbin in CMakeLists.txt and usr/bin in top Makefile?

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Interesting point. I don't know how they interact.

On the router the binary is in /usr/bin/myapp.
Apparently the CMake install line is acting as a dummy.
But the previous errors show that I need it.
I will make them the same to avoid confusing.

Re: OpenWRT package / "does not appear to contain CMakeLists.txt."

Hi,

I'm adding this thread to the SDK page in the wiki.

Also, When I needed to build my helloWorld for OpenWrt I used
http://fleshandmachines.wordpress.com/2011/08/22/openwrt-cc-programing/


Regards,
Guy