|
| 1 | +# Copyright (C) 2007-2011 LuaDist. |
| 2 | +# Created by Peter Kapec |
| 3 | +# Redistribution and use of this file is allowed according to the terms of the MIT license. |
| 4 | +# For details see the COPYRIGHT file distributed with LuaDist. |
| 5 | +# Please note that the package source code is licensed under its own license. |
| 6 | + |
| 7 | +# IMPORTANT !!!! Files opcode.h, opcode.c, parse.h, parse.c were manualy generated... |
| 8 | + |
| 9 | +# Project |
| 10 | + PROJECT(sqlite C) |
| 11 | + CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
| 12 | + INCLUDE(dist.cmake) |
| 13 | + |
| 14 | +# Macros |
| 15 | + MACRO(ADD_PREFIX prefix rootlist) |
| 16 | + SET(outlist ) |
| 17 | + FOREACH(root ${${rootlist}}) |
| 18 | + LIST(APPEND outlist ${prefix}${root}) |
| 19 | + ENDFOREACH(root) |
| 20 | + SET(${rootlist} ${outlist}) |
| 21 | + ENDMACRO(ADD_PREFIX) |
| 22 | + |
| 23 | +# SQLite configuration |
| 24 | + INCLUDE(CheckFunctionExists) |
| 25 | + |
| 26 | + CHECK_FUNCTION_EXISTS("usleep" HAVE_USLEEP) |
| 27 | + IF(HAVE_USLEEP) |
| 28 | + ADD_DEFINITIONS(-DHAVE_USLEEP=1) |
| 29 | + ENDIF() |
| 30 | + |
| 31 | + FIND_PACKAGE(Threads) |
| 32 | + IF(Threads_FOUND) |
| 33 | + IF(CMAKE_USE_PTHREADS_INIT) |
| 34 | + ADD_DEFINITIONS(-DTHREADSAFE=1) |
| 35 | + SET(EXTRA_LIBS ${CMAKE_THREAD_LIBS_INIT}) |
| 36 | + ENDIF() |
| 37 | + ENDIF() |
| 38 | + |
| 39 | + # Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1 |
| 40 | + # to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all |
| 41 | + # malloc()s and free()s in order to track down memory leaks. |
| 42 | + # |
| 43 | + # ADD_DEFINITIONS(-DMEMORY_DEBUG=1) |
| 44 | + |
| 45 | + # SQLite uses some expensive assert() statements in the inner loop. |
| 46 | + # You can make the library go almost twice as fast if you compile |
| 47 | + # with -DNDEBUG=1 |
| 48 | + ADD_DEFINITIONS(-DNDEBUG=1) |
| 49 | + |
| 50 | + FIND_PACKAGE(Readline) |
| 51 | + IF(READLINE_FOUND) |
| 52 | + INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIRS}) |
| 53 | + ENDIF() |
| 54 | + |
| 55 | + #### Should the database engine assume text is coded as UTF-8 or iso8859? |
| 56 | + # |
| 57 | + # ENCODING = UTF8 or ISO8859 |
| 58 | + ADD_DEFINITIONS(-DENCODING=ISO8859) |
| 59 | + |
| 60 | + |
| 61 | + INCLUDE(CheckTypeSize) |
| 62 | + CHECK_TYPE_SIZE("char*" SQLITE_PTR_SZ VARIABLE) |
| 63 | + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) |
| 64 | + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) |
| 65 | + |
| 66 | + SET(VERS "2.8.17") |
| 67 | + SET(ENCODING "ISO8859") |
| 68 | + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sqlite.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/sqlite.h) |
| 69 | + |
| 70 | +# SQLite Library |
| 71 | + INCLUDE_DIRECTORIES(. src) |
| 72 | + |
| 73 | + SET(SQLITE_SRCS |
| 74 | + attach.c auth.c btree.c btree_rb.c build.c copy.c date.c delete.c |
| 75 | + expr.c func.c hash.c insert.c |
| 76 | + main.c opcodes.c os.c pager.c parse.c pragma.c printf.c random.c |
| 77 | + select.c table.c tokenize.c trigger.c update.c util.c |
| 78 | + vacuum.c vdbe.c vdbeaux.c where.c |
| 79 | + ) |
| 80 | + ADD_PREFIX("src/" SQLITE_SRCS) |
| 81 | + |
| 82 | + |
| 83 | + ADD_LIBRARY(sqlite SHARED ${SQLITE_SRCS} sqlite.def) |
| 84 | + IF(CMAKE_USE_PTHREADS_INIT) |
| 85 | + TARGET_LINK_LIBRARIES(sqlite ${EXTRA_LIBS}) |
| 86 | + ENDIF() |
| 87 | + |
| 88 | + INSTALL(TARGETS sqlite RUNTIME DESTINATION ${INSTALL_BIN} LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB}) |
| 89 | + |
| 90 | +# SQLite client |
| 91 | + ADD_EXECUTABLE(sqlite-app src/shell.c) |
| 92 | + SET_TARGET_PROPERTIES(sqlite-app PROPERTIES OUTPUT_NAME sqlite CLEAN_DIRECT_OUTPUT 1 ) |
| 93 | + TARGET_LINK_LIBRARIES(sqlite-app sqlite) |
| 94 | + IF(READLINE_LIBRARIES) |
| 95 | + TARGET_LINK_LIBRARIES(sqlite-app ${READLINE_LIBRARIES}) |
| 96 | + ENDIF() |
| 97 | + INSTALL(TARGETS sqlite-app RUNTIME DESTINATION ${INSTALL_BIN} LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB}) |
| 98 | + |
| 99 | +# Install Headers |
| 100 | + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sqlite.h DESTINATION ${INSTALL_INC}) |
| 101 | + |
0 commit comments