build: add cmake build system
authorJo-Philipp Wich <jo@mein.io>
Fri, 17 Feb 2017 14:08:03 +0000 (15:08 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 17 Feb 2017 14:08:03 +0000 (15:08 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
CMakeLists.txt [new file with mode: 0644]
libbb/CMakeLists.txt [new file with mode: 0644]
libopkg/CMakeLists.txt [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
tests/CMakeLists.txt [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..721f848
--- /dev/null
@@ -0,0 +1,33 @@
+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()
diff --git a/libbb/CMakeLists.txt b/libbb/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0eb84fb
--- /dev/null
@@ -0,0 +1,10 @@
+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
+)
diff --git a/libopkg/CMakeLists.txt b/libopkg/CMakeLists.txt
new file mode 100644 (file)
index 0000000..97edb8e
--- /dev/null
@@ -0,0 +1,16 @@
+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
+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5e1deca
--- /dev/null
@@ -0,0 +1,17 @@
+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})
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..49f2c9d
--- /dev/null
@@ -0,0 +1,26 @@
+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})