--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(opkg C)
+
+OPTION(HOST_CPU "Override Host CPU")
+OPTION(BUILD_CPU "Override Host CPU")
+OPTION(STATIC_UBOX "Statically link libubox")
+OPTION(BUILD_TESTS "Build test programs" ON)
+
+IF(NOT HOST_CPU)
+ SET(HOST_CPU "${CMAKE_HOST_SYSTEM_PROCESSOR}")
+ENDIF()
+
+IF(NOT BUILD_CPU)
+ SET(BUILD_CPU "${CMAKE_SYSTEM_PROCESSOR}")
+ENDIF()
+
+ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -Wmissing-declarations
+ -DDATADIR="/usr/share"
+ -DOPKGETCDIR="/etc"
+ -DOPKGLOCKFILE="/var/lock/opkg.lock"
+ -DOPKGLIBDIR="/usr/lib"
+ -DHOST_CPU_STR="${HOST_CPU}"
+ -DBUILD_CPU=${BUILD_CPU}
+)
+
+ADD_SUBDIRECTORY(libbb)
+ADD_SUBDIRECTORY(libopkg)
+ADD_SUBDIRECTORY(src)
+
+IF(BUILD_TESTS)
+ ADD_SUBDIRECTORY(tests)
+ENDIF()
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(libbb C)
+
+ADD_LIBRARY(bb STATIC
+ all_read.c concat_path_file.c copy_file.c copy_file_chunk.c gzip.c
+ gz_open.c last_char_is.c make_directory.c mode_string.c parse_mode.c
+ safe_strncpy.c time_string.c unarchive.c unzip.c wfopen.c xfuncs.c
+ xreadlink.c
+)
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(libopkg C)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/..)
+LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libbb)
+
+ADD_LIBRARY(opkg STATIC
+ active_list.c conffile.c conffile_list.c file_util.c hash_table.c md5.c
+ nv_pair.c nv_pair_list.c opkg.c opkg_cmd.c opkg_conf.c opkg_configure.c
+ opkg_download.c opkg_install.c opkg_message.c opkg_remove.c
+ opkg_upgrade.c opkg_utils.c parse_util.c pkg.c pkg_depends.c pkg_dest.c
+ pkg_dest_list.c pkg_extract.c pkg_hash.c pkg_parse.c pkg_src.c
+ pkg_src_list.c pkg_vec.c sha256.c sprintf_alloc.c str_list.c
+ void_list.c xregex.c xsystem.c
+)
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(opkg-cl C)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libopkg)
+LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libopkg ${CMAKE_CURRENT_SOURCE_DIR}/../libbb)
+
+IF(STATIC_UBOX)
+ FIND_LIBRARY(ubox NAMES libubox.a)
+ELSE()
+ FIND_LIBRARY(ubox NAMES ubox)
+ENDIF()
+
+FIND_LIBRARY(pthread NAMES pthread)
+
+ADD_EXECUTABLE(opkg-cl opkg-cl.c)
+TARGET_LINK_LIBRARIES(opkg-cl opkg bb ${ubox} ${pthread})
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(opkg-tests C)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libopkg ${CMAKE_CURRENT_SOURCE_DIR}/..)
+LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libopkg ${CMAKE_CURRENT_SOURCE_DIR}/../libbb)
+
+IF(STATIC_UBOX)
+ FIND_LIBRARY(ubox NAMES libubox.a)
+ELSE()
+ FIND_LIBRARY(ubox NAMES ubox)
+ENDIF()
+
+FIND_LIBRARY(pthread NAMES pthread)
+
+ADD_EXECUTABLE(libopkg_test libopkg_test.c)
+TARGET_LINK_LIBRARIES(libopkg_test bb opkg bb ${ubox} ${pthread})
+
+ADD_EXECUTABLE(opkg_active_list_test opkg_active_list_test.c)
+TARGET_LINK_LIBRARIES(opkg_active_list_test bb opkg bb ${ubox} ${pthread})
+
+ADD_EXECUTABLE(opkg_extract_test opkg_extract_test.c)
+TARGET_LINK_LIBRARIES(opkg_extract_test bb opkg bb ${ubox} ${pthread})
+
+#ADD_EXECUTABLE(opkg_hash_test opkg_hash_test.c)
+#TARGET_LINK_LIBRARIES(opkg_hash_test bb opkg bb ${ubox} ${pthread})