mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-29 03:34:26 +08:00
185a7aa23a
* [sqlite3] Control features with a configuration header rather than CMake or pkgconfig. Resolves https://github.com/microsoft/vcpkg/pull/29335 Alternate of https://github.com/microsoft/vcpkg/pull/29258 @Neumann-A points out that controlling features through CMake configs and pkgconfig causes MSBuild customers to be left out in the cold. Moreover, attempting to add parenthesis to the SQLITE_API marco breaks autotools. This change makes such parenthesis unnecessary and ensures the configuration bits are used with automatic linking. * Ensure feature controls affect the .c too, use less MAYBE_UNUSED. * Correctly note that zlib has no effect without tools. * Always add DL_LIBS even when static linking. * [sqlitecpp] Unconditionally enable column metadata because that is done in the sqlite3 port. * Add missing -l prefix on CMAKE_DL_LIBS
77 lines
2.4 KiB
CMake
77 lines
2.4 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
|
|
project(sqlite3 C)
|
|
|
|
option(WITH_ZLIB "Build sqlite3 with zlib support" OFF)
|
|
option(SQLITE3_SKIP_TOOLS "Disable build sqlite3 executable" OFF)
|
|
|
|
set(PKGCONFIG_LIBS_PRIVATE "")
|
|
|
|
add_library(sqlite3 sqlite3.c)
|
|
|
|
target_include_directories(sqlite3 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include>)
|
|
|
|
target_compile_definitions(
|
|
sqlite3
|
|
PRIVATE
|
|
$<$<CONFIG:Debug>:SQLITE_DEBUG=1>
|
|
$<$<CONFIG:Debug>:SQLITE_ENABLE_SELECTTRACE>
|
|
$<$<CONFIG:Debug>:SQLITE_ENABLE_WHERETRACE>
|
|
)
|
|
|
|
if (BUILD_SHARED_LIBS)
|
|
if (WIN32)
|
|
target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__declspec(dllexport)")
|
|
else()
|
|
target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__attribute__((visibility(\"default\")))")
|
|
endif()
|
|
endif()
|
|
|
|
if (NOT WIN32)
|
|
find_package(Threads REQUIRED)
|
|
target_link_libraries(sqlite3 PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
|
|
string(APPEND PKGCONFIG_LIBS_PRIVATE " -pthread")
|
|
foreach(LIB IN LISTS CMAKE_DL_LIBS)
|
|
string(APPEND PKGCONFIG_LIBS_PRIVATE " -l${LIB}")
|
|
endforeach()
|
|
|
|
if(SQLITE_ENABLE_FTS5 OR SQLITE_ENABLE_MATH_FUNCTIONS)
|
|
find_library(HAVE_LIBM m)
|
|
if(HAVE_LIBM)
|
|
target_link_libraries(sqlite3 PRIVATE m)
|
|
string(APPEND PKGCONFIG_LIBS_PRIVATE " -lm")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT SQLITE3_SKIP_TOOLS)
|
|
add_executable(sqlite3-bin shell.c)
|
|
|
|
target_link_libraries(sqlite3-bin PRIVATE sqlite3)
|
|
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()
|
|
|
|
install(TARGETS sqlite3-bin sqlite3
|
|
RUNTIME DESTINATION tools
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
)
|
|
endif()
|
|
|
|
install(
|
|
TARGETS sqlite3
|
|
EXPORT unofficial-sqlite3-targets
|
|
RUNTIME DESTINATION bin
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
)
|
|
|
|
install(FILES sqlite3.h sqlite3ext.h sqlite3-vcpkg-config.h DESTINATION include CONFIGURATIONS Release)
|
|
install(EXPORT unofficial-sqlite3-targets NAMESPACE unofficial::sqlite3:: FILE unofficial-sqlite3-targets.cmake DESTINATION share/unofficial-sqlite3)
|
|
|
|
configure_file(sqlite3.pc.in sqlite3.pc @ONLY)
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sqlite3.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
|