From d3f2a491e60527f542a0bf207f321009d7da30b9 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sun, 18 Sep 2011 23:09:42 +1100 Subject: [PATCH] + added cmake build config --- CMakeLists.txt | 61 ++++++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 8 ++++++ 2 files changed, 69 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5952133 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,61 @@ +SET(CNAME "json2torrent") +SET(VERSION 0.01) + +PROJECT(${CNAME} C) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# cmake modules +INCLUDE(CheckIncludeFile) +INCLUDE(CheckLibraryExists) +INCLUDE(CheckFunctionExists) + +IF (NOT CMAKE_BUILD_TYPE) + SET (CMAKE_BUILD_TYPE Debug) + SET (CMAKE_C_FLAGS "-ggdb -O0 -Wall -pedantic -DDEBUG") +ENDIF (NOT CMAKE_BUILD_TYPE) + +# set paths +SET(CMAKE_INSTALL_PREFIX "/usr") +SET(INSTALL_BIN "${CMAKE_INSTALL_PREFIX}/bin") +SET(INSTALL_LIB "${CMAKE_INSTALL_PREFIX}/lib") + +IF (NOT LIBDIR) + SET (LIBDIR "lib") +ENDIF (NOT LIBDIR) + +SET(REQUIRED_HEADERS + "ctype.h" "stdbool.h" "stdio.h" + "stdint.h" "stdlib.h" "string.h") + +FOREACH (HDR ${REQUIRED_HEADERS}) + CHECK_INCLUDE_FILE (${HDR} TEST_H) + IF (NOT TEST_H) + MESSAGE(FATAL_ERROR "Build aborted.") + ENDIF (NOT TEST_H) + UNSET(TEST_H CACHE) +ENDFOREACH() + +## checks +# yajl (yet another json library) +FIND_LIBRARY(LIB_YAJL yajl) + +IF (LIB_YAJL) + SET (BUILD_LIBS ${BUILD_LIBS} ${LIB_YAJL}) + SET (YAJL_FOUND "FOUND") +ELSE (LIB_YAJL) + MESSAGE (SEND_ERROR "yajl not found") +ENDIF (LIB_YAJL) + + +MESSAGE (STATUS "------------------------------------------") +MESSAGE (STATUS "Build type is: ${CMAKE_BUILD_TYPE}") +MESSAGE (STATUS "") +MESSAGE (STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") +MESSAGE (STATUS "Binaries directory: ${INSTALL_BIN}") +MESSAGE (STATUS "") +MESSAGE (STATUS "Required libraries:") +MESSAGE (STATUS " yajl: ${YAJL_FOUND}") +MESSAGE (STATUS "") +MESSAGE (STATUS "------------------------------------------") + +ADD_SUBDIRECTORY (src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..43c34cb --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(torrent2json "torrent2json.c") +#add_executable(json2torrent "json2torrent.c") + +target_link_libraries(torrent2json ${BUILD_LIBS}) +#target_link_libraries(json2torrent ${BUILD_LIBS}) + +install(TARGETS torrent2json + RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")