Browse Source

+ added cmake build config

master
Alex 'AdUser' Z 13 years ago
parent
commit
d3f2a491e6
  1. 61
      CMakeLists.txt
  2. 8
      src/CMakeLists.txt

61
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)

8
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")
Loading…
Cancel
Save