2018-06-16 11:07:21 +08:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2022-02-17 05:00:36 +08:00
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
project(sqlite3 C)
|
|
|
|
|
2022-02-17 05:00:36 +08:00
|
|
|
option(WITH_ZLIB "Build sqlite3 with zlib support" OFF)
|
|
|
|
option(SQLITE3_SKIP_TOOLS "Disable build sqlite3 executable" OFF)
|
|
|
|
|
2023-01-24 07:49:20 +08:00
|
|
|
set(PKGCONFIG_LIBS_PRIVATE "")
|
2022-02-17 05:00:36 +08:00
|
|
|
|
2018-02-28 04:24:41 +08:00
|
|
|
add_library(sqlite3 sqlite3.c)
|
2016-10-19 04:09:04 +08:00
|
|
|
|
2022-02-17 05:00:36 +08:00
|
|
|
target_include_directories(sqlite3 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include>)
|
|
|
|
|
2018-06-16 11:07:21 +08:00
|
|
|
target_compile_definitions(
|
|
|
|
sqlite3
|
|
|
|
PRIVATE
|
2022-02-17 05:00:36 +08:00
|
|
|
$<$<CONFIG:Debug>:SQLITE_DEBUG=1>
|
|
|
|
$<$<CONFIG:Debug>:SQLITE_ENABLE_SELECTTRACE>
|
|
|
|
$<$<CONFIG:Debug>:SQLITE_ENABLE_WHERETRACE>
|
2018-06-16 11:07:21 +08:00
|
|
|
)
|
2020-08-15 01:29:18 +08:00
|
|
|
|
2022-02-17 05:00:36 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2023-01-24 07:49:20 +08:00
|
|
|
if (WIN32)
|
|
|
|
target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__declspec(dllexport)")
|
|
|
|
else()
|
2023-02-07 04:00:37 +08:00
|
|
|
target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__attribute__((visibility(\"default\")))")
|
2022-02-17 05:00:36 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-02-07 04:00:37 +08:00
|
|
|
if (NOT WIN32)
|
2018-06-16 11:07:21 +08:00
|
|
|
find_package(Threads REQUIRED)
|
2023-01-24 07:49:20 +08:00
|
|
|
target_link_libraries(sqlite3 PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
|
2023-02-07 04:00:37 +08:00
|
|
|
string(APPEND PKGCONFIG_LIBS_PRIVATE " -pthread")
|
|
|
|
foreach(LIB IN LISTS CMAKE_DL_LIBS)
|
|
|
|
string(APPEND PKGCONFIG_LIBS_PRIVATE " -l${LIB}")
|
|
|
|
endforeach()
|
2023-01-24 07:49:20 +08:00
|
|
|
|
2023-02-07 04:00:37 +08:00
|
|
|
if(SQLITE_ENABLE_FTS5 OR SQLITE_ENABLE_MATH_FUNCTIONS)
|
2023-01-24 07:49:20 +08:00
|
|
|
find_library(HAVE_LIBM m)
|
|
|
|
if(HAVE_LIBM)
|
|
|
|
target_link_libraries(sqlite3 PRIVATE m)
|
|
|
|
string(APPEND PKGCONFIG_LIBS_PRIVATE " -lm")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-09-19 11:50:08 +08:00
|
|
|
endif()
|
|
|
|
|
2018-02-28 04:24:41 +08:00
|
|
|
if(NOT SQLITE3_SKIP_TOOLS)
|
|
|
|
add_executable(sqlite3-bin shell.c)
|
2022-02-17 05:00:36 +08:00
|
|
|
|
2018-02-28 04:24:41 +08:00
|
|
|
target_link_libraries(sqlite3-bin PRIVATE sqlite3)
|
2023-02-07 04:00:37 +08:00
|
|
|
if (WITH_ZLIB)
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
target_link_libraries(sqlite3-bin PRIVATE ZLIB::ZLIB)
|
|
|
|
target_compile_definitions(sqlite3-bin PRIVATE SQLITE_HAVE_ZLIB)
|
|
|
|
endif()
|
2022-02-17 05:00:36 +08:00
|
|
|
|
2018-04-24 12:29:17 +08:00
|
|
|
install(TARGETS sqlite3-bin sqlite3
|
|
|
|
RUNTIME DESTINATION tools
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
2018-02-28 04:24:41 +08:00
|
|
|
endif()
|
|
|
|
|
2018-06-16 11:07:21 +08:00
|
|
|
install(
|
|
|
|
TARGETS sqlite3
|
2020-08-06 01:36:25 +08:00
|
|
|
EXPORT unofficial-sqlite3-targets
|
2016-09-19 11:50:08 +08:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
2018-02-28 04:24:41 +08:00
|
|
|
|
2023-02-07 04:00:37 +08:00
|
|
|
install(FILES sqlite3.h sqlite3ext.h sqlite3-vcpkg-config.h DESTINATION include CONFIGURATIONS Release)
|
2020-08-06 01:36:25 +08:00
|
|
|
install(EXPORT unofficial-sqlite3-targets NAMESPACE unofficial::sqlite3:: FILE unofficial-sqlite3-targets.cmake DESTINATION share/unofficial-sqlite3)
|
2021-09-23 04:00:06 +08:00
|
|
|
|
|
|
|
configure_file(sqlite3.pc.in sqlite3.pc @ONLY)
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sqlite3.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
|