Skip to content

Commit d4754c1

Browse files
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.
1 parent 3277ef7 commit d4754c1

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FindSQLite3-namespace
2+
---------------------
3+
4+
* The :module:`FindSQLite3` module now provides imported
5+
targets with the ``SQLite3::`` prefix.

Modules/FindSQLite3.cmake

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,27 @@ Imported Targets
2121
2222
This module provides the following :ref:`Imported Targets`:
2323
24-
``SQLite::SQLite3``
24+
``SQLite3::SQLite3``
2525
Target encapsulating SQLite library usage requirements. It is available only
2626
when SQLite is found.
2727
28+
.. versionadded:: 4.3
29+
30+
``SQLite::SQLite3``
31+
Deprecated. Identical to ``SQLite3::SQLite3``.
32+
33+
If your project needs to support CMake < 4.3, consider adding the following
34+
to your project after calling ``find_package(SQLite3 ...)``:
35+
36+
.. code-block:: cmake
37+
38+
if(NOT TARGET SQLite3::SQLite3) # CMake < 4.3
39+
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
40+
endif()
41+
42+
This will allow your project to use the new name while still permitting it to
43+
compile with older versions of CMake.
44+
2845
Result Variables
2946
^^^^^^^^^^^^^^^^
3047
@@ -96,11 +113,18 @@ find_package_handle_standard_args(SQLite3
96113
if(SQLite3_FOUND)
97114
set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
98115
set(SQLite3_LIBRARIES ${SQLite3_LIBRARY})
116+
if(NOT TARGET SQLite3::SQLite3)
117+
add_library(SQLite3::SQLite3 UNKNOWN IMPORTED)
118+
set_target_properties(SQLite3::SQLite3 PROPERTIES
119+
IMPORTED_LOCATION "${SQLite3_LIBRARY}"
120+
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}")
121+
endif()
99122
if(NOT TARGET SQLite::SQLite3)
100123
add_library(SQLite::SQLite3 UNKNOWN IMPORTED)
101124
set_target_properties(SQLite::SQLite3 PROPERTIES
102125
IMPORTED_LOCATION "${SQLite3_LIBRARY}"
103-
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}")
126+
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}"
127+
DEPRECATION "The target name SQLite::SQLite3 is deprecated. Please use SQLite3::SQLite3 instead.")
104128
endif()
105129
endif()
106130

Tests/FindSQLite3/Test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ find_package(SQLite3 REQUIRED)
77
add_definitions(-DCMAKE_EXPECTED_SQLite3_VERSION="${SQLite3_VERSION}")
88

99
add_executable(test_tgt main.c)
10-
target_link_libraries(test_tgt SQLite::SQLite3)
10+
target_link_libraries(test_tgt SQLite3::SQLite3)
1111
add_test(NAME test_tgt COMMAND test_tgt)
1212

1313
add_executable(test_var main.c)

0 commit comments

Comments
 (0)