CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #
  2. # Copyright (c) 2008-2016 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. # Define target name
  23. set (TARGET_NAME sqlite)
  24. # Define source files
  25. set (SOURCE_FILES src/sqlite3.c)
  26. # ATOMIC BEGIN
  27. set (INCLUDE_DIRS src)
  28. # ATOMIC END
  29. # Setup target
  30. setup_library ()
  31. # ATOMIC BEGIN
  32. # Define preprocessor macros
  33. target_compile_definitions (${TARGET_NAME} PUBLIC -DSQLITE_USE_URI=1 -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_SOUNDEX) # https://www.sqlite.org/compile.html
  34. if (WEB)
  35. # Do not use pthread and dl libraries for Web platform
  36. target_compile_definitions (${TARGET_NAME} PUBLIC -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION)
  37. elseif (MINGW)
  38. # We only support MinGW with "_mingw.h" header file, note the leading underscore
  39. target_compile_definitions (${TARGET_NAME} PRIVATE -D_HAVE__MINGW_H)
  40. endif ()
  41. foreach (VAR HAVE_STDINT_H HAVE_INTTYPES_H HAVE_MALLOC_H HAVE_MALLOC_USABLE_SIZE)
  42. if (${VAR})
  43. target_compile_definitions (${TARGET_NAME} PRIVATE -D${VAR})
  44. endif ()
  45. endforeach ()
  46. # ATOMIC END
  47. # Setup additional SQLite CLI standalone target (this target can be transfered and executed on an embedded device, such as Raspberry Pi and Android)
  48. if (NOT IOS AND NOT TVOS AND NOT WEB)
  49. # Define target name for SQLite shell
  50. set (TARGET_NAME isql)
  51. # Define source files
  52. set (SOURCE_FILES src/shell.c src/sqlite3.c src/sqlite3.h)
  53. # Define dependency libs
  54. if (NOT WIN32)
  55. # ATOMIC BEGIN
  56. set (LIBS dl)
  57. if (NOT ANDROID)
  58. list (APPEND LIBS pthread)
  59. endif ()
  60. # ATOMIC END
  61. if (READLINE_FOUND)
  62. add_definitions (-DHAVE_READLINE)
  63. list (APPEND INCLUDE_DIRS ${READLINE_INCLUDE_DIRS})
  64. list (APPEND LIBS ${READLINE_LIBRARIES})
  65. endif ()
  66. endif ()
  67. # Setup target
  68. setup_executable (NODEPS)
  69. endif ()
  70. # SQLite will not work correctly with the -ffast-math option, so unset it in this scope only
  71. # ATOMIC: Add check for empty CMAKE_C_FLAGS
  72. if (CMAKE_C_FLAGS)
  73. string (REPLACE -ffast-math "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") # Stringify for string replacement
  74. endif()