FindSQLite3: Use package name as namespace

As we (hopefully) move toward a CPS world, it is helpful for imported
targets to use the package name as the namespace (as required by CPS).
Modify FindSQLite3 to do so. The old name is retained for compatibility.
This commit is contained in:
Matthew Woehlke
2025-12-08 11:14:43 -05:00
parent 3277ef73c8
commit d4754c1a0c
3 changed files with 32 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
FindSQLite3-namespace
---------------------
* The :module:`FindSQLite3` module now provides imported
targets with the ``SQLite3::`` prefix.

View File

@@ -21,10 +21,27 @@ Imported Targets
This module provides the following :ref:`Imported Targets`:
``SQLite::SQLite3``
``SQLite3::SQLite3``
Target encapsulating SQLite library usage requirements. It is available only
when SQLite is found.
.. versionadded:: 4.3
``SQLite::SQLite3``
Deprecated. Identical to ``SQLite3::SQLite3``.
If your project needs to support CMake < 4.3, consider adding the following
to your project after calling ``find_package(SQLite3 ...)``:
.. code-block:: cmake
if(NOT TARGET SQLite3::SQLite3) # CMake < 4.3
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
endif()
This will allow your project to use the new name while still permitting it to
compile with older versions of CMake.
Result Variables
^^^^^^^^^^^^^^^^
@@ -96,11 +113,18 @@ find_package_handle_standard_args(SQLite3
if(SQLite3_FOUND)
set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
set(SQLite3_LIBRARIES ${SQLite3_LIBRARY})
if(NOT TARGET SQLite3::SQLite3)
add_library(SQLite3::SQLite3 UNKNOWN IMPORTED)
set_target_properties(SQLite3::SQLite3 PROPERTIES
IMPORTED_LOCATION "${SQLite3_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}")
endif()
if(NOT TARGET SQLite::SQLite3)
add_library(SQLite::SQLite3 UNKNOWN IMPORTED)
set_target_properties(SQLite::SQLite3 PROPERTIES
IMPORTED_LOCATION "${SQLite3_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}")
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}"
DEPRECATION "The target name SQLite::SQLite3 is deprecated. Please use SQLite3::SQLite3 instead.")
endif()
endif()

View File

@@ -7,7 +7,7 @@ find_package(SQLite3 REQUIRED)
add_definitions(-DCMAKE_EXPECTED_SQLite3_VERSION="${SQLite3_VERSION}")
add_executable(test_tgt main.c)
target_link_libraries(test_tgt SQLite::SQLite3)
target_link_libraries(test_tgt SQLite3::SQLite3)
add_test(NAME test_tgt COMMAND test_tgt)
add_executable(test_var main.c)