Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Replace custom FindSqlite3 with FindSQLite3 built-in #4007

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,22 @@ if(NOT EXE_SQLITE3)
message(SEND_ERROR "sqlite3 binary not found!")
endif()

find_package(Sqlite3 REQUIRED)
if(NOT SQLITE3_FOUND)
message(SEND_ERROR "sqlite3 dependency not found!")
# Deprecated variables since PROJ 9.4.0
if(DEFINED SQLITE3_INCLUDE_DIR)
message(DEPRECATION "Use SQLite3_INCLUDE_DIR instead of SQLITE3_INCLUDE_DIR")
set(SQLite3_INCLUDE_DIR ${SQLITE3_INCLUDE_DIR})
endif()
if(DEFINED SQLITE3_LIBRARY)
message(DEPRECATION "Use SQLite3_LIBRARY instead of SQLITE3_LIBRARY")
set(SQLite3_LIBRARY ${SQLITE3_LIBRARY})
Comment on lines +182 to +186
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR the target variables are (meant to be) cache variables. But it probably works as is.

endif()

find_package(SQLite3 REQUIRED)

# Would build and run with older versions, but with horrible performance
# See https://github.com/OSGeo/PROJ/issues/1718
if("${SQLITE3_VERSION}" VERSION_LESS "3.11")
message(SEND_ERROR "sqlite3 >= 3.11 required!")
if(SQLite3_VERSION VERSION_LESS "3.11")
message(SEND_ERROR "SQLite3 >= 3.11 required!")
endif()

################################################################################
Expand Down
88 changes: 0 additions & 88 deletions cmake/FindSqlite3.cmake

This file was deleted.

26 changes: 12 additions & 14 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,8 @@ On Windows, one may need to specify generator::

cmake -G "Visual Studio 15 2017" ..

If the SQLite3 dependency is installed in a custom location, specify the
paths to the include directory and the library::

cmake -DSQLITE3_INCLUDE_DIR=/opt/SQLite/include -DSQLITE3_LIBRARY=/opt/SQLite/lib/libsqlite3.so ..

Alternatively, the custom prefix for SQLite3 can be specified::
If the SQLite3 dependency is installed in a custom location, specify
:option:`CMAKE_PREFIX_PATH`::

cmake -DCMAKE_PREFIX_PATH=/opt/SQLite ..

Expand Down Expand Up @@ -315,6 +311,12 @@ All cached entries can be viewed using ``cmake -LAH`` from a build directory.
:envvar:`OSGEO4W_ROOT` (if set), otherwise is ``c:/OSGeo4W``.
Default for Unix-like is ``/usr/local/``.

.. option:: CMAKE_PREFIX_PATH

`CMake variable
<https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html>`_
used to specify installation prefixes for SQLite3 and other dependencies.

.. option:: CMAKE_UNITY_BUILD=OFF

.. versionadded:: 9.4
Expand All @@ -341,14 +343,10 @@ All cached entries can be viewed using ``cmake -LAH`` from a build directory.

Path to an ``sqlite3`` or ``sqlite3.exe`` executable.

.. option:: SQLITE3_INCLUDE_DIR

Path to an include directory with the ``sqlite3.h`` header file.

.. option:: SQLITE3_LIBRARY

Path to a shared or static library file, such as ``sqlite3.dll``,
``libsqlite3.so``, ``sqlite3.lib`` or other name.
.. deprecated:: 9.4.0
``SQLITE3_INCLUDE_DIR`` and ``SQLITE3_LIBRARY`` should be replaced with
``SQLite3_INCLUDE_DIR`` and ``SQLite3_LIBRARY``, respectively.
Users may also consider :option:`CMAKE_PREFIX_PATH` instead.

.. option:: ENABLE_CURL=ON

Expand Down
10 changes: 5 additions & 5 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ endif() # USE_EXTERNAL_GTEST
#

include_directories(${PROJ_SOURCE_DIR}/include)
include_directories(${SQLITE3_INCLUDE_DIR})

# Add the directory containing proj_config.h
include_directories(${PROJ_BINARY_DIR}/src)

Expand Down Expand Up @@ -140,8 +140,8 @@ set_property(SOURCE ${PROJ_TEST_CPP_API_SOURCES} PROPERTY SKIP_UNITY_BUILD_INCLU

target_link_libraries(proj_test_cpp_api
PRIVATE GTest::gtest
PRIVATE ${PROJ_LIBRARIES}
PRIVATE ${SQLITE3_LIBRARY})
PRIVATE SQLite::SQLite3
PRIVATE ${PROJ_LIBRARIES})
add_test(NAME proj_test_cpp_api COMMAND proj_test_cpp_api)
set_property(TEST proj_test_cpp_api
PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT})
Expand Down Expand Up @@ -172,8 +172,8 @@ if(CURL_ENABLED)
endif()
target_link_libraries(test_network
PRIVATE GTest::gtest
PRIVATE ${PROJ_LIBRARIES}
PRIVATE ${SQLITE3_LIBRARY})
PRIVATE SQLite::SQLite3
PRIVATE ${PROJ_LIBRARIES})
if(TIFF_ENABLED)
add_test(NAME test_network COMMAND test_network)
set_property(TEST test_network
Expand Down
Loading