Skip to content

Commit

Permalink
[sqlite3] Improve usage on non-Windows; Fixes example and Fixes #3703
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Jun 16, 2018
1 parent a650bad commit 3726ce9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
26 changes: 17 additions & 9 deletions ports/sqlite3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)
project(sqlite3 C)

include_directories(.)
Expand All @@ -9,13 +9,19 @@ else()
endif()
add_library(sqlite3 sqlite3.c)

target_compile_definitions(sqlite3 PRIVATE
$<$<CONFIG:Debug>:SQLITE_DEBUG>
${API}
-DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_UNLOCK_NOTIFY
)
target_compile_definitions(
sqlite3
PRIVATE
$<$<CONFIG:Debug>:SQLITE_DEBUG>
${API}
-DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_UNLOCK_NOTIFY
)
target_include_directories(sqlite3 INTERFACE $<INSTALL_INTERFACE:include>)
if(NOT WIN32)
find_package(Threads REQUIRED)
target_link_libraries(sqlite3 PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
endif()

if(CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
target_compile_definitions(sqlite3 PRIVATE -DSQLITE_OS_WINRT=1)
Expand All @@ -32,11 +38,13 @@ if(NOT SQLITE3_SKIP_TOOLS)
)
endif()

install(TARGETS sqlite3 EXPORT sqlite3Config
install(
TARGETS sqlite3
EXPORT sqlite3
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

install(FILES sqlite3.h sqlite3ext.h DESTINATION include CONFIGURATIONS Release)
install(EXPORT sqlite3Config DESTINATION share/sqlite3)
install(EXPORT sqlite3 FILE sqlite3-targets.cmake DESTINATION share/sqlite3)
2 changes: 1 addition & 1 deletion ports/sqlite3/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: sqlite3
Version: 3.24.0
Version: 3.24.0-1
Description: SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

Feature: tool
Expand Down
13 changes: 7 additions & 6 deletions ports/sqlite3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ vcpkg_configure_cmake(
)

vcpkg_install_cmake()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(READ ${CURRENT_PACKAGES_DIR}/debug/share/sqlite3/sqlite3Config-debug.cmake SQLITE3_DEBUG_CONFIG)
string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" SQLITE3_DEBUG_CONFIG "${SQLITE3_DEBUG_CONFIG}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/sqlite3/sqlite3Config-debug.cmake "${SQLITE3_DEBUG_CONFIG}")
endif()
vcpkg_fixup_cmake_targets()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)

configure_file(
${CMAKE_CURRENT_LIST_DIR}/sqlite3-config.in.cmake
${CURRENT_PACKAGES_DIR}/share/sqlite3/sqlite3-config.cmake
@ONLY
)

file(WRITE ${CURRENT_PACKAGES_DIR}/share/sqlite3/copyright "SQLite is in the Public Domain.\nhttp://www.sqlite.org/copyright.html\n")
vcpkg_copy_pdbs()
7 changes: 7 additions & 0 deletions ports/sqlite3/sqlite3-config.in.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static" AND NOT WIN32)
include(CMakeFindDependencyMacro)
find_dependency(Threads)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/sqlite3-targets.cmake)

0 comments on commit 3726ce9

Please sign in to comment.