2018-06-16 11:07:21 +08:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2016-09-19 11:50:08 +08:00
|
|
|
project(sqlite3 C)
|
|
|
|
|
2018-02-28 04:24:41 +08:00
|
|
|
include_directories(.)
|
2016-10-19 04:09:04 +08:00
|
|
|
if(BUILD_SHARED_LIBS)
|
2020-05-16 08:04:42 +08:00
|
|
|
if(UNIX)
|
2019-06-21 00:40:50 +08:00
|
|
|
set(API "-DSQLITE_API=__attribute__((visibility(\"default\")))")
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
set(API "-DSQLITE_API=__declspec(dllexport)")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
|
|
|
endif()
|
2016-10-19 04:09:04 +08:00
|
|
|
else()
|
|
|
|
set(API "-DSQLITE_API=extern")
|
|
|
|
endif()
|
2018-02-28 04:24:41 +08:00
|
|
|
add_library(sqlite3 sqlite3.c)
|
2016-10-19 04:09:04 +08:00
|
|
|
|
2018-06-16 11:07:21 +08:00
|
|
|
target_compile_definitions(
|
|
|
|
sqlite3
|
|
|
|
PRIVATE
|
|
|
|
$<$<CONFIG:Debug>:SQLITE_DEBUG>
|
|
|
|
${API}
|
|
|
|
-DSQLITE_ENABLE_RTREE
|
|
|
|
-DSQLITE_ENABLE_UNLOCK_NOTIFY
|
2018-10-23 01:49:16 +08:00
|
|
|
-DSQLITE_ENABLE_COLUMN_METADATA
|
2018-06-16 11:07:21 +08:00
|
|
|
)
|
2020-08-15 01:29:18 +08:00
|
|
|
|
|
|
|
if(WITH_GEOPOLY)
|
|
|
|
add_compile_definitions(SQLITE_ENABLE_GEOPOLY)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_JSON1)
|
|
|
|
add_compile_definitions(SQLITE_ENABLE_JSON1)
|
|
|
|
endif()
|
|
|
|
|
2016-10-19 12:42:21 +08:00
|
|
|
target_include_directories(sqlite3 INTERFACE $<INSTALL_INTERFACE:include>)
|
2018-06-16 11:07:21 +08:00
|
|
|
if(NOT WIN32)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
target_link_libraries(sqlite3 PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
|
|
|
|
endif()
|
2016-12-07 02:08:15 +08:00
|
|
|
|
2018-02-28 04:24:41 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
|
2016-09-19 11:50:08 +08:00
|
|
|
target_compile_definitions(sqlite3 PRIVATE -DSQLITE_OS_WINRT=1)
|
|
|
|
endif()
|
|
|
|
|
2018-02-28 04:24:41 +08:00
|
|
|
if(NOT SQLITE3_SKIP_TOOLS)
|
|
|
|
add_executable(sqlite3-bin shell.c)
|
|
|
|
target_link_libraries(sqlite3-bin PRIVATE sqlite3)
|
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
|
|
|
|
|
|
|
install(FILES sqlite3.h sqlite3ext.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)
|